I need code for theMake Drawing from Assembly Command, is this possible? Thanksin advance.SolidworksApi macros
Comments1
SF
SF2009-01-07
Hi, Here are two ways I have used to create drawings. Have the assembly or part as the active document.
Scott
Dim swApp As SldWorks.SldWorks Dim Model As SldWorks.ModelDoc2 Dim Part As SldWorks.ModelDoc2 Dim CompPathName As String Dim DrawView As SldWorks.View
Sub main()
Set swApp = Application.SldWorks Set Model = swApp.ActiveDoc
'version 1-------------------------------------------------- 'run the actual SolidWorks commands******************************** swApp.RunCommand swCommands_MakeDrawingFromPartAssembly,"NewDrawingFromAssembly"
Here are two ways I have used to create drawings.
Have the assembly or part as the active document.
Scott
Dim swApp As SldWorks.SldWorks
Dim Model As SldWorks.ModelDoc2
Dim Part As SldWorks.ModelDoc2
Dim CompPathName As String
Dim DrawView As SldWorks.View
Sub main()
Set swApp = Application.SldWorks
Set Model = swApp.ActiveDoc
'version 1--------------------------------------------------
'run the actual SolidWorks commands********************************
swApp.RunCommand swCommands_MakeDrawingFromPartAssembly,"NewDrawingFromAssembly"
swApp.RunCommand swCommands_Standard3View, "Add3View"
SendKeys "{ENTER}", 2
Exit Sub
'end of SolidWorks commands*********************************
'version 2------------------------------------------------------
'have full control over views and locations using a knowntemplate*******
'get path of assembly or part
CompPathName = Model.GetPathName
'open new drawing with specified template
Set Part = swApp.NewDrawing2(14, "F:\Library\Templates\Universal Dsize drawing.DRWDOT", 4, 0, 0)
Set Part = swApp.ActiveDoc
'add views
Set DrawView = Part.CreateDrawViewFromModelView2(CompPathName,"*Back", 0.25, 0.3, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Drawing View1","DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
Set DrawView = Part.CreateUnfoldedViewAt3(0.5, 0.3, 0, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Drawing View2","DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
Set DrawView = Part.CreateUnfoldedViewAt3(0.7, 0.3, 0, 0)
Part.ClearSelection2 True
End Sub