Message 1 of 4
Selecting Parts in Assembly and Filling in IProperties
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to write an ilogic code that will allow me to select parts within an assembly then update the Iproperties of the the selected parts. I found this code to select the parts and run a rule on the selected parts.
Sub Main() Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition Dim oPart As ComponentOccurrence 'Dim sRuleName As String = "IPROPERTY UPDATE" Line1 : '''Pick part occurrence oPart = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select Part") If oPart Is Nothing Then Exit Sub Else Dim oFileName As String = oPart.Definition.Document.FullFileName Dim oDoc As PartDocument = ThisApplication.Documents.Open(oFileName) iLogicVb.RunExternalRule("IPROPERTY UPDATE") ' auto = iLogicVb.Automation ' Try ' auto.RunRuleExternalRule(oDoc, sRuleName) ' Catch ' MessageBox.Show("Cannot find a rule with the name " & sRuleName & "." & vbLf & "Please try again.", "Open and run") ' End Try '''Close the document with SAVE (as False), without SAVE (As True) oDoc.Close(False) Question = MessageBox.Show("Repeat Command?", "Open and run", MessageBoxButtons.OKCancel) If Question = vbOK Then ''Repeat command GoTo Line1 Else Exit Sub End If End If End Sub
However if the commented code is uncommented and the iLogicVb.RunExternalRule("IPROPERTY UPDATE") is commented the message box pops up saying the rule can't be found. If the commented and uncommented are switched the select parts code will run as well as the iproperty update from within the select parts but the iproperties of the selected part don't update. What am I doing wrong? I feel like I'm missing something simple.
Thank you in advance for the help.