Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a plane with offset using Inventor API

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
2470 Views, 9 Replies

Create a plane with offset using Inventor API

Anonymous
Not applicable

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 !

0 Likes

Create a plane with offset using Inventor API

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 !

9 REPLIES 9
Message 2 of 10
Hochenauer
in reply to: Anonymous

Hochenauer
Autodesk
Autodesk
Accepted 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

 



Gerald Hochenauer
Senior Principal Engineer, Inventor
Autodesk, Inc.

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

 



Gerald Hochenauer
Senior Principal Engineer, Inventor
Autodesk, Inc.

Message 3 of 10
Anonymous
in reply to: Hochenauer

Anonymous
Not applicable

Thank you for your answer I hope it will be fixed soon !

0 Likes

Thank you for your answer I hope it will be fixed soon !

Message 4 of 10
ruthsteed
in reply to: Anonymous

ruthsteed
Autodesk
Autodesk

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



Ruth Steed
Inventor Development Team
Autodesk, Inc.

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



Ruth Steed
Inventor Development Team
Autodesk, Inc.

Message 5 of 10
sam
Advocate
in reply to: Hochenauer

sam
Advocate
Advocate
This is still not working in assemblies? Any reason why?

This is still not working in assemblies? Any reason why?
Message 6 of 10
markus_gruebel
in reply to: ruthsteed

markus_gruebel
Participant
Participant

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

0 Likes

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

Message 7 of 10
hariharanhZXJ8L
in reply to: Anonymous

hariharanhZXJ8L
Contributor
Contributor

I am trying to Create Plane using AddByPlaneAndOffset in 2022 version. But I am facing the same !
@Hochenauer  is the Issue Resolved ?

 

Thanks

HARI

0 Likes

I am trying to Create Plane using AddByPlaneAndOffset in 2022 version. But I am facing the same !
@Hochenauer  is the Issue Resolved ?

 

Thanks

HARI

Message 8 of 10
A.Acheson
in reply to: hariharanhZXJ8L

A.Acheson
Mentor
Mentor

There is still no AddByPlaneAndOffset in assembly see object in API help. Follow message 5 vba version. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

There is still no AddByPlaneAndOffset in assembly see object in API help. Follow message 5 vba version. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 9 of 10
hariharanhZXJ8L
in reply to: Anonymous

hariharanhZXJ8L
Contributor
Contributor

@A.Acheson 

do you have any option to create work plane in assembly with reference to Face object ?

0 Likes

@A.Acheson 

do you have any option to create work plane in assembly with reference to Face object ?

Message 10 of 10
A.Acheson
in reply to: hariharanhZXJ8L

A.Acheson
Mentor
Mentor

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.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

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.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report