|
make drawing from active document
i need code for the make drawing from assembly command, is this possible? thanks in advance.
adrian velazquez
cswp
cswp-smtl
solidworks x64 2009 sp3.0
nvidia quadro fx 570
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"
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 known template*******
'get path of assembly or part
comppathname = model.getpathname
'open new drawing with specified template
set part = swapp.newdrawing2(14, "f:\library\templates\universal d size 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
quick |
|