October 19, 2015, 3:38 am
Author:
Ralph Wessel
Posted: Mon Oct 19, 2015 11:38 am (GMT+1)
gehairing wrote: |
I try to modifiy an existing Library part by adding some parameters.
After running this code on a valid library part the library part is no more valid. In the Library Part dialog there are messages indicating that the 2D symbol and 3D symbol are not valid.
Do you have any idea what i am doing wrong ? |
I think you need to include both the new and additional parameters when you make this call:
Code: |
err = ACAPI_LibPart_SetDetails_ParamDef (&libPart, sectionHdl, &details); |
Your existing code will be setting the library part to have only the 3 parameters in sectionHdl.
_________________
Ralph Wessel
Cadimage
↧
October 19, 2015, 3:41 am
Author:
Ralph Wessel
Posted: Mon Oct 19, 2015 11:41 am (GMT+1)
Kinstewar wrote: |
Our client changed a menu of our plugin in the menu customization settings, removed some items probably and he cant see them and also a new ones that come with a new builds.
Is there any API which we can use to restore or detect such situation? |
Sorry, I don't think the API provides any way to manage this situation. I think it's all governed by the work environment settings, and the API can't change them.
_________________
Ralph Wessel
Cadimage
↧
↧
October 19, 2015, 3:53 am
Author:
Ralph Wessel
Posted: Mon Oct 19, 2015 11:53 am (GMT+1)
LesWoolsey wrote: |
Is there any documentation or examples for how to localize an AddOn? I have my English messages etc in a GRC file. The examples sort of lead me to believe that I need a GRC file for each language. But is there a naming convention or is there some way I indicate the language in the GRC file? Do I create a single Add-on or must I create one for each language? It's all very unclear without some sort of guidance. Any suggestions, pointers or examples would help. |
At the moment, the best approach is to make a separate build for every different language (using the relevant GRC files). ARCHICAD and its API don't currently provide a method to bundle all languages in an add-on and switch on demand. You could implement something like that yourself, but I think it's better/simpler to make separate builds.
_________________
Ralph Wessel
Cadimage
↧
October 19, 2015, 4:32 am
Author:
gehairing
Posted: Mon Oct 19, 2015 12:32 pm (GMT+1)
Hello Ralph,
Thank's for your answer.
I don't understand what you mean ![Rolling Eyes]()
(Probably i don't understand how these api calls work togheter)
I "get" a section, create some additional parameters, "update" the section with these added parameters.
↧
October 19, 2015, 5:45 am
Author:
gehairing
Posted: Mon Oct 19, 2015 1:45 pm (GMT+1)
When i use following code i have no problems at all :
Code: |
// Set parameters to the given libPart
void TestSetParameters(const API_LibPart& libPart) { // Add parameters/properties for this object API_LibPartSection section; BNZeroMemory (§ion, sizeof (API_LibPartSection)); section.sectType = API_SectParamDef;
GSHandle sectionHdl = NULL; GSErrCode err = ACAPI_LibPart_GetSection(libPart.index, §ion, §ionHdl, NULL); API_LibPartDetails details; BNZeroMemory (&details, sizeof (API_LibPartDetails)); details.object.autoHotspot = false; err = ACAPI_LibPart_SetDetails_ParamDef (&libPart, sectionHdl, &details); err = ACAPI_LibPart_UpdateSection (libPart.index, §ion, sectionHdl, NULL);
BMKillHandle (§ionHdl); }
|
When is use this code i have the problem :
Code: |
// Set parameters to the given libPart
void TestSetParameters(const API_LibPart& libPart) { // Add parameters/properties for this object API_LibPartSection section; BNZeroMemory (§ion, sizeof (API_LibPartSection)); section.sectType = API_SectParamDef;
GSHandle sectionHdl = NULL; GSErrCode err = ACAPI_LibPart_GetSection(libPart.index, §ion, §ionHdl, NULL);
short nPars = 1; API_AddParType** addPars = reinterpret_cast<API_AddParType**>(BMAllocateHandle (nPars * sizeof (API_AddParType), ALLOCATE_CLEAR, 0)); if (addPars != NULL) { API_AddParType* pAddPar = &(*addPars)[0]; pAddPar->typeID = APIParT_Mater; pAddPar->typeMod = 0; CHTruncate ("mat", pAddPar->name, sizeof (pAddPar->name)); GS::ucscpy (pAddPar->uDescname, L("Tom's testing parameter")); pAddPar->value.real = 1; double aa = 1.0; double bb = 1.0; GSHandle Sect2DHdl = NULL; err = ACAPI_LibPart_GetSect_ParamDef (&libPart, addPars, &aa, &bb, Sect2DHdl, §ionHdl);
BMKillHandle (reinterpret_cast<GSHandle*>(&addPars)); } err = ACAPI_LibPart_UpdateSection (libPart.index, §ion, sectionHdl, NULL);
BMKillHandle (§ionHdl); }
|
This is only testing code based on code i found in the Libpart_test project.
When i create a LibPart i have no problems at all.
I didn't find code samples for modifying existing Libpart.
I forgot to say that i have no error codes returned on any of the above api calls.
↧
↧
October 19, 2015, 6:07 am
Author:
Rinovo
Posted: Mon Oct 19, 2015 2:07 pm (GMT+1)
Hello!
I need to get move/drag operation beg and end coords. Couldn't find a way to get drag event or initialize drag. Any ideas ?
↧
October 19, 2015, 6:25 am
Author:
Ralph Wessel
Posted: Mon Oct 19, 2015 2:25 pm (GMT+1)
gehairing wrote: |
When i use following code i have no problems at all :
[...]
When is use this code i have the problem :
[...]
This is only testing code based on code i found in the Libpart_test project.
When i create a LibPart i have no problems at all.
|
There is a marked difference between your 2 examples. Consider the contents of sectionHdl when you reach this part of the code:
Code: |
err = ACAPI_LibPart_UpdateSection (libPart.index, §ion, sectionHdl, NULL); |
In the first example, sectionHdl contains all the parameters because you retrieved them with ACAPI_LibPart_GetSection. In the second example, sectionHdl will contain only 1 parameter populated from addPars.
The call to ACAPI_LibPart_UpdateSection replaces all the parameters in the object with a new parameter list. I don't think it can be used to just add parameters. What you want to do is:1. Get all the existing parameters in a handle;
2. Add the new parameter to the handle (so the list contains both new and existing parameters);
3. Call ACAPI_LibPart_UpdateSection and pass the list with existing and new parameters in it.
_________________
Ralph Wessel
Cadimage
↧
October 19, 2015, 6:32 am
Author:
Ralph Wessel
Posted: Mon Oct 19, 2015 2:32 pm (GMT+1)
Rinovo wrote: |
Hello!
I need to get move/drag operation beg and end coords. Couldn't find a way to get drag event or initialize drag. Any ideas ? |
There are example add-ons bundled with the API to illustrate the use of many calls. For drag-drop operations, I suggest looking at Navigator_Test and searching for DGDragDropMsgData. You should find all the details your looking for in that data structure.
_________________
Ralph Wessel
Cadimage
↧
October 19, 2015, 6:41 am
Author:
Rinovo
Posted: Mon Oct 19, 2015 2:41 pm (GMT+1)
Thanks Ralph!
Will look into.
↧
↧
October 19, 2015, 6:45 am
Author:
gehairing
Posted: Mon Oct 19, 2015 2:45 pm (GMT+1)
Thanks for your reply.
I thought getting the current section with GetSection and adding the new data with GetSect_ParamDef would update the section with the new data. That's what i understand after reading the API doc. But my english is not so good so i probably misunterstood this.
Do you have an idea how i can :
- Get actual parameters,
- Add a few new ones,
- Set all back again.
↧
October 19, 2015, 7:23 am
Author:
Ralph Wessel
Posted: Mon Oct 19, 2015 3:23 pm (GMT+1)
gehairing wrote: |
Thanks for your reply.
I thought getting the current section with GetSection and adding the new data with GetSect_ParamDef would update the section with the new data. That's what i understand after reading the API doc. But my english is not so good so i probably misunterstood this.
Do you have an idea how i can :
- Get actual parameters,
- Add a few new ones,
- Set all back again. |
The code you've written is almost right. Try getting the existing parameters with ACAPI_LibPart_GetParams and then append the new parameters in addPars. You might be able to use BMHandleAndHandle, but that depends on whether the result from ACAPI_LibPart_GetParams is an ordinary handle. The documentation advises disposing of it with ACAPI_DisposeAddParHdl, which suggests it's not an ordinary GSHandle. The safest is probably to allocate a handle large enough to accommodate the new and old parameters and populating that.
_________________
Ralph Wessel
Cadimage
↧
October 19, 2015, 7:36 am
Author:
gehairing
Posted: Mon Oct 19, 2015 3:36 pm (GMT+1)
Thanks Ralph. I'll try to find how to do what you've explained.
After my previous message i have tried following :
Creating a "dump" code :
(completely based on sample code i found in the API doc)
Code: |
static void DumpParameters (Int32 libInd, API_LibTypeID typeID) { API_LibPartDetails details; double a, b; Int32 addParNum, i, ind, i1, i2; API_AddParType **addPars; double value; char *valueStr; GSErrCode err;
err = ACAPI_LibPart_GetParams (libInd, &a, &b, &addParNum, &addPars); if (err) return;
for (i = 0; i < addParNum; i++) { if ((*addPars)[i].typeMod == API_ParSimple) { ACAPI_WriteReport ((*addPars)[i].name, false); } else { ind = 0; ACAPI_WriteReport ((*addPars)[i].name, false); for (i1 = 1; i1 <= (*addPars)[i].dim1; i1++) { for (i2 = 1; i2 <= (*addPars)[i].dim2; i2++) { if ((*addPars)[i].typeID != APIParT_CString) { value = (Int32) ((double *) *(*addPars)[i].value.array) [ind]; valueStr = NULL; ind ++; } else { value = 0.0; valueStr = *(*addPars)[i].value.array + ind; ind += strlen (valueStr) + 1; } ACAPI_WriteReport (valueStr, false); } } } } ACAPI_DisposeAddParHdl (&addPars); } |
Called this method to dump all parameters before my code :
Code: |
A
B
ZZYZX
AC_show2DHotspotsIn3D
ac_bottomlevel
ac_toplevel
showerType
services
matFinish
SKU
gs_2D_representation
gs_cont_pen
gs_fill_type
gs_fill_pen
gs_back_pen
gs_list
gs_list_cost
gs_list_manufacturer
gs_list_note
gs_list_location
gs_list_accessories
FM_Type
iFMType
FM_InventoryNumber
FM_SerialNumber
FM_ProductionYear
FM_ObjectWeight
FM_ObjectWeightUnit
gs_list_custom1
gs_list_custom2
gs_list_custom3
gs_list_custom4
gs_list_custom5
gs_3D_representation
gs_detlevel_3D
gs_shadow
doorOpen |
Then i run this code (the same as in my previous message) to "add" a parameter :
Code: |
// Set parameters to the given libPart
void TestSetParameters(const API_LibPart& libPart) { // Add parameters/properties for this object API_LibPartSection section; BNZeroMemory (§ion, sizeof (API_LibPartSection)); section.sectType = API_SectParamDef;
GSHandle sectionHdl = NULL; GSErrCode err = ACAPI_LibPart_GetSection(libPart.index, §ion, §ionHdl, NULL);
short nPars = 1; API_AddParType** addPars = reinterpret_cast<API_AddParType**>(BMAllocateHandle (nPars * sizeof (API_AddParType), ALLOCATE_CLEAR, 0)); if (addPars != NULL) { API_AddParType* pAddPar = &(*addPars)[0]; pAddPar->typeID = APIParT_Mater; pAddPar->typeMod = 0; CHTruncate ("mat", pAddPar->name, sizeof (pAddPar->name)); GS::ucscpy (pAddPar->uDescname, L("Tom's testing parameter")); pAddPar->value.real = 1; double aa = 1.0; double bb = 1.0; GSHandle Sect2DHdl = NULL; err = ACAPI_LibPart_GetSect_ParamDef (&libPart, addPars, &aa, &bb, Sect2DHdl, §ionHdl);
BMKillHandle (reinterpret_cast<GSHandle*>(&addPars)); } err = ACAPI_LibPart_UpdateSection (libPart.index, §ion, sectionHdl, NULL);
BMKillHandle (§ionHdl); }
|
Then run the dump code again :
Code: |
A
B
ZZYZX
AC_show2DHotspotsIn3D
ac_bottomlevel
ac_toplevel
gs_2D_representation
gs_cont_pen
gs_fill_type
gs_fill_pen
gs_back_pen
gs_list
gs_list_cost
gs_list_manufacturer
gs_list_note
gs_list_location
gs_list_accessories
FM_Type
iFMType
FM_InventoryNumber
FM_SerialNumber
FM_ProductionYear
FM_ObjectWeight
FM_ObjectWeightUnit
gs_list_custom1
gs_list_custom2
gs_list_custom3
gs_list_custom4
gs_list_custom5
mat |
"mat" is the one i "added".
So It seem's to me that i have lost (or destroyed or whatever
)some parameters but not all.
↧
October 19, 2015, 7:46 am
Author:
Ralph Wessel
Posted: Mon Oct 19, 2015 3:46 pm (GMT+1)
gehairing wrote: |
Thanks Ralph. I'll try to find how to do what you've explained.
After my previous message i have tried following :
Creating a "dump" code :
(completely based on sample code i found in the API doc)
[...] "mat" is the one i "added".
So It seem's to me that i have lost (or destroyed or whatever )some parameters but not all. |
I suspect that all the parameters before 'mat' are required for the object subtype, so ARCHICAD automatically injects them. So your original list is destroyed and replaced with the subtype parameters and the 1 you added.
_________________
Ralph Wessel
Cadimage
↧
↧
October 19, 2015, 8:49 am
Author:
gehairing
Posted: Mon Oct 19, 2015 4:49 pm (GMT+1)
I have found out how to manage that.
Thank you Ralph for guiding me. ![Smile]()
Here is some testing code that works, hope it can help someone one day.
Now i have to do the real clean code...
Code: |
static void AddParameterTest (const API_LibPart& libPart) { GSErrCode err;
API_LibPartSection section; BNZeroMemory (§ion, sizeof (API_LibPartSection)); section.sectType = API_SectParamDef;
GSHandle sectionHdl = NULL; err = ACAPI_LibPart_GetSection(libPart.index, §ion, §ionHdl, NULL); if (err) return;
double a, b; Int32 addParNum, i; API_AddParType **addPars; err = ACAPI_LibPart_GetParams (libPart.index, &a, &b, &addParNum, &addPars); if (err) return;
// Create enough space for all parameters Int32 myParameterCount = 1; short nPars = addParNum + myParameterCount; API_AddParType** newAddPars = reinterpret_cast<API_AddParType**>(BMAllocateHandle (nPars * sizeof (API_AddParType), ALLOCATE_CLEAR, 0)); if (addPars != NULL) { // Copy all parameters for (i = 0; i < addParNum; i++) { (*newAddPars)[i] = (*addPars)[i]; }
// Add our new parameter API_AddParType* pAddPar = &(*newAddPars)[nPars-1]; pAddPar->typeID = APIParT_Mater; pAddPar->typeMod = 0; CHTruncate ("mat", pAddPar->name, sizeof (pAddPar->name)); GS::ucscpy (pAddPar->uDescname, L("Tom's testing parameter")); pAddPar->value.real = 1; // Build a section handle with all parameters GSHandle Sect2DHdl = NULL; err = ACAPI_LibPart_GetSect_ParamDef (&libPart, newAddPars, &a, &b, NULL, §ionHdl);
BMKillHandle (reinterpret_cast<GSHandle*>(&newAddPars)); }
// Update our section... err = ACAPI_LibPart_UpdateSection (libPart.index, §ion, sectionHdl, NULL); BMKillHandle (§ionHdl);
ACAPI_DisposeAddParHdl (&addPars); }
|
↧
October 19, 2015, 11:52 pm
Author:
Rinovo
Posted: Tue Oct 20, 2015 7:52 am (GMT+1)
In navigator_test i can get drag operation in list view, didn't found what could suit me. I need to get move/drag operation when moving object and retrieve beg and end coords.
ACAPI_Notify_GetTranParams could be the one, but ..
Code: |
*The transformation data is valid only between a APINotifyElement_BeginEvents and the following APINotifyElement_EndEvents notification. |
..i don't know how to get these events.
EDIT: Hmmm... i might have found a way, will set up for a try.
↧
October 20, 2015, 1:35 am
Author:
Ralph Wessel
Posted: Tue Oct 20, 2015 9:35 am (GMT+1)
Rinovo wrote: |
ACAPI_Notify_GetTranParams could be the one, but ..
Code: | *The transformation data is valid only between a APINotifyElement_BeginEvents and the following APINotifyElement_EndEvents notification. |
..i don't know how to get these events. . |
Sorry, I misunderstood your question –
I thought you meant drag-drop in the UI, e.g. list items. What you really want to do is track moving elements.
In order to get events for an element moving, you need to instruct ARCHICAD to notify you by calling ACAPI_Notify_InstallElementObserver. You also need to identify which elements should trigger a notification with ACAPI_Element_AttachObserver.
_________________
Ralph Wessel
Cadimage
↧
October 22, 2015, 12:23 am
Author:
MarkHenryC
Posted: Thu Oct 22, 2015 8:23 am (GMT+1)
To reproduce:
1. Create a wall
2. Create a new wall that intersects the first (or just drag another wall in)
3. Move the original wall away from the area of intersection
ArchiCAD apparently triggers a boolean operation, subtracting from the new intersecting shape. But when you move the other shape away it exposes the cut but doesn't raise a notification. The only notification is on the shape you've moved.
ArchiCAD manages it OK. The wall is restored in the 3D view. And if you force a notification on the modified wall - such as by opening Selection Settings and clicking OK, the correct geometry is available. But the AddOn doesn't get notified even though the geometry has changed.
↧
↧
October 22, 2015, 12:26 am
Author:
MarkHenryC
Posted: Thu Oct 22, 2015 8:26 am (GMT+1)
Settings > More Sun > Project Location > change North direction in compass gadget and close with OK, OK, OK.
No notification is sent. But if you open Settings again and just click OK, a notification is sent.
↧
October 22, 2015, 1:36 am
Author:
Rinovo
Posted: Thu Oct 22, 2015 9:36 am (GMT+1)
Thanks Ralph!
Got it working.
If i could initiate move/drag operation in project would be even better, but i guess there isn't structure for that.
↧
October 23, 2015, 3:44 am
Author:
stefan
Posted: Fri Oct 23, 2015 11:44 am (GMT+1)
When you collect the quantities of composite layers from Walls, using ACAPI_Element_GetSurfaceQuantities you can get the Projected Area/Exposed Surface from the API.
However, I noticed that if you have a project where the option "Use Legacy intersection and Surface methods for model elements" is enabled for your project, the exposed surface stays ZERO.
Is this a bug? Or a limitation? I did not read it in the documentation.
_________________
--- stefan boeykens --- architect-engineer-musician ---
ArchiCAD18-19/Revit2016/SketchUp2015/Cinema4D16/Rhino5/Unity5
rMBP15:i7Quad2.3Ghz+16GB+nVidia650M/ElCapitan+Win10
http://bit.ly/17u87df
↧