Hi All,
I'm trying to automate my drawing creation but i've run into a problem. In my code it takes the document collection object and itereates through and creates a drawing for each part and assembly the problem is i need it to skip the files from my library and content center since they dont require drawings. Any help would be greatly appreciated. Here is the code:
Public Sub CreateDrawing()
'get documents collection object
Dim invDocs As Documents
Set invDocs = ThisApplication.Documents
'iterate through documents in collection
Dim invDoc As Document
For Each invDoc In invDocs
ElseIf invDoc.DocumentType = kAssemblyDocumentObject Then
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, ThisApplication.FileOptions.TemplatesPath & "ASE-Drawing (Part).idw", True)
'Set a reference to the active sheet.
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
' Create the placement point objects.
Dim oPoint1 As Point2d
Set oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(16, 18)
Dim oPoint2 As Point2d
Set oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(37, 18)
Dim oPoint3 As Point2d
Set oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(16, 32)
Dim oPoint4 As Point2d
Set oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(37, 32)
' Create a base view.
Dim oBaseView As DrawingView
Set oBaseView = oSheet.DrawingViews.AddBaseView(invDoc, oPoint1, 1, kFrontViewOrientation, kHiddenLineDrawingViewStyle, "Front")
' Create left projected view.
Dim rightProjView As DrawingView
Set rightProjView = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, kFromBaseDrawingViewStyle, 1)
' Create top projected view.
Dim topProjView As DrawingView
Set topProjView = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint3, kFromBaseDrawingViewStyle, 1)
' Create isometric projected view.
Dim isoProjView As DrawingView
Set isoProjView = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint4, kHiddenLineRemovedDrawingViewStyle, 1)
' Create a parts list for the assembly
' Set a reference to th sheet's border
'Dim oBorder As Border
'Set oBorder = oSheet.Border
Dim oPlacementPoint As Point2d
Set oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(16.8275, 41.5925)
' Create the parts list.
Dim oPartsList As PartsList
Set oPartsList = oSheet.PartsLists.Add(oBaseView, oPlacementPoint, kPartsOnly)
ElseIf invDoc.DocumentType = kPartDocumentObject Then
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc1 As DrawingDocument
Set oDrawDoc1 = ThisApplication.Documents.Add(kDrawingDocumentObject, ThisApplication.FileOptions.TemplatesPath & "ASE-Drawing (Assembly).idw", True)
'Set a reference to the active sheet.
Set oSheet = oDrawDoc1.ActiveSheet
' Create the placement point objects.
Set oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(16, 18)
Set oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(37, 18)
Set oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(16, 32)
Set oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(37, 32)
' Create a base view.
Set oBaseView = oSheet.DrawingViews.AddBaseView(invDoc, oPoint1, 1, kFrontViewOrientation, kHiddenLineDrawingViewStyle, "Front")
' Create left projected view.
Set rightProjView = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, kFromBaseDrawingViewStyle, 1)
' Create top projected view.
Set topProjView = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint3, kFromBaseDrawingViewStyle, 1)
' Create isometric projected view.
Set isoProjView = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint4, kHiddenLineRemovedDrawingViewStyle, 1)
Else: End If
Next
End Sub
HI,
I guess one way could be checking the path of each document and compare it to the path of the content center files and library files folder.
You could get back those paths from the Application.DesignProjectManager.ActiveDesignProject object.
I hope this helps.
Cheers,