Hi all,
I have a drawing document that has a rule "DRAWINGPROCESS" and within that rule I am calling the CommandManager to arrange dimensions :
Dim oSelectSet As SelectSet = oDoc.SelectSet oSelectSet.Clear For Each oDrawingDim In oSheet.DrawingDimensions oSelectSet.Select(oDrawingDim) Next Dim oPropContDef2 As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("DrawingArrangeDimensionsCmd") Call oPropContDef2.execute
The code works fine when I run the rule manually in the drawing document.
However, I actually trigger the rule from an assembly document through iLogic.Automation
So from the assembly document I :
- Open the drawing document
- Pass some iProperties into the document
- Run the "DRAWINGPROCESS" rule in the document
The code runs OK and doesn't error out BUT the Arrange Dimensions Command doesn't get executed, I put some message boxes in around the line that executes the command I can see that the dimensions are selected but are never arranged (see images attached)
I also did another test, I created a new rule in my drawing document to do the following :
Dim iLogicAuto As Object = iLogicVb.Automation If (iLogicAuto Is Nothing) Then Exit Sub Dim doc As Document = ThisApplication.ActiveDocument Dim ruleName As String = "DRAWINGPROCESS" Dim rule As Object = iLogicAuto.GetRule(doc, ruleName) Dim i As Integer = iLogicAuto.RunRuleDirect(rule)
This code also runs OK but fails to run ArrangeDimensionsCmd.
And finally, if I create a new rule in the drawing doc and do :
iLogicVb.RunRule("DRAWINGPROCESS")
Everything works OK - the ArrangeDimensionsCmd is fired.
All of the above leads me to the conclusion that it's the iLogic.Automation that is stopping the command being executed.
If this is the case is there a workaround I can use to get this to work ?
If not, where am I going wrong?!
Thanks,
Tom
Solved! Go to Solution.
Solved by MjDeck. Go to Solution.
edit :
I forgot to add that I'm working with Inventor 2011 on Win 7, 64bit
I did a bit more testing this morning but this time in an assembly document
I created this rule to fire a rule "test"
Dim iLogicAuto As Object = iLogicVb.Automation If (iLogicAuto Is Nothing) Then Exit Sub Dim doc As Document = ThisApplication.ActiveDocument Dim ruleName As String = "test" Dim rule As Object = iLogicAuto.GetRule(doc, ruleName) Dim i As Integer = iLogicAuto.RunRuleDirect(rule)
and the "test" rule is trying to execute the place command :
Dim oCommandMgr As CommandManager = ThisApplication.CommandManager Dim oControlDef As ControlDefinition = oCommandMgr.ControlDefinitions.Item("AssemblyPlaceComponentCmd") Call oControlDef.Execute
Again, the command gets executed when the rule is fired manually but doesn't execute when fired via .RunRuleDirect
Hmmm...
Tom,
This has been fixed in Inventor 2013. You can work around it in Inventor 2011 and 2012 by adding the line:
ThisApplication.UserInterfaceManager.UserInteractionDisabled = False
at the top of any rule that calls the ControlDefinition.Execute method.
(This line of code is available under the Advanced API category in the iLogic snippets).