NX二次开发-设置属性到组件、部件、实例


    NXOpen::Session *theSession = NXOpen::Session::GetSession();
    NXOpen::Part *workPart(theSession->Parts()->Work())

    NXOpen::Part *part1(dynamic_cast<NXOpen::Part *>(NXObjectManager::Get(instanceID)));//部件
    //Open::Assemblies::Component *component1(dynamic_cast<NXOpen::Assemblies::Component *>(NXObjectManager::Get(occ)));//组件
    //NXOpen::NXObject *instance1(dynamic_cast<NXOpen::NXObject *>(NXObjectManager::Get(instanceID)));//实例

    std::vector<NXOpen::NXObject *> objects(1);
    objects[0] = part1;//设置为组件时将此处part换成component1,instance1
    NXOpen::AttributePropertiesBuilder *attributePropertiesBuilder = theSession->AttributeManager()->CreateAttributePropertiesBuilder(workPart, objects, NXOpen::AttributePropertiesBuilder::OperationTypeNone);

    attributePropertiesBuilder->SetTitle(attributeTitle);
    attributePropertiesBuilder->SetStringValue(attributeValue);
    attributePropertiesBuilder->Commit();
    attributePropertiesBuilder->Destroy();


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM