Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey y'all. I am trying to create some code I can run in a drawing document that is going to automatically add a different parts list to my sheet depending on if the current view on the sheet is a part or assembly. I have pieced together some code, but have not had any success when running it. (no errors, but nothing happens) I think the problem is something to do with calling on "oDwgDoc.type" and not the type in the view on the sheet. I have pasted the code below:
oDwgDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDwgDoc.ActiveSheet Dim oBaseView As DrawingView Dim oPartsList As PartsList oBaseView = oSheet.DrawingViews.Item(1) If Not oBorder Is Nothing Then oPlacementPoint = oBorder.RangeBox.MaxPoint Else oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width - 2.54/2, oSheet.Height - 2.54) End If Try oPartsList = oSheet.PartsLists(1) Catch If oDwgDoc.Type = kAssemblyDocumentObject Then oPartsList = oSheet.PartsLists.Add(oBaseView, oPlacementPoint) oPartsList.Style = oDwgDoc.StylesManager.PartsListStyles.Item("Assembly List") Else If oDwgDoc.Type = kPartDocumentObject Then oPartsList = oSheet.PartsLists.Add(oBaseView, oPlacementPoint) oPartsList.Style = oDwgDoc.StylesManager.PartsListStyles.Item("Parts List Dimensionless") End If End Try End Sub
Solved! Go to Solution.