Change Default Parts List with iLogic

Change Default Parts List with iLogic

Anonymous
Not applicable
436 Views
0 Replies
Message 1 of 1

Change Default Parts List with iLogic

Anonymous
Not applicable

Hey all,

I'm looking for a way to change the default parts list with iLogic. I looked at this post, and it was a good launching point, but I was hoping to get some more advanced advice. For my code, I'd like it to change the Parts List style before it is placed in the drawing. With this, of course, the "active sheet" shouldn't matter.

 

My code is as follows:

 

 

SyntaxEditor Code Snippet

'Look For a model referenced within the drawing. End the Rule If the drawing Is empty.
If ThisDoc.ModelDocument IsNot Nothing Then
    Dim MDocFile As Document
    MDocFile = ThisDoc.ModelDocument

    Dim openDoc As Document
    openDoc = ThisDoc.Document
    
    'Check the drawing's Stock Number iProperty for DAD, ASM, or GAD
    If iProperties.Value("Project", "Stock Number") = "DAD" Then

        'YOU'LL NOTICE THAT I HAVE MUCH OF THE CODE BELOW GREYED OUT.
        'IT WAS FROM THE ORIGINAL CODE, AND I'M NOT SURE IF I'LL NEED IT
        'IN THE FUTURE, SO I JUST KEPT IT.

        'Set a reference to the active document
        Dim oDrawDoc As DrawingDocument
        oDrawDoc = ThisApplication.ActiveDocument
        
        'Set a reference to the active sheet.
        'Dim oSheet As Sheet
        'oSheet = oDrawDoc.ActiveSheet
        
        'Look for partlist within drawing. 
        'Dim oPartslist As PartsList
        'oPartslist = oSheet.PartsLists(1)

        'Set parts list to a style based on the Stock Number iProperty
        'oPartsList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("PartsList(NOV Structural BOM - DAD)")
        oDrawDoc.PartsLists(1).Style = oDrawDoc.StylesManager.PartsListStyles.Item("PartsList(NOV Structural BOM - DAD)")
                
    Else If iProperties.Value("Project", "Stock Number") = "ASM" Or iProperties.Value("Project", "Stock Number") = "GAD"
    
         'This will contain the same code as above, albeit with a different Parts List Style
    
    Else
        MessageBox.Show("Please run the iProperty Synch Rule after ensuring that the Model's Stock Number iProperty contains the suffix DAD, ASM, or GAD")
    
    End If
    
Else
    MessageBox.Show("Please imprt a Model into the Drawing", "Error")
    
End If

Also, if anyone knows how to get a rule to run immediately after placing an object in a drawing, that would be helpful, too.

 

Thanks!

0 Likes
437 Views
0 Replies
Replies (0)