Hide Table of Contents
RunCommand2 Method (IApplication)
Errors[out]
Status of running the command as defined in dsRunCommandError_e

Runs the specified command.

.NET Syntax

Visual Basic (Declaration) 
Function RunCommand2( _
   BSTR CommandString As System.String, _
   VARIANT ParameterStrArray As System.Object, _
   VARIANT ParameterTypeLongArray As System.Object, _
   VARIANT_BOOL HideCommandTitle As System.Boolean _
) As dsRunCommandError_e
C# 
dsRunCommandError_e RunCommand2( 
   System.string CommandString,
   System.object ParameterStrArray,
   System.object ParameterTypeLongArray,
   System.bool HideCommandTitle
)
JavaScript 
RunCommand2( 
   CommandString : System.String,
   ParameterStrArray : System.Object,
   ParameterTypeLongArray : System.Object,
   HideCommandTitle : Boolean,\n) : String
COM native C++ 
HRESULT RunCommand2( 
   const dsString& CommandString,
,
   VARIANT ParameterStrArray,
,
   VARIANT ParameterTypeLongArray,
,
   bool HideCommandTitle
,
   dsRunCommandError_e* Errors
) 
C++ 
DSRESULT RunCommand2( 
   BSTR CommandString,
,
   VARIANT ParameterStrArray,
,
   VARIANT ParameterTypeLongArray,
,
   VARIANT_BOOL HideCommandTitle
,
   dsRunCommandError_e* Errors
) 

Parameters

CommandString
Name of command to run (see Remarks)
ParameterStrArray
Array of parameters to execute with the command
ParameterTypeLongArray
Array of ParameterStrArray types as defined by dsResType_e; the size of this array much match the size of ParameterStrArray
HideCommandTitle
True to hide the command in the command window, false to show the command in the command window

Parameters

Errors[out] or Return Value
Status of running the command as defined in dsRunCommandError_e

Example

Create a C++ program in Visual Studio using the C++ snippet below, substituting your_pdf with the full path to a PDF file on your computer.

=======================================================================

C++ snippet attaches and detaches your_pdf

=============================================================================

dsCommandMessage_ptr commandline;

application->GetCommandMessage(&commandline);

 

dsRunCommandError_e error = dsRunCommand_InvalidCommand;

dsStringArray parameters;

dsLongArray parametersLong;

dsString strFile = L"your_pdf";

dsResType_e type = dsResType_String;

parameters.add( strFile );

parametersLong.add( type );

 

application->RunCommand2( L"_ATTACHPDF", parameters, parametersLong, true, &error );

commandline->PrintLine( error != dsRunCommand_Succeeded ? L"Run command failed" : L"Run command passed!" );

 

dsDocument_ptr document;

application->GetActiveDocument( &document );

 

dsLongArray ExternalDefinitionTypeLongArray;

dsObjectPtrArray ExternalDefinitionsArray;

document->GetImmediateChildReferences( &ExternalDefinitionTypeLongArray, &ExternalDefinitionsArray );

 

dsModel_ptr dsModel;

document->GetModel( &dsModel );

 

dsSketchManager_ptr sketchManager;

dsModel->GetSketchManager( &sketchManager );

 

dsPdfDefinition_c* pdfDefinition = ( dsPdfDefinition_c* )ExternalDefinitionsArray[ 0 ];

 

bool bRet;

sketchManager->DetachPdfDefinition( pdfDefinition, &bRet );

commandline->PrintLine( bRet ? L"Passed to detach Pdf" : L"Failed to detach PDF" );

Example

Remarks

Depending on the programming language that you use, either:

  • append \n to the command
    - or -
  • include & Chr(10) after the command

    These control strings emulate a user pressing the Enter key in DraftSight. The number of control strings should correspond to the number of times a user is required to press the Enter key for the command in DraftSight.

For example: 

To delete all entities in a drawing in this programming language... Call...
C#

int state;

state = (int)dsApp.RunCommand("DELETE ALL\n\n", false);

VB.NET

Dim state as Integer;

state = dsApp.RunCommand("DELETE ALL" & Chr(10) & Chr(10), False)

VBA

Dim state as Long;

state = dsApp.RunCommand("DELETE ALL" & Chr(10) & Chr(10), False)

 

 

See Also

Availability

DraftSight 2024 SP02


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   RunCommand2 Method (IApplication)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:




x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2024 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.