Message 1 of 3
Having trouble with a parts list rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an ilogic rule that I run to remove, add, and sort my parts lists. But for some reason it doesn't always work.
I made a template using a frame generated assembly with a general drawing. I then ilogic copied the drawing and model to new folders for the different sizes that I am going to make. I then open each model and drawing and edit them to the correct dimensions then I complete the drawing. But every once in a while the parts list rule shows and error and won't run. I can seem to figure out why. Any help on this is greatly appreciated, thanks in advance.
Here is the rule:
Sub Main Partslist Renumber PLSTYLE End Sub Sub Partslist 'Create or replace Partslist Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDrawingDoc.ActiveSheet Try Dim oPartslistCheck As PartsList oPartslistCheck = oSheet.PartsLists(1) partslistpresent=True Catch partslistpresent=False End Try If partslistpresent=True Dim oPartsList As PartsList oPartsList = oDrawingDoc.ActiveSheet.PartsLists.Item(1) oPartsList.Delete End If Dim oDrawingView As DrawingView oDrawingView = oSheet.DrawingViews(1) Dim oBorder As Border oBorder = oSheet.Border xMax = oBorder.RangeBox.MaxPoint.X - 0 yMax = oBorder.RangeBox.MaxPoint.Y xMin = oBorder.RangeBox.MinPoint.X yMin = oBorder.RangeBox.MinPoint.Y Dim oPlacementPoint1 As Point2d oPlacementPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(xMax, yMax) Dim oPartsList1 As PartsList oSheet.PartsLists.Add(oDrawingView, oPlacementPoint1) oPartsList1 = oDrawingDoc.ActiveSheet.PartsLists.Item(1) PLxrev = (oPartsList1.RangeBox.MaxPoint.X -oPartsList1.RangeBox.MinPoint.X) PLyrev = (oPartsList1.RangeBox.MaxPoint.Y -oPartsList1.RangeBox.MinPoint.Y) oPlaceX = xMax PL_Style = Parameter("PL_Style") If PL_Style = "ICM Parts List - Lower Right" Then oPlaceY = yMin + PLyrev + 2.8575 End If If PL_Style = "ICM Parts List - Upper Right" Then oPlaceY = yMax End If oPlacementPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(oPlaceX, oPlaceY) oPartsList1.Position = oPlacementPoint2 oPartsList1.Sort("DWG# /TAG#") oPartsList1.Renumber oPartsList1.SaveItemOverridesToBOM oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item(PL_Style) Dim oPartList As PartsList oPartList = oDrawingDoc.ActiveSheet.PartsLists.Item(1) Dim i As Long For i = 1 To oPartList.PartsListRows.Count oCell = oPartList.PartsListRows.Item(i).Item("CUT LENGTH") oCell2 = oPartList.PartsListRows.Item(i).Item("CUT_LTH") If oCell2.Value = "" Then oCell.Value = "" End If Next End Sub Sub Renumber Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim oPartList As Partslist oPartList = oDrawingDoc.ActiveSheet.PartsLists.Item(1) Dim i As Long For i = 1 To oPartList.PartsListRows.Count oCell = oPartList.PartsListRows.Item(i).Item("CUT LENGTH") oCell2 = oPartList.PartsListRows.Item(i).Item("CUT_LTH") If oCell2.Value = "" Then oCell.Value = "" End If Next 'oPartList.Sort("ITEM", True) oPartList.Sort2("ITEM",True,"ITEM",True,"ITEM",True,True, True) oPartList.Renumber oPartList.SaveItemOverridesToBOM End Sub Sub PLSTYLE Dim openDoc As Document '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 'Look for partlist within drawing. End rule, if it doesn't exist. 'say there is a Partslist on the sheet. Dim oPartslist As Partslist oPartslist = oSheet.PartsLists(1) 'set parts list to a specific style If PL_Style= "ICM Parts List - Upper Right" Then oPartslist.Style = oDrawDoc.StylesManager.PartsListStyles.Item("ICM Parts List - Upper Right") End If If PL_Style= "ICM Parts List - Lower Right" Then oPartslist.Style = oDrawDoc.StylesManager.PartsListStyles.Item("ICM Parts List - Lower Right") End If End Sub