Community
Public Sub AddDerivedSolids(coSource As ComponentOccurrence, coAdd2 As ComponentOccurrence) Dim pdSource As PartDocument Set pdSource = coSource.Definition.Document Dim pdAdd2 As PartDocument Set pdAdd2 = coAdd2.Definition.Document ' Create a derived definition for the solids to be added. Dim oDerivedPartDef As DerivedPartUniformScaleDef Set oDerivedPartDef = pdAdd2.ComponentDefinition.ReferenceComponents. _ DerivedPartComponents.CreateUniformScaleDef(pdSource.FullFileName) oDerivedPartDef.DeriveStyle = kDeriveAsMultipleBodies oDerivedPartDef.IncludeAllSolids = kDerivedIndividualDefined ' Create the derived part. Call pdAdd2.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Add(oDerivedPartDef) Dim oDerPartComp As DerivedPartComponent Set oDerPartComp = pdAdd2.ComponentDefinition.ReferenceComponents.DerivedPartComponents(1) Dim dpesEntities As DerivedPartEntities Dim dpeEntity As DerivedPartEntity For Each dpeEntity In oDerivedPartDef.Solids If (dpeEntity.ReferencedEntity.Name = "Int" Or dpeEntity.ReferencedEntity.Name = "Caut") Then dpeEntity.IncludeEntity = True End If Next Set oDerPartComp.Definition = oDerivedPartDef End Sub
I get errors when I try to do the for loop. I only want 2 solids from the part added to the newly derived part. I have found some ways of doing this after the derive was created (and failed to get the code to work) but nothing for setting up the definition before. How do I do this?