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:
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.
Solved! Go to Solution.
Solved by ekinsb. Go to 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
Thank you! That was exactly what I was looking for. I know that I tried something similar but it is working now.
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.
Can't find what you're looking for? Ask the community or share your knowledge.