几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】solidworks api help - saving a par (http://www.dimcax.com/hust/showthread.php?t=5759)

yang686526 2009-04-13 02:29 PM

【转帖】solidworks api help - saving a par
 
solidworks api help - saving a part
hey guys,
can anyone tell me why this code is not saving my part?
pdirectory = "m:\solidworks\tooling\inspect\" & tooltbx.text & "\" & tooltbx.text & ".sldprt"
if msgbox("save as " & pdirectory & "?", vbokcancel, "confirm save") = vbok then
part.extension.saveas pdirectory, 0, 2, nothing, longstatus, longwarnings
if msgbox("make a drawing?", vbokcancel, "create drawing?") = vbcancel then
end
end if
else
exit sub
end if
find a job or post a job opening
hey, guy!
can you tell us what sort of thing actually does happen?
-handleman, cswp (the new, easy test)
i figured it out. as is, the code does absolutely nothing. i changed the save command and added some code that created the appropriate folder if it does not exist and that solved my problems. here is that code if you were wondering.
folder = "m:\solidworks\tooling\inspect\" & tooltbx.text
set fso = createobject("scripting.filesystemobject")
if not fso.folderexists(folder) then
fso.createfolder (folder)
end if
pdirectory = "m:\solidworks\tooling\inspect\" & tooltbx.text & "\" & tooltbx.text & ".sldprt"
if msgbox("save as " & pdirectory & "?", vbokcancel, "confirm save") = vbok then
part.saveas2 pdirectory, 0, false, false
if msgbox("make a drawing?", vbokcancel, "create drawing?") = vbcancel then
end
end if
else
exit sub
end if


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