- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, looking for help with navigating object constraints in an Inventor assembly via C#.
We have two parts with 4 holes each in them, that are "connected" with two InsertConstraint objects. Using C# with the Inventor API, we need to be able to find exactly these 2 constraints.
Assume that we prompt the user to select, individually, the two parts, giving us two ComponentOccurrence objects. Let's call them fittingOcc and baseOcc. We can iterate over fittingOcc.Constraints, and identify any and all InsertConstraints in that set. We can do the same for baseOcc.
But it isn't this straightforward. Assume there may be more than 2 InsertConstraint objects in our sets.
Can we rely on using constraint1.Equals(constraint2)? Is this a true object equality, or does it only compare the Name properties? Occurrence names are not guaranteed to be unique within our entire assembly.
The other problem is that the constraints we seek may not "live" in the Constraints collection on the ComponentOccurrence objects we selected - they may "live" in *.ParentOccurrence.Constraints, or *.Parent.Constraints - or possibly at another level, if the parts are in separate deeply nested subassemblies.
We've tried getting the EdgeProxy from constraint.EntityOne and constraint.EntityTwo, then looked at its ContainingOccurrence property to try to determine if this is the constraint we are looking for. In theory we could compare edgeProxy.ContainingOccurrence.OccurrencePath with fittingOcc.OccurrencePath, but in nested sub-assemblies, we get a partial occurrence path from the edge proxy.
Could anyone provide guidance on the best way to accomplish this?
Stew Sabadell
Solved! Go to Solution.