C++
Session *theSession = Session::GetSession();
Part *workPart(theSession->Parts()->Work());
Part *displayPart(theSession->Parts()->Display());
//NXOpen对当前工作部件加属性
std::vector<NXObject *> objects1(1);
objects1[0] = workPart;
AttributePropertiesBuilder *attributePropertiesBuilder1;
attributePropertiesBuilder1 = theSession->AttributeManager()->CreateAttributePropertiesBuilder(workPart,
objects1, AttributePropertiesBuilder::OperationTypeNone);
attributePropertiesBuilder1->SetTitle("PartNo");//创建属性标题
attributePropertiesBuilder1->SetStringValue("1-001");//创建字符属性内容
NXObject *nXObject1;
nXObject1 = attributePropertiesBuilder1->Commit();//创建第一个属性
attributePropertiesBuilder1->SetTitle("PartName");//创建属性标题
attributePropertiesBuilder1->SetStringValue("后模仁");//创建字符属性内容
NXObject *nXObject2;
nXObject2 = attributePropertiesBuilder1->Commit();//创建第二个属性
attributePropertiesBuilder1->Destroy();//释放attributePropertiesBuilder1