Ilogic rule to open "change Component" dialogue box of a specific Ipart within an assembly

Ilogic rule to open "change Component" dialogue box of a specific Ipart within an assembly

Tim.PelvanRijnsoever
Contributor Contributor
804 Views
7 Replies
Message 1 of 8

Ilogic rule to open "change Component" dialogue box of a specific Ipart within an assembly

Tim.PelvanRijnsoever
Contributor
Contributor

Hi all,

 

I am trying to come up with an Ilogic Rule to automatically open the "change Component" dialogue box of a specific Ipart within an assembly. i have a rule i have adapted from another forum thread here but this one requires the user to click (pick) the ipart within the assembly for the dialogue box to open after running the rule.

 

could someone please help me adjust this code to achieve this?  

the ipart name is "Reducer BW: 1"

 

cheers

Tim P

 

Dim asm As AssemblyDocument = ThisDoc.Document
Dim occ As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "SELECT REDUCER")
Dim occNode As BrowserNode = asm.BrowserPanes.ActivePane.GetBrowserNodeFromObject(occ)
Dim tabNode As BrowserNode = occNode.BrowserNodes(1)
tabNode.DoSelect()

ThisApplication.CommandManager.ControlDefinitions("AssemblyChangeComponentCmd").Execute

  

0 Likes
Accepted solutions (2)
805 Views
7 Replies
Replies (7)
Message 2 of 8

Andrii_Humeniuk
Advisor
Advisor

Hi @Tim.PelvanRijnsoever . Try this code:

Dim asm As AssemblyDocument = ThisDoc.Document
Dim occ As ComponentOccurrence = asm.ComponentDefinition.Occurrences.ItemByName("Reducer BW:1")
Dim occNode As BrowserNode = asm.BrowserPanes.ActivePane.GetBrowserNodeFromObject(occ)
occNode.DoSelect()

ThisApplication.CommandManager.ControlDefinitions("AssemblyChangeComponentCmd").Execute()

 In line 2, you need to write the name of your component ("Reducer BW:1").

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 8

Tim.PelvanRijnsoever
Contributor
Contributor

Thanks for the reply @Andrii_Humeniuk,

 

when I run this rule it only selects/highlights the component in the assembly tree and doesn't open the "change Component" dialogue box..

any ideas?

 

Tim

 

0 Likes
Message 4 of 8

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

This code will definitely work:

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oPane As BrowserPane = oDoc.BrowserPanes.ActivePane
Dim oOcc As ComponentOccurrence = oDoc.ComponentDefinition.Occurrences.ItemByName("Reducer BW:1")
Dim oNode As BrowserNode = oPane.GetBrowserNodeFromObject(oOcc)
oNode.Expanded = True
Dim oTableNode As BrowserNode = oNode.BrowserNodes.Item(1)
oTableNode.DoSelect
ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyChangeComponentCmd").Execute

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 5 of 8

Tim.PelvanRijnsoever
Contributor
Contributor

Thanks again @Andrii_Humeniuk,

 

This code works when i directly run the rule. 

one small problem i didnt mention though. I am tying to use this rule in a local Form within the assembly, when i add the rule and set the Behavior of rule to "Close and Then Run Rule" under "On Click Action" it only highlights the Table of the iPart and never opens the Change Component dialogue box.

im not sure if this is a form or rule issue?

i have created a separate Rule (iLogicVB.RunRule)  to run the Change Component Rule but it still wont work.

Any thoughts?

 

Tim

0 Likes
Message 6 of 8

Tim.PelvanRijnsoever
Contributor
Contributor
Hey,

just wondering if you or others could still help me with this?

cheers
Tim
0 Likes
Message 7 of 8

WCrihfield
Mentor
Mentor
Accepted solution

Is the iLogic Form internal, or global?  Is the iLogic rule internal or external?  If the form is global, then you will need to use the 'On Click Action' that includes 'Apply' before running the rule, because changes in the form need to be 'sent' to the document first.  Also, is the form shown 'Modal' or Non-Modal?  Is the form being launched from an iLogic rule?  If so, does that rule contain more lines of code after the line of code that launches the form?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 8

Tim.PelvanRijnsoever
Contributor
Contributor

Hi @WCrihfield,

 

I changed the Behavior "Modal" to True and this worked! I didn't know this was an option..

thanks for your help!

 

Tim PvR 

 

0 Likes