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 Else ' 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 iLogicVb.RunRule("SortPartsList")
Solved! Go to Solution.
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) Try 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") Catch 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,
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Start with some of our most frequented solutions to get help installing your software.