Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone,
My task is to create a rule which allows me to enter a rule name and click the part in an assembly and it will run that particular rule in that assembly. I already have the rule and it is working fine. but i am looking for a little of modification like to give a list of all rules in each part in the assembly and then select the part to run that particular rule. could anyone please help me with that. below is the code for running the rule for selected part. the code will not display the list of rules and we have to manually type the rule to run.
Dim doc As AssemblyDocument doc = ThisApplication.ActiveDocument Dim RuleName As String RuleName = InputBox("INPUT RULE", "ASFD-DESIGN TECHNOLOGY DEPARTMENT", "Type Here Please") If doc.DocumentType = kPartDocumentObject Then MessageBox.Show("This rule can only be run in an assembly file - exiting rule", "") Return End If Dim targetOcc As ComponentOccurrence= Nothing Do While True ' Note the below line will prompt the user to pick an assembly occurrence (this can be a single part file or a sub-assembly of the active document... targetOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Occurrence to Modify...(Press ESC to cancel)") If Not targetOcc Is Nothing Then Exit Do Else Dim Res As MsgBoxResult = MsgBox("No model selected - exit?", 36, "") If Res = vbYes Then Return Else ' Do nothing - keep on looping... End If End If Loop Try iLogicVb.RunRule(targetOcc.Name, RuleName) Catch MsgBox("Error - No Rule Exit with this name in the Selection", 64, "") End Try
Solved! Go to Solution.