• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    Contributor
    Posts: 21
    Registered: ‎06-08-2012

    Re: parts lists in Inventor 2012

    06-11-2012 02:12 PM 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

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,933
    Registered: ‎03-08-2006

    Re: parts lists in Inventor 2012

    06-11-2012 02:17 PM 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. :smileywink:

     

    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




      solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.

    Please use plain text.
    *Pro
    Posts: 1,835
    Registered: ‎09-15-2003

    Re: parts lists in Inventor 2012

    06-12-2012 04:16 AM 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


     

    Please use plain text.
    Contributor
    Posts: 21
    Registered: ‎06-08-2012

    Re: parts lists in Inventor 2012

    06-12-2012 05:08 AM in reply to: sbixler

    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

    Please use plain text.
    *Pro
    Posts: 1,835
    Registered: ‎09-15-2003

    Re: parts lists in Inventor 2012

    06-12-2012 05:14 AM 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.

    Please use plain text.
    Contributor
    Posts: 21
    Registered: ‎06-08-2012

    Re: parts lists in Inventor 2012

    06-12-2012 09:39 AM in reply to: sbixler

    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

    Please use plain text.
    *Pro
    Posts: 1,835
    Registered: ‎09-15-2003

    Re: parts lists in Inventor 2012

    06-12-2012 11:56 AM 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.

    Please use plain text.
    Contributor
    Posts: 21
    Registered: ‎06-08-2012

    Re: parts lists in Inventor 2012

    06-12-2012 01:56 PM in reply to: sbixler

    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.

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,933
    Registered: ‎03-08-2006

    Re: parts lists in Inventor 2012

    06-12-2012 05:02 PM 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)")

     



      solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.

    Please use plain text.
    *Pro
    Posts: 1,835
    Registered: ‎09-15-2003

    Re: parts lists in Inventor 2012

    06-13-2012 04:53 AM 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.

    Please use plain text.