Placing parts list in drawing with ILogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an ilogic program that creates a drawing for an assembly. 90% of the time this runs without error. However if the program is run multiple times (say if something happened where I want to recreate the drawing) it gives the following error when I comment out the on error resume next in the function for placing the parts list:
(Exception from HRESULT: 0x80070057 (E_INVALIDARG))
That error occurs on the point where the parts list is actually added. With the on error resume next, it simply ignores adding the parts list, completes the function without it and creates the rest of the drawing. It will give this error every time on this assembly until a completely new file is done from scratch.
Why is it doing that? Does anyone know how to fix it?
'Places a structured view of the parts list and shifts it to the specified location 'Possible positions are 'Top Right', 'Top Left', 'Bottom Right', 'Bottom Left' '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Function PlacePartsList(oDrawingDoc As DrawingDocument, Position As String) On Error Resume Next 'Declare Document Variables '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Dim oSheet As Sheet Dim oDrawingView As DrawingView Dim oPlacementPoint As Point2d Dim oPartsList As PartsList Dim oBorder As Border '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'Declare Local Variables '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Dim oStyle As String Dim oPlaceX As Double Dim oPlaceY As Double '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'Initialize variables '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ oSheet = oDrawingDoc.ActiveSheet oDrawingView = oSheet.DrawingViews(1) oBorder = oSheet.Border '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'create parts list '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ oPartsList = oSheet.PartsLists.Add(oDrawingView, oBorder.RangeBox.MinPoint, PartsListLevelEnum.kStructured) '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'Set position '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ If Position = "Top Right" oPlaceX = oBorder.RangeBox.MaxPoint.X oPlaceY = oBorder.RangeBox.MaxPoint.Y Else If Position = "Top Left" oPlaceX = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X) oPlaceY = oBorder.RangeBox.MaxPoint.Y Else If Position = "Bottom Right" oPlaceX = oBorder.RangeBox.MinPoint.X oPlaceY = oBorder.RangeBox.MinPoint.Y + (oPartsList.RangeBox.MaxPoint.Y - oPartsList.RangeBox.MinPoint.Y) Else If Position = "Bottom Left" oPlaceX = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X) oPlaceY = oBorder.RangeBox.MinPoint.Y + (oPartsList.RangeBox.MaxPoint.Y - oPartsList.RangeBox.MinPoint.Y) Else MsgBox("Incorrect position statement. Please correct input position and input") Exit Function End If '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'Move parts list '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oPlaceX,oPlaceY) oPartslist.position = oPlacementPoint '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ End Function '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\