Inventor Customization

Inventor Customization

Reply
Distinguished Contributor
thomaskennedy
Posts: 113
Registered: ‎09-27-2010
Message 1 of 5 (841 Views)
Accepted Solution

Command Manager and iLogic.Automation not working

841 Views, 4 Replies
06-27-2012 07:40 AM

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

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

Distinguished Contributor
thomaskennedy
Posts: 113
Registered: ‎09-27-2010
Message 2 of 5 (820 Views)

Re: Command Manager and iLogic.Automation not working

06-27-2012 08:39 AM in reply to: thomaskennedy

edit :

 

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

Distinguished Contributor
thomaskennedy
Posts: 113
Registered: ‎09-27-2010
Message 3 of 5 (807 Views)

Re: Command Manager and iLogic.Automation not working

06-28-2012 02:57 AM in reply to: thomaskennedy

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

 

 

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 4 of 5 (772 Views)

Re: Command Manager and iLogic.Automation not working

07-09-2012 11:26 AM 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
DLS - Mechanical Design
Autodesk, Inc.

Distinguished Contributor
thomaskennedy
Posts: 113
Registered: ‎09-27-2010
Message 5 of 5 (754 Views)

Re: Command Manager and iLogic.Automation not working

07-10-2012 12:53 AM in reply to: MjDeck

Mike,

 

That's worked great, thanks very much!

 

Cheers,

Tom

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!