NX二次开发源码分享:报告当前工作部件的所有属性
NX二次开发源码分享:报告当前工作部件的所有属性
主要是用过workPart->GetUserAttributes()获取属性信息;
void MyClass::do_it()
{
stringstream out;
std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
out.str(""); out.clear();
out << "\nAttributes found: " << infos.size() << endl;
print(out.str().c_str());
for (unsigned int ii=0; ii<infos.size(); ii++)
{
out.str(""); out.clear();
out << "\nAttribute: " << infos.Title.GetText() << endl;
out << " Array: " << infos.Array << endl;
if( infos.Category.GetText() )
out << " Category: " << infos.Category.GetText() << endl;
else
out << " Category: NULL"<< endl;
out << " Inherited: " << infos.Inherited << endl;
out << " Locked: " << infos.Locked << endl;
out << " OwnedBySystem: " << infos.OwnedBySystem << endl;
out << " PdmBased: " << infos.PdmBased << endl;
out << " Required: " << infos.Required << endl;
out << " Type: " << infos.Type << endl;
out << " Unset: " << infos.Unset << endl;
switch ( infos.Type )
{
case NXObject::AttributeTypeInvalid:
out << " Type is invalid." << endl;
break;
case NXObject::AttributeTypeBoolean:
out << " BooleanValue: " << infos.BooleanValue << endl;
break;
case NXObject::AttributeTypeInteger:
out << " IntegerValue: " << infos.IntegerValue << endl;
break;
case NXObject::AttributeTypeReal:
out << "RealValue: " << infos.RealValue << endl;
break;
case NXObject::AttributeTypeString:
out << " StringValue: " << infos.StringValue.GetText() << endl;
break;
case NXObject::AttributeTypeTime:
out << " TimeValue: " << infos.TimeValue.GetText() << endl;
break;
}
print(out.str().c_str());
}
}
有用的,解决
页:
[1]