查看单个帖子
旧 2009-04-12, 06:57 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】make drawing from active documen

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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)