- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying a code that I found online for an automatic partslist.
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet
'Detect if the template has a parts list
Try
Dim oPartslistCheck As PartsList
oPartslistCheck = oSheet.PartsLists(1)
partslistpresent=True
Catch
partslistpresent=False
End Try
If partslistpresent=True
'Delete the current parts list
Dim oPartsList As PartsList
oPartsList = oDrawingDoc.ActiveSheet.PartsLists.Item(1)
oPartsList.Delete
End If
' 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 the sheet's border
Dim oBorder As Border
oBorder = oSheet.Border
Dim oPlacementPoint As Point2d
xrev = oBorder.RangeBox.MaxPoint.X
yrev = oBorder.RangeBox.MinPoint.Y
Dim oTitleBlockItem As TitleBlock
oTitleBlockItem = oSheet.TitleBlock
Dim oHeightTitleBlock As Double
oHeightTitleBlock = oTitleBlockItem.RangeBox.MaxPoint.Y - oTitleBlockItem.RangeBox.MinPoint.Y
' Dim oPartsListItem As PartsList
' oPartsListItem = oSheet.PartsLists
' Dim oHeightPartsList As Double
' oHeightPartsList = oPartsListItem.RangeBox.MaxPoint.Y - oPartsListItem.RangeBox.MinPoint.Y
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev + oHeightTitleBlock)
' Create the parts list.
Dim oPartsList1 As PartsList
oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
oPartsLis1t = oDrawingDoc.ActiveSheet.PartsLists.Item(1)
oPartsList1.Sort("Part Nr. / Drawing Nr.")
oPartsList1.Renumber
oPartsList1.Style.UpdateFromGlobal
'Switch style back and forth to ensure style is up-to-date
' oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ANSI)")
oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ISO)")
InventorVb.DocumentUpdate()
Now I was wondering if it is possible to switch the insert point.
Now it uses corner/point 1 as insert point. And I would like corner/point 2. Is it possible to change this in the code?
Ciao
Solved! Go to Solution.