Inventor General Discussion

Posts: 14
Registered: ‎09-12-2012
Message 1 of 3 (898 Views)
Accepted Solution

ilogic generate parts list

898 Views, 2 Replies
10-04-2012 02:34 AM

Hi, I curently have a rule that generates a part list automatically in a drawing. the problem is that I want the rule to be continuisly running but it keeps generating 2,3,5... parts lists. I need an if statment to check if a parts list already exists.


iLogicVb.UpdateWhenDone = True   
    On Error Resume Next
    ' Set a reference to the drawing document.    ' This 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. This assumes the first drawing    ' view on the sheet is not a draft view.    Dim oDrawingView As DrawingView
    oDrawingView = oSheet.DrawingViews(1)
    ' Set a reference to th sheet's border    Dim oBorder As Border
    oBorder = oSheet.Border
    Dim oPlacementPoint As Point2d
    If Not oBorder Is Nothing Then
        ' A border exists. The placement point        ' is the top-right corner of the border.        oPlacementPoint = oBorder.RangeBox.MaxPoint
        ' There is no border. The placement point        ' is the top-right corner of the sheet.         oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
         iLogicVb.UpdateWhenDone = True
    End If
    ' Create the parts list.    Dim oPartsList As PartsList
    oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

iLogicVb.UpdateWhenDone = True

*Expert Elite*
Posts: 2,812
Registered: ‎03-08-2006
Message 2 of 3 (890 Views)

Re: ilogic generate parts list

10-04-2012 04:56 AM in reply to: craigzcool

Hi craigzcool,


Here's a quick rule that checks for an existing parts list:


Dim oDoc As Inventor.DrawingDocument
oDoc = ThisDoc.Document

'specify the drawing sheet as the first sheet in the collection
oSheet = oDoc.Sheets(1) 

Dim oPartslist As PartsList
'set as the first parts list found on sheet 1
oPartslist = oSheet.PartsLists(1)
MessageBox.Show("There is an existing Parts List", "iLogic")
MessageBox.Show("There is NOT an existing Parts List", "iLogic")
End Try


You could also use an Error check to catch the case where no parts list is found, as in this example:


 I hope this helps.
Best of luck to you in all of your Inventor pursuits,

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

Posts: 14
Registered: ‎09-12-2012
Message 3 of 3 (886 Views)

Re: ilogic generate parts list

10-04-2012 05:04 AM in reply to: craigzcool

The code works perfectly!


Thanks :smileyhappy:

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community

Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor