Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

parts lists in Inventor 2012

20 REPLIES 20
SOLVED
Reply
Message 1 of 21
cmines
1549 Views, 20 Replies

parts lists in Inventor 2012

Hi,

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. 

 

Thanks!

 

Tags (1)
20 REPLIES 20
Message 2 of 21
SBix26
in reply to: cmines

PartsList.Style property should do the job.  Haven't tried it, just looking in the API Reference section of the Programming Help.

Message 3 of 21
cmines
in reply to: SBix26

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.

Thanks!

Message 4 of 21
SBix26
in reply to: cmines

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.

Message 5 of 21
cmines
in reply to: SBix26

Sam,

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!

Chris

Message 6 of 21
SBix26
in reply to: cmines

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"

Message 7 of 21
cmines
in reply to: SBix26

ok....I'm not getting any errors (YEA),  but it didn't change the parts list style.....(sigh).  Anything else I should try?

Thanks again,

Chris

Message 8 of 21
SBix26
in reply to: cmines

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?

Message 9 of 21
cmines
in reply to: SBix26

Sam,

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!

Chris

Message 10 of 21
Curtis_Waguespack
in reply to: cmines

Hi cmines, 

 

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,
Curtis
http://inventortrenches.blogspot.com

 

 

' 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)

 

Message 11 of 21
cmines
in reply to: Curtis_Waguespack

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

Message 12 of 21
Curtis_Waguespack
in reply to: cmines

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. Smiley Wink

 

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=15&t=12431

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com


Message 13 of 21
SBix26
in reply to: cmines

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


 

Message 14 of 21
cmines
in reply to: SBix26

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

Message 15 of 21
SBix26
in reply to: cmines

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.

Message 16 of 21
cmines
in reply to: SBix26

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

Message 17 of 21
SBix26
in reply to: cmines

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.

Message 18 of 21
cmines
in reply to: SBix26

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.

Message 19 of 21
Curtis_Waguespack
in reply to: cmines

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)")

 

Message 20 of 21
SBix26
in reply to: Curtis_Waguespack

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report