I have created 2 parts list styles and need to be able to change just the parts list style for the active sheet in a multiple sheet document. I read in posts on this forum that this was not possible in previous versions. Is this now possible with the API for Inventor 2012 or 2013? I know it can be done thru the UI, but have not been able to figure out how to or even if it can be done using the API for 2012.
Solved! Go to Solution.
That's what I thought, and tried, but I couldn't get it to work. What would the code look like to set the name? When selected the API Reference help for the Name property of the PartsListStyle from the Object Browser, it took me to the Style.Name property instead of the PartsListStyle.Name property I was expecting. When I looked under the PartsListStyle in the API Reference, there is no Name property listed......but there is in the Object Browser. Any help you could provide would be greatly appreciated.
Looks as if once you have a particular parts list identified, you could use something like this: oMyPartsList.Style = "Parts List (ANSI)". Again, I haven't tried this, just trying to interpret what I'm reading.
Here is what I tried:
Dim oPartsList As String
Set oPartsList.Style = "Parts List A"
I got a compile error "Invalid qualifier"
Thanks again for your help!
Ah, the declaration is a problem (I hope it's the only problem)-- you need to declare the Parts List object as a PartsList object, not a string. So "Dim oPartsList As PartsList"
How are you getting oPartsList to be the actual list you're interested in? How many parts lists are there in each drawing? Only one, or could there be more?
Right before I add the first parts list, I'm setting the style. I wrote a macro that essentially creates a parts list for the first part found, and then adds custom line (from a temp part list) for each additional part found on the sheet. It works great when I use my idw template that already has the parts list style that I want as default. Now I need to run the macro in an idw that has a different parts list style as default and get the macro to change only the parts list style when it is run. Here is how I'm trying to set the style for the first parts list created.
' 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!
I think you need to use the StylesManager as in this example. I didn't test this, but I think it might be the last missing piece.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
' Create the parts list and set a reference to it. Dim oDoc As DrawingDocument oDoc = ThisApplication.ActiveDocument Dim oPartsList As PartsList Set oPartsList.Style = oDoc.StylesManager.DimensionStyles.Item("PARTS LIST PART" ) Set oPartsList = oSheet.PartsLists.Add(oDrawingView1, oPlacementPoint) Set oPartsList = oSheet.PartsLists.Item(1)
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.