Enable/Disable Section Standard Part Setting in Inventor API

By Barbara Han

Issue
By default the standard parts are not sectioned  and the regular parts are sectioned in a section drawing view. How can I change this setting through UI and API? 

Solution
Through UI:

In Inventor 2013, "Tools" -> "Application Settings" –> "Drawing" –>  "Section Standard Part”, there are three options available in the drop down list:

  1. Obey Brower Setting
  2. Never
  3. Always

Through API:

VBA sample code:

Public Sub SetPartSectioning()         Thisapplication.DrawingOptions.StandardPartsSectionBehavior=kAlwaysSectionStandardParts

End Sub

VB.NET version:

Public Sub SetPartSectioning()

  Dim m_inventorApp As Inventor.Application = Nothing

 

  ‘ Try to get an active instance of Inventor

  Try

    m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")

  Catch ex As Exception

  End Try

 

  ‘ If not active, create a new Inventor session

  If m_inventorApp Is Nothing Then

 

    Dim inventorAppType As Type = System.Type.GetTypeFromProgID("Inventor.Application")

    m_inventorApp = System.Activator.CreateInstance(inventorAppType)

  End If

  m_inventorApp.DrawingOptions.StandardPartsSectionBehavior =

    StandardPartsSectionBehaviorEnum.kAlwaysSectionStandardParts

End Sub

Note: If the sectioned view of the Part/Assembly is already created in a drawing document, it is impossible to get the sectioned view
updated. You will have to re-create every sectioned view in order to take in consideration the new settings.


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading