BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

Archicad C++ API
About Archicad add-on development using the C++ API.

Modify attributes of my own object

Anonymous
Not applicable
Hi developers,

I've drawn a new object from my API. Imagine i have defined a new attribute(i.e. angle axe x rotation = inc(in the example picture)) and i would like to modify the field from my API and automatically change this paremeter in the object i have alredy drawn.

Nowadays, i know there is an archiCAD structure where i can modify some object attributes but i can't access to the new ones('inc' in my case). This structure is:

element.objetct.x where 'x' is the attribute to modify.

I'm in a good way? I'm looking for something like element.object.inc. How can i access to this attribute?

THANKS,

Alex


Sin título.png

9 REPLIES 9
Ralph Wessel
Mentor
frankito5 wrote:
i would like to modify the field from my API and automatically change this paremeter in the object i have alredy drawn.
Take a look at the documentation for APIAny_OpenParametersID. It includes sample code for modifying a parameter. Although the defaults are changed in this example, the same applies to an object instance.
Ralph Wessel BArch
Anonymous
Not applicable
I've tried but unsuccessfully:

BNZeroMemory (&paramOwner, sizeof (API_ParamOwnerType));
paramOwner.libInd = 0;
paramOwner.typeID = API_ObjectID;
paramOwner.index = 0;

I suposse libInd and index are 0 due to a default element is defined. In my case, should I change the value? I don't think so because the manual says we have to set it to zero.

BNZeroMemory (&getParams, sizeof (API_ GetParamsType));

err = ACAPI_Goodies (APIAny_OpenParametersID, &paramOwner, NULL);

if (err == NoError) {
BNZeroMemory (&chgParam, sizeof (API_ChangeParamType));
err = ACAPI_Goodies (APIAny_GetActParametersID, &getParams, NULL);

if (err == NoError) {
chgParam.index = 0;
CHCopyC("inc",chgParam.name);
chgParam.realValue = 35.0;
err = ACAPI_Goodies (APIAny_ChangeAParameterID, &chgParam, NULL);

Here, the index should be 0 again? I'm not pretty sure...

if (err == NoError)
err = ACAPI_Goodies (APIAny_GetActParametersID, &chgParam, NULL);
}
err = ACAPI_Goodies (APIAny_CloseParametersID, NULL, NULL);
}

ACAPI_DisposeAddParHdl (&getParams.params);
err = ACAPI_Element_Create (&element, &memo);
ACAPI_DisposeElemMemoHdls(&memo);


I have alredy checked all the calls which modify a parameter return the correct expected value so, there is something wrong. I don't know exactly how the system recognizes my object and if it is looking for the parameter i'm trying to modify in the correct library and so on, but when i draw my object from the API, the field 'inc' is still the previous value.
Ralph Wessel
Mentor
frankito5 wrote:
I have alredy checked all the calls which modify a parameter return the correct expected value so, there is something wrong. I don't know exactly how the system recognizes my object and if it is looking for the parameter i'm trying to modify in the correct library and so on, but when i draw my object from the API, the field 'inc' is still the previous value.
I may have misunderstood your question - do you want to change a parameter in a library part (the file that defines the object) or a parameter of an instance of that object placed in the floor plan?
Ralph Wessel BArch
Anonymous
Not applicable
I may have misunderstood your question - do you want to change a parameter in a library part (the file that defines the object) or a parameter of an instance of that object placed in the floor plan?
I think is the second one. I have created a GDL object and i draw it from an API. In this API i have a dialog where u can set the inclination of this object. When i designed this object i gave it 0º inclination, but what i want is to modify this inclination from the API and draw it directly with the inclination alredy modified. Do you know what i mean? Thank you for your patience.

Alex
Ralph Wessel
Mentor
frankito5 wrote:
what i want is to modify this inclination from the API and draw it directly with the inclination alredy modified.
Wouldn't it be the same if you did this in 2 consecutive steps?
  • 1. Place the object in the floor plan at 0 degrees.

    2. Open the parameter list for the placed object and modify the inclination parameter as required
Ralph Wessel BArch
Anonymous
Not applicable
What i want is give the inclination from my API, and when i draw my own object(also from my API), draw the object with this inclination alredy set. I will show you in images to be clearer.

In first picture u can see the line ROTx inc, where inc is the inclination in the x axe. If i draw this object this parameter is 0º(as you can see in the picture 2). So, what i want is open my API, give a value in an Edit Box and set the new inclination. Next time i draw the object, i want the parameter inc has automatically 45º value(i.e) instead of 0º, without select the object and change the value manually.


I tried how i showed u few many posts before, and i don't know why the system don't change this parameter inc...
Anonymous
Not applicable
Task alredy done succesfully! I just modify and change the value in a different function and that's all. I hope this post helps somebody else.

Thank you Ralph.
Anonymous
Not applicable
It would be nice if you wrote what did you mean by "in a different function" What is that function?

I am fighting with the same problem: I placed the object in the floor, as Ralph suggested, and then tried to change the element's parameter "A" using the above example from the API documentation.
I only changed these paramOwner's members to the corresponding ones of my element:

paramOwner.libInd = libPart.index;
paramOwner.guid   = element.header.guid;
I got error -2130313112 here:

error = ACAPI_Goodies (APIAny_ChangeAParameterID, &chgParam, nullptr);
what could be wrong with my parameter?

chgParam.index = 0;
CHCopyC ("А", chgParam.name);
chgParam.realValue = 77.0;
Anonymous
Not applicable
For the next who will face the same problem - if you want to change the parameters of a placed element, do not use ACAPI_Element_ChangeDefaults, use ACAPI_Element_ChangeParameters instead:

elemHead = (API_Elem_Head **) BMAllocateHandle (sizeof (API_Elem_Head), ALLOCATE_CLEAR, 0);
(*elemHead)[0].typeID = API_ObjectID;
(*elemHead)[0].guid   = guid;
ACAPI_Element_ChangeParameters (elemHead, 1, &element, &memo, &mask);
Learn and get certified!