Issue
I need to create a work plane in the Assembly document. I have tried using AddByPlaneAndOffset and other methods however an error occurs. Is there a way to add a work plane programmatically to the assembly document?
The only add method that is supported for work features in the assembly document is the AddFixed (this is true for all work feature types). The resulting work plane will return an AssemblyWorkPlaneDef definition. Work plane position can be changed by assembly constraints. We do not currently support (and there are currently no plans to support) the other methods in assembly.
This VBA example creates a work plane on the same plane as the YZ plane in the second part placed in the assembly.
Public Sub AddWorkPlaneInAssembly()
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = oAsmDoc.ComponentDefinition
Dim oOcc As ComponentOccurrence
Set oOcc = oAsmCompDef.Occurrences(2)
Dim oPartDef As PartComponentDefinition
Set oPartDef = oOcc.Definition
Dim oWrkPlane1 As WorkPlane
Set oWrkPlane1 = oPartDef.WorkPlanes(1)
Dim oWrkPlane1Proxy As WorkPlaneProxy
Call oOcc.CreateGeometryProxy( _
oWrkPlane1, oWrkPlane1Proxy)
Dim oOriginPnt As Point
Dim oXaxis As UnitVector
Dim oYaxis As UnitVector
Call oWrkPlane1Proxy.GetPosition( _
oOriginPnt, oXaxis, oYaxis)
Dim oWrkPlane As WorkPlane
Set oWrkPlane = oAsmCompDef.WorkPlanes _
.AddFixed(oOriginPnt, oXaxis, oYaxis)
End Sub
VB .NET:
Public Sub AddWorkPlaneInAssembly()
Dim oAsmDoc As AssemblyDocument _
= m_inventorApp.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition _
= oAsmDoc.ComponentDefinition
Dim oOcc As ComponentOccurrence _
= oAsmCompDef.Occurrences(2)
Dim oPartDef As PartComponentDefinition _
= oOcc.Definition
Dim oWrkPlane1 As WorkPlane _
= oPartDef.WorkPlanes(1)
Dim oWrkPlane1Proxy As WorkPlaneProxy = Nothing
Call oOcc.CreateGeometryProxy( _
oWrkPlane1, oWrkPlane1Proxy)
Dim oOriginPnt As Inventor.Point = Nothing
Dim oXaxis As UnitVector = Nothing
Dim oYaxis As UnitVector = Nothing
Call oWrkPlane1Proxy.GetPosition( _
oOriginPnt, oXaxis, oYaxis)
Dim oWrkPlane As WorkPlane _
= oAsmCompDef.WorkPlanes.AddFixed _
(oOriginPnt, oXaxis, oYaxis)
End Sub