Hide Table of Contents
CreateCommand Method (IApplication)
Cmd[out]
Command

Obsolete. Superseded by IApplication::CreateCommand2.

.NET Syntax

Visual Basic (Declaration) 
Function CreateCommand( _
   const dsString& ApiUuid As System.String, _
   const dsString& CmdName As System.String, _
   dsCreateCommandError_e* Error As dsCreateCommandError_e _
) As Command
C# 
Command CreateCommand( 
   System.string ApiUuid,
   System.string CmdName,
   out dsCreateCommandError_e Error
)
JavaScript 
CreateCommand( 
   ApiUuid : String,
   CmdName : String
) : {
   Error : String,
   Cmd : dsCommand
}
COM native C++ 
HRESULT CreateCommand( 
   BSTR ApiUuid,
   BSTR CmdName,
   dsCreateCommandError_e* Error,
   ICommand** Cmd
) 
C++ 
DSRESULT CreateCommand( 
   const dsString& ApiUuid,
   const dsString& CmdName,
   dsCreateCommandError_e* Error,
   dsCommand** Cmd
) 

Parameters

ApiUuid

UUID of the add-in or non add-in application

CmdName
Unique name for the command (see Remarks)
Error[out]
Status of creating the command as defined in dsCreateCommandError_e
Cmd[out] or Return Value
Command

Example

The following code snippets show how to add a command for the command window:

COM native C++

DsAddinConnection.cpp   
    DsAddinUserCommand pNotepad(m_sApiUuid, L"Notepad", L"^C^CNotepad", L"Opens Notepad", L"path_and_file_name.bmp", L"path_and_file_name.png");
  

DsAddinUserCommand.cpp 

DsAddinUserCommand::DsAddinUserCommand( _bstr_t ApiUuid, _bstr_t UserCmdName, _bstr_t CmdString, _bstr_t Description, _bstr_t SmallIcon, _bstr_t LargeIcon )

{

     CDsAddinConnection *dsConnection = getMyApp(); 

     dsCreateCommandError_e commandErr;

     // User command dependent on pre-defined command

     ICommand* pCommand = dsConnection->m_DsApp->CreateCommand( ApiUuid, UserCmdName, &commandErr );

     m_DsUserCommand = dsConnection->m_DsApp->CreateUserCommand( ApiUuid, UserCmdName, CmdString, Description, SmallIcon, LargeIcon, &commandErr ); 

     DsAddinCommand *dsAddCom = new DsAddinCommand(pCommand); 

}

 

C++ 

bool myApplication::CreateUserInterfaceAndCommands()

{

dsString emptyStr = L"";

dsString UserCommandName = L"qAddin1_Notepad";

dsString Description = L"Opens Notepad";

dsString UserCmdString = L"^C^CqAddin1_Notepad";

 

const int MENU_POSITION = 9; //Menu should be between "Modify" and "Tools" menus

 

dsApplication_c *dsApp = getDsApp();

dsCreateCommandError_e Error;

 

// User command dependent on pre-defined command

dsApp->CreateCommand(myApplication::appID, UserCommandName, &Error, &pCmd );

if(( Error == 0 ) )

{

RegisterCommandExecuteNotifyHook( pCmd );

dsUserCommand_ptr pUserCmd;

dsApp->CreateUserCommand( myApplication::appID, UserCommandName, UserCmdString, Description, L"path_and_file_name.bmp", L"path_and_file_name.png", dsUIState_Document, &Error, &pUserCmd ); 

Back to top

Remarks

If CmdName already exists, then dsCreateCommand_e.dsCreateCommandError_CommandNameExisted is returned for Error.

Use the string specified for CmdName for IApplication::CreateUserCommand's UserCmdName parameter; e.g.; apiCmd.

To see a list of existing commands:

  1. Right-click a toolbar in the user interface.
  2. Select Customize Interface.
  3. Click Commands on the left side of the dialog.
  4. Use the scroll bar to see the list of existing commands.
  5. To quickly locate a command that you've added:
    1. Type the name of the command in Find.
    2. Click the name of the command in the Name column.
    3. Examine the information at the bottom of the dialog.
 

See Also

Availability

DraftSight V1R1


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:   CreateCommand 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) 2019 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.