How do i get edit a Property?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-08-18 02:43 PM - edited 2022-08-18 02:44 PM
Dear Graphisoft-Community,
I'm currently trying to build my first C++ AddOn, but I'm struggeling a bit.
I'm trying to set a property for selected elements, but the part where I set doesn't seem to work.
My current code looks/works somewhat like this:
1) I get the selected Elements with ACAPI_Selection_Get
static void getSelectedElements(GS::Array<API_Neig>& selNeigs)
{
GSErrCode err;
API_SelectionInfo selectionInfo;
err = ACAPI_Selection_Get(&selectionInfo, &selNeigs, true);
}
2) Looking for the Property I want to edit (2 Steps)
This method finds the wanted PropertyGroup by its name
{
GS::Array<API_PropertyGroup> propertyGroups;
GSErrCode err{ ACAPI_Property_GetPropertyGroups(propertyGroups) };
std::list<GS::UniString> groups;
if (err == NoError)
for (API_PropertyGroup pg : propertyGroups)
if (pg.name == name)
target = pg;
}
This method above gets used in the following:
{
GSErrCode err;
GS::UniString groupName{ "Identifizierung" };
GS::UniString propertyName{ "Bezeichnung" };
GS::Array <API_PropertyDefinition> propDefs;
API_PropertyGroup propertyGroup;
findPropertyGroupByName(groupName, propertyGroup);
err = ACAPI_Property_GetPropertyDefinitions(propertyGroup.guid, propDefs);
for (API_PropertyDefinition pd : propDefs)
if (pd.name == propertyName)
propertyDefinition = pd;
}
propertyDefintion will then have the information for our user-defined property ["Identifizierung","Bezeichnung"]
With the selected Neigs and the propertyDefinition accuired i wanted to use
to get the property of the Element and edit it
property.value.variantStatus = API_VariantStatusUserUndefined;
property.definition.collectionType = API_PropertySingleCollectionType;
property.definition.valueType = API_PropertyStringValueType;
property.definition.canValueBeEditable = true;
property.value.singleVariant.variant.uniStringValue = GS::ValueToUniString(i);
//i is an int which gets iterated everytime a new neig is selected through for (API_Neig neig : selNeigs), so the first one gets 1, the second 2 and so forth
but after I call
none of the selected Elements have a changed their value of Bezeichnung.
So how can i edit a property of an element? What am i missing?
And on a side note, this my very first AC/C++ AddOn, so if you get any recommendations for my code (readability, performance or general things) those are much appreciated 🙂
Solved! Go to Solution.
- Labels:
-
Add-On (C++)
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-08-31 11:57 AM
For anyone with the same problem as me:
I think I used the wrong method.
I started using ACAPI_ElementList_ModifyPropertyValue() which resulted in change

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-08-20 12:16 AM
Hi Dayiz
You may just need to encapsulate in an 'Undo' session.. this has got me a few times. 😀
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-08-24 04:17 PM
Hello Ben,
Thanks four your help, i tried it out and encapsulated the important bits of the addon:
the method "numberBezeichnung()" then gets called in MenuCommandHandler.
But when i execute the AddOn, no values get changed. To check if my selection works i added the line
DG::InformationAlert(GS::ValueToUniString(selNeigs.GetSize()), "", "Ok");
which returns me after executing the addon the amount of the selected elements, which works.
Any idea why that still happens?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-08-31 11:57 AM
For anyone with the same problem as me:
I think I used the wrong method.
I started using ACAPI_ElementList_ModifyPropertyValue() which resulted in change