Autodesk Inventor
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: parts lists in Inventor 2012
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Curtis,
I tried Set oPartsList.Style = oDoc.StylesManager.PartsListStyles.Item("PARTS LIST PART"), but the style stayed the same. I'm assuming I needed to change the "DimensionStyles" in your example to "PartsListStyles"?
Thank you,
Chris
Re: parts lists in Inventor 2012
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi cmines,
You're exactly right. I meant PartsListStyles.
That's what I get for trying to offer code help without being able to test it. ![]()
I'm not sure what else to offer other than I notice that oSheet is not defined in your example, but I assume you'd have that defined elsewhere.
Also you might look at the example here:
http://www.mcadforums.com/forums/viewtopic.php?f=1
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Re: parts lists in Inventor 2012
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
OK, I assumed that you were wanting to change the style of an existing PL. What you are wanting to do is set the style of a PL before or as you place it. I believe all that's needed is to move the line that sets the style property to the end (after placing the PL).
The problem with your code below is simply that you're trying to assign a style to a PL that doesn't yet exist-- oPartsList is empty at that point. Wait until oPartsList actually contains a PL, then assign the style. The last line of your code is not needed, since the reference is already set by the line above (the Add method).
So here's my idea:
Dim oPartsList As PartsList
oPartsList = oSheet.PartsLists.Add(oDrawingView1, oPlacementPoint)
oPartsList.Style = "PARTS LIST PART"
This declares the parts list object, creates a new parts list and simultaneously assigns it to the declared object, then assigns the style of that object.
cmines wrote:
' Create the parts list and set a reference to it.
Dim oPartsList As PartsList
Set oPartsList.Style = "PARTS LIST PART"
Set oPartsList = oSheet.PartsLists.Add(oDrawingView1, oPlacementPoint)
Set oPartsList = oSheet.PartsLists.Item(1)
This creates the parts list, just not with the style I am trying to tell it to use.
Thanks for all your help!
Chris
Re: parts lists in Inventor 2012
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sam,
I tried moving the line to set the style after the pl was created, and still no change. I was under the impression that Inventor used the pl style to create the pl.....what the contents of each column are, how many columns, column size, etc.
I'm sure you have noticed, but my profession is NOT programming, so I appreciate all your help and hints!
Thanks,
Chris
Re: parts lists in Inventor 2012
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I haven't discovered any way for the API to set the PL style before or as a PL is placed, only afterwards. Is this Visual Basic, or VBA, or iLogic code?
I'm not a programmer, either, but I pretend to be one from time to time.
Update: how about some debugging messages to understand what's going on? Try having your code report the new PL's style right after it's placed, then report again after the line that changes the style. If you're using VB or VBA, you can also step through your code line by line and check the status of variables and properties after each step.
Re: parts lists in Inventor 2012
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sam,
I'm using VBA for now. After I get everything working the way I want it, I'll move it to VB. Ive tried adding code to report the pl style....I can't even get it to do that. Other variables or properties, no problem. I've also drilled down in the watch list and found the pl style I want to change it to, but I can't seem to get the right....hierarchy.....path...whatever that is called, into my code to change it.
Thanks,
Chris
Re: parts lists in Inventor 2012
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I'm finally trying it out for myself and getting nowhere. I can get it to report the style of the PL (oPartsList.Style.Name), but I'm having no luck setting the PL style because I can't figure out how to actually access available styles. The Help is really useless here-- just an example or two would be really... helpful.
Re: parts lists in Inventor 2012
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I agree! Examples would be a huge help! I was hoping that someone from Autodesk would read this thread and verify if it is possible or not.
Re: parts lists in Inventor 2012
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi guys,
I had a go at this and was able to get it sorted with sbixler's pointer of setting the style after creating the parts list. I tested this on Inventor 2013, but not 2012.
Here's an example ilogic rule that places a parts list on a specific layer and to a specific style. You can tweek it for VB as needed.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
'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
'set a reference to the first drawing view on the sheet. Assumes it's not a draft view.
Dim oDrawingView As DrawingView
oDrawingView = oSheet.DrawingViews(1)
'define the insert point
Dim oPlacementPoint As Point2d
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d (27#, 20.625#)
'create the parts list
Dim oPartsList As PartsList
oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
'set parts list to a specific layer
oPartsList.Layer = oDrawDoc.StylesManager.Layers.Item("Visible (ANSI)")
'set parts list to a specific style
oPartsList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("Material List (ANSI)")

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Re: parts lists in Inventor 2012
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
OK, found my problem: my last line was "Set oPL.Style = ...." When I got rid of the "Set", it works fine. Apparently VBA requires the Set keyword to assign objects, but must not use it to set properties. I had forgotten that little detail.
Cmines, have you got what you need now? If not, fire back and we'll get it figured out.



