Reusing iMates

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to reuse some iMates and would like some advice about how to code this.
Background Information
I will be constraining parts/assemblies to an extruded aluminum beam.
This beam has 4 slots and thus four composite iMates.
This is a simplified shaft clamp and it has 2 similar composite iMates that mate to any slot on the beam. There are 2 to allow me to flip the clamp over. (We have lots of different clamps so that is necessary). There are also other iMates on it that are important
Part 1
First, I ALT+drag-and-drop the composite iMates to the slot I want:
Next, I want the code to reapply the iMates within the composite iMate and then delete the composite iMate so it looks like this:
It should be noted that I mated the iMates of the under the Clamp's composite iMate with the Beam's original geometry that the iMates referenced, not the iMates themselves as you can't do that.
The reason for this is so that I can reuse the Composite if I want to change the location on the beam.
Part 2
I want to be able to change the location of the clamp a different slot by ALT+dragging the composite iMate. Thus, I need the code to delete the previous iMates and then repeat part 1.
Problem
When you ALT+drag a composite iMate over another, before releasing the mouse, Inventor fires a new relationship event (in code) to visualize what will happen. Thus, if you ALT+drag a composite over another composite, drag it away, and then bring it back, it fires a new relationship event multiple times in the AssemblyEvents_OnNewRelationship. This is a problem because I was thinking of using that event to add iMates and then delete the Composite. Or can I still do that anyway?
In other words, I am wondering if anyone has advice or some pseudocode about the best way to implement this idea. I was thinking about handling the assembly Events to do it but not sure if this is best. If all else fails, I can have multiple commands that I manually fire but this is less than optimal. Also, do you think it would be possible to have the code change the Position representation of the clamps depending on which iMate I grab?
Thank you
Let me know if this is confusing and you need me to clear anything up. Attached should be the parts but here is an extra link for more convenience.
https://drive.google.com/file/d/1LmP9PrehjmeN_VYk9bez1FcVMk-M_8Vb/view?usp=sharing