Redefine assembly work point to a work point in a part

Redefine assembly work point to a work point in a part

ilari_monkare6Q6T9
Contributor Contributor
265 Views
4 Replies
Message 1 of 5

Redefine assembly work point to a work point in a part

ilari_monkare6Q6T9
Contributor
Contributor

How do I redefine a work point in assembly file so that it is in same location as a work point in a part (that is part of the assembly) using iLogic?

My use case is to place dimensions in a drawing using assembly work points. All my code is in the assembly file. If I redefine the work points manually the dimensions are updated correctly, just need to do it automatically with iLogic .

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

WCrihfield
Mentor
Mentor
Accepted solution

Hi @ilari_monkare6Q6T9.  Unfortunately, the only method we can use to create / define WorkPoints within an assembly using Inventor API code or iLogic code is the WorkPoints.AddFixed method, which obviously creates a fixed WorkPoint, not one that will automatically move with updates.  All the other methods for creating WorkPoints will work just fine in Parts, but not in Assemblies.  We can create them manually in assemblies just fine, but there has been something preventing all those code based methods from working in assemblies for years now.  So, if you created them by code, they would be fixed.  There are ways change their locations by code after they are created, but any code that does that would have to be 'event driven', or manually ran, when you want to update them.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

ilari_monkare6Q6T9
Contributor
Contributor

Thank you Wesley. I understand now why this approach hasn't come up when placing dimensions between parts in an assembly view. Is there a way to do it from assembly file?

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

Just as added information, for future reference, I will post about how to change the locations of existing WorkPoints, by code, that were created directly within an assembly.

When you iterate through all the WorkPoints in an assembly, each individual WorkPoint object has some properties that are essentially just for reference (ReadOnly), and some that we can actually use to change them.  For example, the WorkPoint.Point property is ReadOnly, so we can not set a different Point object as its value, and trying to change the properties of that returned Point object directly will not work either, becaues it is a 'transient' (temporary / mathematical) object that is not held onto.  But there is still a way to change it indirectly.  When we check its WorkPoint.DefinitionType property, which returns a variation of the WorkPointDefinitionEnum, we will find out that it's always a 'kAssemblyWorkPoint' type, which informs us about the type of work point definition to expect from the WorkPoint.Definition property.  Then we can create a variable to hold onto that definition, and set its Type as AssemblyWorkPointDef, and use that WorkPoint.Definition property to set that variable's value.  Once we have that, we can use its AssemblyWorkPointDef.Point property, which is Read/Write, allowing us to set a different Point object as its value.  The other Point object we may set as its value can be obtained from some other proxy geometry that exists within the assembly, if that is your goal, but as mentioned before, this update step would likely need to be ran (one way or another), whenever either the part geometry changes, &/or when the component occurrence representing that part moves within the assembly, to keep it accurate.  You will also notice that the 'definition' has a 'constraints' collection associated with it (AssemblyWorkPointDef.Constraints).  Unfortunately that is another ReadOnly property which only returns an AssemblyConstraintsEnumerator type object, which does not give us any options to create new constraints that would be associated with this WorkPoint.

Another way to move that fixed WorkPoint, which is likely slightly simpler/easier, is by using the WorkPoint.SetFixed method.  Even though that method works, the very similar WorkPoint.SetByPoint method will throw an error, because it is one of those that is not supported for use in assemblies right now.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor

I did not see your second reply before posting my second reply.  I think that what you are trying to do is actually a pretty valid and relatively popular automation process.  Just not something that I do myself.  Due to the vast diversity in the things we make drawings for, we generally do not do the 'detailing / dimensioning / annotations' portion of our drawings using code-based automation tactics.

However, it seems like if your assemblies are relatively similar, and you originally created all the WorkPoints you needed in your assembly manually, and maybe kept a copy of one of those assemblies as a sort of 'template', where you could 'replace' components with other components, then you may be able to maintain the 'automatic updating' ability of those WorkPoints, or at lease be able to find the constraints associated with those existing WorkPoint objects, so that you could edit/modify those existing constraints, in whatever way may be necessary, to keep them updated, as needed.  This is just a thought though, since I do not use this process myself.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes