Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
mgigliotti
in reply to: Owner2229

Mike;

 

Thanks for the reply.  After I posted, I dug a little deeper and found some more options in the api and came up with the below.  Same basic approach as you suggested, make the derived part and then underive all but one body in each, and adjust metadata accordingly.  (Again, this represents only the block concerned with creating the derived part.  I have also however attached the entire rule below.  Still need to write the bit to create the new assembly and put all the new parts in it.)

 

'StartCode

     oPartDocFinal = CType(ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , False),PartDocument)
      oFinalCompDef = oPartDocFinal.ComponentDefinition
      oPartDocFinal.UnitsOfMeasure.LengthUnits = UnitsTypeEnum.kInchLengthUnits
      
      oDerivedPrtDef = oFinalCompDef.ReferenceComponents.DerivedPartComponents.CreateDefinition(oPartDoc.FullDocumentName)
      'oDerivedPrtDef.ExcludeAll
      'oDerivedPrtDef.IncludeAllSolids=kDerivedIncludeAll'kDerivedIndividualDefined
      oDerivedPrtDef.IncludeAllParameters=True
      For each oDerivedEntity in oDerivedPrtDef.Solids
       strEName = oDerivedEntity.ReferencedEntity.Name
       msgBox (strEName)
       If strEName <> strBName Then
        oDerivedEntity.IncludeEntity = False
       End If
      Next
      
      'oDerivedPrtDef.Solids.Add(oBody)
      oFinalCompDef.ReferenceComponents.DerivedPartComponents.Add(oDerivedPrtDef)

      For q = 0 to 3
       oTargetParams = oFinalCompDef.Parameters.UserParameters
       oTargetParameter = oTargetParams.AddByValue(aProperties(q),1,UnitsTypeEnum.kInchLengthUnits)
             
       strPExpression = strBName & aPropAbbr(q)
       oTargetParameter.Expression = strPExpression
      Next q
      'oPartDocFinal.ComponentDefinition.Features.NonParametricBaseFeatures.Add(oBody,oMatrix)
     oPartDocFinal.SaveAs(strWorkPath & "\" & "PT_" & strBName & ".ipt", True)

'EndCode.