SE V20 Addin Event

 

I have one Addin running in Solid Edge V20. It is represented by a Menu on solid Edge MenuBar. I want to call one of the addin command in another exe using StartCommand(ID). How can I get this "ID" for the addin command at runtime?

 

Posted by: Manish Wagh
Post date: 4/28/2008 3:30:01 AM

4 REPLIES

RE: SE V20 Addin Event

 

Hi Manish,

see this post:

http://www.jasonnewell.net/Forums/tabid/55/forumid/1/tpage/1/view/topic/postid/703/Default.aspx#705

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 4/28/2008 10:57:42 PM

RE: SE V20 Addin Event

 

Hi Calum,

Thanks for the update. The solution I see is that - Get SE Command ID generated at runtime by SE and write in some text file. Then reading this ID from our exe for startcommand(). Actually I am looking for another solution ....

Can we Execute this command using methods

Application->Environments->ActiveEnvironment->CommandBars->CommandBar

I am facing problem after CommandBars. I tried to get ActiveMenuBar of CommandBars but could not get id. sample code is

second call to AutomationWraper is failing at redline

HRESULT hr = AutomationWraper(DISPATCH_PROPERTYGET, &resCmdBars, pActiveEnv, L"CommandBars", 0);

VARIANT resActiveBar; VariantInit(&resActiveBar);

hr = AutomationWraper(DISPATCH_PROPERTYGET, &resActiveBar, pCmdBars, L"ActiveMenuBar", 0);

IDispatch * pCmdBars = resCmdBars.pdispVal;

 

 

HRESULT AutomationWraper(int autoType, VARIANT *pvResult, IDispatch *pDisp,

LPOLESTR ptName, int cArgs...)

{

BOOL bFlag = TRUE;

 

// Begin variable-argument list...

va_list marker;

va_start(marker, cArgs);

if(!pDisp)

{

LOG_INFO(_T("[CSEAppManager::AutomationWraper] Invalid Interface pointer passed"));

_exit(0);

}

// Variables used...

DISPPARAMS dp = { NULL, NULL, 0, 0 };

DISPID dispidNamed = DISPID_PROPERTYPUT;

DISPID dispID;

HRESULT hr = S_OK;

hr = pDisp->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);

if(FAILED(hr))

{

LOG_INFO(_T("[CSEAppManager::AutomationWraper] method/property name not supported"));

bFlag = FALSE;

}

 

if(bFlag == TRUE)

{

VARIANT *pArgs = new VARIANT[cArgs+1];

// Extract arguments...

for(int i=0; i

pArgs = va_arg(marker, VARIANT);

}

// Build DISPPARAMS

dp.cArgs = cArgs;

dp.rgvarg = pArgs;

 

// Handle special-case for property-puts!

if(autoType & DISPATCH_PROPERTYPUT) {

dp.cNamedArgs = 1;

dp.rgdispidNamedArgs = &dispidNamed;

}

 

EXCEPINFO pInfo;

 

// Make the call!

hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &dp, pvResult, &pInfo, NULL);

if(FAILED(hr)){

 

 

bFlag = FALSE;

}

SAFE_DELETE_ARRAY(pArgs);

}

 

va_end(marker);

if(bFlag == FALSE)

{

_exit(0);

}

LOG_INFO(_T("[CSEAppManager::AutomationWraper] Exiting"));

return hr;

 }

 

 

Is executing Addin command possible using this approach ?

 

 

Posted by: Manish Wagh
Post date: 4/28/2008 11:20:05 PM

RE: SE V20 Addin Event

 

Hi Manish,

I'll have to look into it later. Just one thing, I'm assumming the following code:HRESULT hr = AutomationWraper(DISPATCH_PROPERTYGET, &resCmdBars, pActiveEnv, L"CommandBars", 0);VARIANT resActiveBar; VariantInit(&resActiveBar);hr = AutomationWraper(DISPATCH_PROPERTYGET, &resActiveBar, pCmdBars, L"ActiveMenuBar", 0);IDispatch * pCmdBars = resCmdBars.pdispVal;

Is actually written this way:HRESULT hr = AutomationWraper(DISPATCH_PROPERTYGET, &resCmdBars, pActiveEnv, L"CommandBars", 0);IDispatch * pCmdBars = resCmdBars.pdispVal;VARIANT resActiveBar; VariantInit(&resActiveBar);hr = AutomationWraper(DISPATCH_PROPERTYGET, &resActiveBar, pCmdBars, L"ActiveMenuBar", 0);

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 4/28/2008 11:59:26 PM

RE: SE V20 Addin Event

 

Yes right !

That was my copy paste mistake .

What you wrote is correct.

In that code I am having problem in getting property "ActiveMenuBar" 

Regards

Manish

 

Posted by: Manish Wagh
Post date: 4/29/2008 12:05:56 AM