Inventor API: Change the mirrored state of a derived part

by Vladimir Ananyev

Q: I need to change a derived part from "not mirrored" to "mirrored". Is there an example showing how to do this?

A: Here is a VBA example that mirrors a derived part.

Sub testMirrorDerivedPart()

  Dim oPartDoc As Document

  Set oPartDoc = ThisApplication.ActiveDocument

  If oPartDoc.DocumentType <> kPartDocumentObject Then Exit Sub

 

  Dim oRefComps As ReferenceComponents

  Set oRefComps = oPartDoc.ComponentDefinition.ReferenceComponents

 

  Dim oDerPartC As DerivedPartComponent

  Set oDerPartC = oRefComps.DerivedPartComponents(1)

 

  Dim oDerPartDef As DerivedPartDefinition

  Set oDerPartDef = oDerPartC.Definition

 

  If (TypeOf oDerPartDef Is DerivedPartUniformScaleDef) Then

      Dim oDerPartUScaleDef As DerivedPartUniformScaleDef

    Set oDerPartUScaleDef = oDerPartDef

  

    If (oDerPartUScaleDef.MirrorPlane = kDerivedPartNoMirrorPlane) Then

      Debug.Print "not mirrored – mirroring now"

      oDerPartUScaleDef.MirrorP
lane = kDerivedPartMirrorPlaneXY

      oDerPartC.Definition = oDerPartUScaleDef

    Else

      Debug.Print "mirrored un-mirrowing now"

      oDerPartUScaleDef.MirrorPlane = kDerivedPartNoMirrorPlane

      oDerPartC.Definition = oDerPartUScaleDef

    End If

  End If

  

<

p style=”line-height: 12pt;margin: 0cm 0cm 0pt;background: #e5e5e5″ class=”MsoNormal”>End Sub


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading