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