Create Work Axis in Assembly

Create Work Axis in Assembly

Anonymous
Not applicable
2,804 Views
4 Replies
Message 1 of 5

Create Work Axis in Assembly

Anonymous
Not applicable

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.

 

0 Likes
Accepted solutions (1)
2,805 Views
4 Replies
Replies (4)
Message 2 of 5

ekinsb
Alumni
Alumni
Accepted solution

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
Not applicable

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

0 Likes
Message 4 of 5

Anonymous
Not applicable

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.  

0 Likes
Message 5 of 5

ekinsb
Alumni
Alumni
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