Inventor Customization

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

Command Manager and iLogic.Automation not working

737 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

Distinguished Contributor
thomaskennedy
Posts: 112
Registered: ‎09-27-2010
Message 2 of 5 (716 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: 112
Registered: ‎09-27-2010
Message 3 of 5 (703 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: 957
Registered: ‎02-24-2009
Message 4 of 5 (668 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: 112
Registered: ‎09-27-2010
Message 5 of 5 (650 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube