SDK: How to Add Properties/PropertySets

233 viewsQuestions and Answers
0

Hello,

could someone tell me how to add new Properties/PropertySets to an object?

There is the Function “api.AddOrChangeObjectProperty(def, data);” but I’m unable to use it.

best regards

Alex

crush4 Unselected an answer 29 October 2021
1

Hello,

This code should add property to the selected object. New Property and property set should appear at the bottom of property list.

if (api.GetSelected().Length > 0)

{

string exampleSetName = “New set name”;

string examplePropertyName = “New property name”;

string examplePropertyValue = “65”;

string examplePropertyUnit = “cm”;

PropertyData newData = new PropertyData();

newData.name = examplePropertyName;

newData.value_num = Int32.Parse(examplePropertyValue);

newData.value_type = ValueType.vt_int;

newData.unit = examplePropertyUnit;

PropertyDef newDef = new PropertyDef();

newDef.object_id = api.GetSelected()[0];

newDef.set_name = exampleSetName;

newDef.name = examplePropertyName;

api.AddOrChangeObjectProperty(newDef, newData);

api.Invalidate();

}

Best regards,

BIMvision Team

crush4 Unselected an answer 29 October 2021
You are viewing 1 out of 1 answers, click here to view all answers.