Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Command Manager and iLogic.Automation not working

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
thomaskennedy
2319 Views, 4 Replies

Command Manager and iLogic.Automation not working

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

4 REPLIES 4
Message 2 of 5

edit :

 

I forgot to add that I'm working with Inventor 2011 on Win 7, 64bit

Message 3 of 5

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...

 

 

Message 4 of 5
MjDeck
in reply to: thomaskennedy

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).


Mike Deck
Software Developer
Autodesk, Inc.

Message 5 of 5
thomaskennedy
in reply to: MjDeck

Mike,

 

That's worked great, thanks very much!

 

Cheers,

Tom

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report