Author:mar_kq
Posted: Wed Dec 28, 2016 6:53 pm (GMT+1)
Hi,
Thanks for the Reply. I guess you describe the Problem correctly. I''ll recap my process:
1- I have registered a Menu command (no Palette)
2- This Menu command calls the managed dll which instantiates a custom WPF Interface (also connecting to other applications)
3- An Event in the WPF is calling the "GetPropertiesSpace" function (below) which uses several API methods.
4- So far I experience issues Only with the ACAPI_Element_GetMemo function.
GetPropertiesSpace:
I have attempted to use the ACAPI_Command_CallFromEventLoop you suggested, with the example in the documentation, but so far with no avail.
When I call the Do_CommandCallFromEventLoop(); from the managed Code I get the same Error on the ACAPI_Command_CallFromEventLoop as with the GetMemo.
I also tried with a sample for the DWG IO Add-On but I get the same Error as before):
I also found a post that was perhaps related: http://archicad-talk.graphisoft.com/viewtopic.php?printertopic=1&t=50872&start=0&postdays=0&postorder=asc&vote=viewresult&sid=dab5266f1e6f57c7fa2d8c06641f8725
Am I moving in the right direction? Would you happen to have a small example of how to achieve this otherwise?
Thanks again.
Posted: Wed Dec 28, 2016 6:53 pm (GMT+1)
Akos Somorjai wrote: |
Hi, Could you please post the relevant part of your code? That function usually gives that error code when it cannot build up the connection to ARCHICAD from the add-on. The API functions mostly run on the main thread of the application, triggered by some user event, so you cannot really throw API calls randomly at ARCHICAD; this won't work. Is this the case you refer to? If so, then I can recommend two solutions: if you have a palette in ARCHICAD, then enable idle events for that, and call the API from that idle event handler (PanelIdle ()). If you don't have an interface, then use the ACAPI_Command_CallFromEventLoop () mechanism to get what you want. I'm not sure how the handles allocated in the ACAPI_Element_GetMemo work with managed code, though. Regards, Akos |
Hi,
Thanks for the Reply. I guess you describe the Problem correctly. I''ll recap my process:
1- I have registered a Menu command (no Palette)
2- This Menu command calls the managed dll which instantiates a custom WPF Interface (also connecting to other applications)
3- An Event in the WPF is calling the "GetPropertiesSpace" function (below) which uses several API methods.
4- So far I experience issues Only with the ACAPI_Element_GetMemo function.
GetPropertiesSpace:
Code: |
map<string, string> GetPropertiesSpace (API_Guid& guid, map<string, string> searchMap) { API_Element element; API_ElementMemo memo; GSErrCode err; map<string, string> targetMap = map<string, string>(); // GET ELEMENT ------------------------------------------------------------ // BNZeroMemory (&element, sizeof (element)); element.header.typeID = API_ZoneID; element.header.guid = guid; err = ACAPI_Element_Get (&element); // GET GUID //WriteReport ("Room_GUID: %s", APIGuidToString (guid).ToCStr ().Get ()); GS::UniString strguid = APIGuidToString(guid).ToCStr().Get(); if(strguid != "") targetMap["GUID"] = strguid.ToCStr(); // GET MEMO ------------------------------------------------------------ // BNZeroMemory (&memo, sizeof (memo)); if (err == NoError && element.header.hasMemo) { err = ACAPI_Element_GetMemo (element.header.guid, &memo, APIMemoMask_AddPars); //err = ACAPI_Element_GetDefaults (&element, &memo); if (err != NoError) { ErrorBeep ("ACAPI_Element_Get/Memo (zone)", err); } } // GET ELEMENT PARAMETERS -- ROOM if (&memo.params != NULL || *memo.params != NULL) { ... get other params } return targetMap; } |
I have attempted to use the ACAPI_Command_CallFromEventLoop you suggested, with the example in the documentation, but so far with no avail.
When I call the Do_CommandCallFromEventLoop(); from the managed Code I get the same Error on the ACAPI_Command_CallFromEventLoop as with the GetMemo.
I also tried with a sample for the DWG IO Add-On but I get the same Error as before):
Code: |
bool APIHandler::Test () { // API_ModulID mdid = { developerID, localID }; API_ModulID mdid = { 1198731108, 1322668197 }; // DXF/DWG add-on try { GSErrCode err = NoError; GSHandle paramHandle; err = ACAPI_Goodies (APIAny_InitMDCLParameterListID, ¶mHandle, NULL); if (err == NoError) { err = ACAPI_Command_CallFromEventLoop (&mdid, 'GDCO', 1, paramHandle, false, CommandCallBackProc); if (err != NoError) { WriteReport_Err ("ACAPI_Command_CallFromEventLoop failed", err); ACAPI_Goodies (APIAny_FreeMDCLParameterListID, ¶mHandle, NULL); return false; } } else{ return false; } } catch (...) { } return true; } |
I also found a post that was perhaps related: http://archicad-talk.graphisoft.com/viewtopic.php?printertopic=1&t=50872&start=0&postdays=0&postorder=asc&vote=viewresult&sid=dab5266f1e6f57c7fa2d8c06641f8725
Am I moving in the right direction? Would you happen to have a small example of how to achieve this otherwise?
Thanks again.