By Barbara Han
First of all, you may want to know what command in API world is for “Half Section View” command in UI. You can get all commands’ information using below several lines of VBA code:
Sub printCmdInfo()
Dim oControlDef As ControlDefinition
Open "c:\1.txt" For Output As #1
Dim s As String
For Each oControlDef In ThisApplication.CommandManager. _
ControlDefinitions
s = oControlDef.InternalName & ":" & _
oControlDef.DescriptionText
Write #1, s
Next
Close #1
End Sub
Open the C:\1.txt file created by above code, you can find the name for the Half Section View command in Assembly environment is “AssemblyHalfSectionViewCmd”.
If you have a plane selected before running above line, there will be no user interaction needed when you executing above line. If this is not the case, you can select a work plane via API too, for example:
Dim assm As AssemblyDocument
Set assm = ThisApplication.ActiveDocument
ThisApplication.ActiveDocument.SelectSet.Select assm.ComponentDefinition.WorkPlanes.Item(4)
Then you can call this command programmatically like this:
ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyHalfSectionViewCmd").Execute
The Offset dialog will pop up after calling above line of code, you can set a value in the Offset dialog then exit it by SendKeys method, for example:
SendKeys "0.02"
SendKeys "{ENTER}"

Leave a Reply to Klaas De SmedtCancel reply