几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   SolidWorks二次开发 (http://www.dimcax.com/hust/forumdisplay.php?f=111)
-   -   【转帖】make drawing from active documen (http://www.dimcax.com/hust/showthread.php?t=4529)

yang686526 2009-04-12 06:57 PM

【转帖】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


所有的时间均为北京时间。 现在的时间是 01:03 AM.