Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I add select solids to a part using derive in API?

1 REPLY 1
Reply
Message 1 of 2
Anonymous
269 Views, 1 Reply

How do I add select solids to a part using derive in API?

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?

Tags (2)
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

I get this error when attempting the for loop

 

Run time Error 430 Class does not support automation

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report