Change Parts List Style with iLogic

Change Parts List Style with iLogic

Anonymous
Not applicable
2,957 Views
7 Replies
Message 1 of 8

Change Parts List Style with iLogic

Anonymous
Not applicable

I need iLogic code to change the Parts List Style. Here's what I'm starting with:

 

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
        

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
        
Dim oPartslist As PartsList
oPartslist = oSheet.PartsLists(1)

oPartsList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("PartsList(MyStyleName)")

 

But it's not working. I get the error message, "The Parameter is Incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) 

 

Any ideas?

0 Likes
Accepted solutions (1)
2,958 Views
7 Replies
Replies (7)
Message 2 of 8

Ktomberlin
Advocate
Advocate
Accepted solution

It looks like it should work, as long as "Parts​List(MyStyleName)" is actually a parts list in your active drawing. 

 

Dim openDoc As Document
   'assumes a drawing document is active.
    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. End rule, if it doesn't exist.
    'say there is a Partslist on the sheet.
    Dim oPartslist As PartsList
    oPartslist = oSheet.PartsLists(1)

    If oSheet.PartsLists(1) IsNot Nothing Then

        'set parts list to a specific style
        oPartsList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("Material List (ANSI)")

     End If 
Message 3 of 8

Anonymous
Not applicable
My style name was "MyStyleName," not "PartsList(MyStyleName)." Silly me. Thanks.
0 Likes
Message 4 of 8

Anonymous
Not applicable
By the way, could you quickly explain for me what the (1) was for in PartsList(1) and why it's general practice to create these variables named oDrawDoc and oSheet? Or are they even variables? I see them so often, I'm starting to think they're iLogic syntax...
0 Likes
Message 5 of 8

Curtis_Waguespack
Consultant
Consultant

@Anonymous wrote:
By the way, could you quickly explain for me what the (1) was for in PartsList(1) and why it's general practice to create these variables named oDrawDoc and oSheet? Or are they even variables? I see them so often, I'm starting to think they're iLogic syntax...

See link:

http://forums.autodesk.com/t5/inventor-customization/ilogic-a-couple-syntax-questions/m-p/6407238#M65029

EESignature

0 Likes
Message 6 of 8

Anonymous
Not applicable
Baha, thanks, I hadn't gotten an email notification of your response.
0 Likes
Message 7 of 8

Curtis_Waguespack
Consultant
Consultant

@Anonymous wrote:
Baha, thanks, I hadn't gotten an email notification of your response.

No worries, and my apologies for all of they typos in that reply. Smiley Frustrated  Hopefully it makes some bit of sense. Smiley Embarassed

EESignature

0 Likes
Message 8 of 8

Anonymous
Not applicable
don't sweat it, it clears everything up perfectly.