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 Work Axis in Assembly

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
2517 Views, 4 Replies

Create Work Axis in Assembly

I am writing code that inserts a part from the content center, then patterns it along the x-axis and along a custom work axis that I need to define in iLogic.  I've read through the help files and the single forum post I could find relating to this topic of creating a work axis in an assembly but I have not managed to get anything to work.

 

I understand that most of the workaxis setby methods outlined in the programming/API help do not work within an assembly.  I would appreciate it if someone could put up a code snippet that creates a work axis in an assembly environment that passes through the origin and a point.

 

This is the other relevant forum post I found:

https://forums.autodesk.com/t5/inventor-customization/workplanes-amp-workaxis-in-assemblies/m-p/2694...

 

As far as I can tell, the workflow necessary is thus:

 

Create origin work point.

Create second work point at specified X, Y coordinates.

Create work axis.

Constrain work axis to the origin point.

Constrain work axis to the second work point.

 

Any help or direction that could be provided to me would be greatly appreciated.

 

4 REPLIES 4
Message 2 of 5
ekinsb
in reply to: Anonymous

To create any of the work features in an assembly you need to use the AddFixed method.  In an assembly, work features aren't ever directly dependent on other geometry, like they are in a part.  Instead their position is controlled via assembly constraints.  You can see this if you interactively create a parallel work plane.  If  you look at the plane after you've created you'll see that the result is a work plane constrained to the selected face with a flush constraint.  If you want to create the same result in the API you create the work plane and then add the constraint as a seperate step.

 

Below is a small program that creates a work axis in an assembly.  You define it's position and orientation by a point and vector.

 

 

Public Sub AssemblyWorkAxis()
    Dim asmDoc As AssemblyDocument
    Set asmDoc = ThisApplication.ActiveDocument
    
    Dim asmDef As AssemblyComponentDefinition
    Set asmDef = asmDoc.ComponentDefinition
    
    Dim tg As TransientGeometry
    Set tg = ThisApplication.TransientGeometry
    
    Dim wa As WorkAxis
    Set wa = asmDef.WorkAxes.AddFixed(tg.CreatePoint(0, 0, 0), _
                                      tg.CreateUnitVector(1, 1, 1))
    wa.Grounded = True
End Sub

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 5
Anonymous
in reply to: ekinsb

Thank you!  That was exactly what I was looking for.  I know that I tried something similar but it is working now.

Message 4 of 5
Anonymous
in reply to: ekinsb

This code works great for me.  I have an issue with units. when enter the values 5, 0, 5, to create point it offsets 5 mm instead of inches.

i checked the assembly document and they are all set to inches as the units.  

Message 5 of 5
ekinsb
in reply to: Anonymous

When using the API, the units are always centimeters, regardless of the units the user has chosen for the document.

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog

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

Post to forums  

Autodesk Design & Make Report