Parent assemblies of the one being edited in place report being changed when a constraint limit is enabled. To reproduce, open Assembly3 (attached) and edit Assembly1 as shown.
Run the following code (also attached).
static void Main() { Inventor.Application application = Marshal.GetActiveObject("Inventor.Application") as Inventor.Application; ApplicationEvents events = application.ApplicationEvents; events.OnDocumentChange += OnDocumentChange; AssemblyComponentDefinition assembly = ((AssemblyDocument)application.ActiveEditDocument).ComponentDefinition; ComponentOccurrence component1 = assembly.Occurrences[1]; ComponentOccurrence component2 = assembly.Occurrences[2]; object workPlane1, workPlane2; component1.CreateGeometryProxy(((PartComponentDefinition)component1.Definition).WorkPlanes[1], out workPlane1); component2.CreateGeometryProxy(((PartComponentDefinition)component2.Definition).WorkPlanes[1], out workPlane2); MateConstraint constraint = assembly.Constraints.AddMateConstraint(workPlane1, workPlane2, 5); Console.WriteLine("Before enable constraint limit"); constraint.ConstraintLimits.MinimumEnabled = true; Console.WriteLine("After enable constraint limit"); constraint.ConstraintLimits.Minimum.Expression = "0"; events.OnDocumentChange -= OnDocumentChange; } static void OnDocumentChange(_Document documentObject, EventTimingEnum beforeOrAfter, CommandTypesEnum reasonsForChange, NameValueMap context, out HandlingCodeEnum handlingCode) { Console.Out.WriteLine("Document changed : {0} : {1} : {2}", reasonsForChange, beforeOrAfter, documentObject.DisplayName); handlingCode = HandlingCodeEnum.kEventNotHandled; }
The following is written to the console.
Document changed : kShapeEditCmdType : kBefore : Assembly1.iam Document changed : kShapeEditCmdType : kAfter : Assembly1.iam Before enable constraint limit Document changed : kShapeEditCmdType : kBefore : Assembly1.iam Document changed : kShapeEditCmdType : kBefore : Assembly2.iam Document changed : kShapeEditCmdType : kBefore : Assembly3.iam Document changed : kShapeEditCmdType : kAfter : Assembly1.iam Document changed : kShapeEditCmdType : kAfter : Assembly2.iam Document changed : kShapeEditCmdType : kAfter : Assembly3.iam After enable constraint limit Document changed : kShapeEditCmdType : kBefore : Assembly1.iam Document changed : kShapeEditCmdType : kAfter : Assembly1.iam
I'm trying to defer updates to the parent assembly.
Regards,
cadull
Solved! Go to Solution.
Solved by ekinsb. Go to Solution.
When you edit in place, the active document is still the top-level assembly. I believe what's happening here is that you're editing the assembly and it's recomputing, which is also causing a recompute in all of the referencing document in order to react to the possible changes.
Thanks Brian,
It is interesting that if we remove the code that sets the limit value, Inventor indicates that the parent assemblies require an update, so the recompute is not a complete update. This led me to inspect the RequiresUpdate property of the document during the event processing and it appears to be suitable in filtering out changes that will require a subsequent update.
Regards,
cadull
Hi Cadull,
Has Brian answered your questions or you need more help?
Cheers,
Hi Adam,
My question has been resolved in that I can determine when I don't need to update in response to the change notification. However, I still don't see why it should behave this way. It does this even if we insert an ActiveDocument.Update between the constraint creation and enabling the limit. I would expect it to behave in the same way as adding the constraint.
Regards,
cadull
I agree that this is not the behavior I would expect. I would have expected a shape edit notification from the upper levels assembly documents when the constraint was placed too since that could result in things moving within them. If you've been able to resolve your problem I think I'll just leave it alone for now.