Hello,
I'd like to create a new plane parallel to the XY plane with an offset of 35 mm in an assembly using Inventor API. I'm not yet familiar with VBA but I'm learning step by step.
I have searched on internet and I have found some code but none of them works. From what I've seen I guess it's something like that:
Sub createWP()
Dim oAssDoc As AssemblyDocument Set oAssDoc = ThisApplication.ActiveDocument Dim oAssCD As AssemblyComponentDefinition Set oAssCD = oAssDoc.ComponentDefinition Dim oWPlane as WorkPlane Set oWPlane = oAssCD.WorkPlanes.AddByPlaneAndOffset(oAssCD.WorkPlanes.Item("XY Plane"), 35) End Sub
Thank you in advance for you help !
Solved! Go to Solution.
Hello,
I'd like to create a new plane parallel to the XY plane with an offset of 35 mm in an assembly using Inventor API. I'm not yet familiar with VBA but I'm learning step by step.
I have searched on internet and I have found some code but none of them works. From what I've seen I guess it's something like that:
Sub createWP()
Dim oAssDoc As AssemblyDocument Set oAssDoc = ThisApplication.ActiveDocument Dim oAssCD As AssemblyComponentDefinition Set oAssCD = oAssDoc.ComponentDefinition Dim oWPlane as WorkPlane Set oWPlane = oAssCD.WorkPlanes.AddByPlaneAndOffset(oAssCD.WorkPlanes.Item("XY Plane"), 35) End Sub
Thank you in advance for you help !
Solved! Go to Solution.
Solved by Hochenauer. Go to Solution.
Hi,
I debugged the code behind the API and found that the current AddByPlaneAndOffset works for part documents only. I am logging a defect to get this working for assemblies as well - sorry for the inconvenience!
Kind regards,
Gerald
Hi,
I debugged the code behind the API and found that the current AddByPlaneAndOffset works for part documents only. I am logging a defect to get this working for assemblies as well - sorry for the inconvenience!
Kind regards,
Gerald
Thank you for your answer I hope it will be fixed soon !
Thank you for your answer I hope it will be fixed soon !
Hi,
When you create an offset workplane in an assembly from the UI, what really happens is a workplane is created and an offset constraint is applied. You can do the same thing through the API, but you have to do the steps yourself. Here is a sample that does what you want:
Public Sub AddWorkPlaneInAssembly()
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Dim oAssCD As AssemblyComponentDefinition
Set oAssCD = oAsmDoc.ComponentDefinition
Dim oWrkPlane1 As WorkPlane
Set oWrkPlane1 = oAssCD.WorkPlanes.Item("XY Plane")
Dim oOriginPnt As Point
Dim oXaxis As UnitVector
Dim oYaxis As UnitVector
Set oOriginPnt = ThisApplication.TransientGeometry.CreatePoint(0#, 0#, 0#)
Set oXaxis = ThisApplication.TransientGeometry.CreateUnitVector(1#, 0#, 0#)
Set oYaxis = ThisApplication.TransientGeometry.CreateUnitVector(0#, 1#, 0#)
Dim oWrkPlane As WorkPlane
Set oWrkPlane = oAssCD.WorkPlanes.AddFixed(oOriginPnt, oXaxis, oYaxis) ' create the workplane
oWrkPlane.AutoResize = True ' To make it easier to see
oAssCD.Constraints.AddFlushConstraint oWrkPlane, oWrkPlane1, 35 ' constrain it to the XY plane
End Sub
Hope this helps.
Regards,
Ruth
Hi,
When you create an offset workplane in an assembly from the UI, what really happens is a workplane is created and an offset constraint is applied. You can do the same thing through the API, but you have to do the steps yourself. Here is a sample that does what you want:
Public Sub AddWorkPlaneInAssembly()
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Dim oAssCD As AssemblyComponentDefinition
Set oAssCD = oAsmDoc.ComponentDefinition
Dim oWrkPlane1 As WorkPlane
Set oWrkPlane1 = oAssCD.WorkPlanes.Item("XY Plane")
Dim oOriginPnt As Point
Dim oXaxis As UnitVector
Dim oYaxis As UnitVector
Set oOriginPnt = ThisApplication.TransientGeometry.CreatePoint(0#, 0#, 0#)
Set oXaxis = ThisApplication.TransientGeometry.CreateUnitVector(1#, 0#, 0#)
Set oYaxis = ThisApplication.TransientGeometry.CreateUnitVector(0#, 1#, 0#)
Dim oWrkPlane As WorkPlane
Set oWrkPlane = oAssCD.WorkPlanes.AddFixed(oOriginPnt, oXaxis, oYaxis) ' create the workplane
oWrkPlane.AutoResize = True ' To make it easier to see
oAssCD.Constraints.AddFlushConstraint oWrkPlane, oWrkPlane1, 35 ' constrain it to the XY plane
End Sub
Hope this helps.
Regards,
Ruth
Hi!
I am trying to learn how to create my own VBA-Projects for Inventor.
Is there a source for all these functions , like creating a plane with an offset?
i have many ideas for macros, but i just have no idea where to look this up.
Greetings,
Markus
Hi!
I am trying to learn how to create my own VBA-Projects for Inventor.
Is there a source for all these functions , like creating a plane with an offset?
i have many ideas for macros, but i just have no idea where to look this up.
Greetings,
Markus
I am trying to Create Plane using AddByPlaneAndOffset in 2022 version. But I am facing the same !
@Hochenauer is the Issue Resolved ?
Thanks
HARI
I am trying to Create Plane using AddByPlaneAndOffset in 2022 version. But I am facing the same !
@Hochenauer is the Issue Resolved ?
Thanks
HARI
There is still no AddByPlaneAndOffset in assembly see object in API help. Follow message 5 vba version.
There is still no AddByPlaneAndOffset in assembly see object in API help. Follow message 5 vba version.
do you have any option to create work plane in assembly with reference to Face object ?
do you have any option to create work plane in assembly with reference to Face object ?
From memory I think you can get a point on the face, use that point to create a fixed workplane about the face then constrain it afterwards.
From memory I think you can get a point on the face, use that point to create a fixed workplane about the face then constrain it afterwards.
Can't find what you're looking for? Ask the community or share your knowledge.