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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-12, 06:55 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】macro to do not save the part, drawing and assembly

macro to do not save the part, drawing and assembly
i wonder if somebody has a macro to do not save the part, drawing and assembly.
thanks in advance.
maperalia
that's something a strange requirement. may i ask why you looking for such kinda macro...
deepak gupta
sw2007 sp5.0
sw2009 sp2.1
would a macro to open the file read-only be acceptable?
jeff sweeney, cswp
sw user since '96
deepak;
thanks for your quick response. you are absolute right. in fact, it is a strange requirement.
the reason that i am looking for this macro is because i have a sw file which has a part1, assembly1 and drawing1 that i am using them as a template. basically, this what i am doing:
1.- the macro updated the dimensions of my part1.then the assembly1 and drawing1 absorbe these changes.
2.- i "save as" the part1, assembly1 and drawing1 under other revision part2, assembly2, drawing2).
3.- close the previous files (part1,assembly1 and drawing1)
the problem is that when i close the template files (part1,assembly1 and drawing1). the template files keep the updated dimensions. i just want the macro to close them without changes.
i have tried to use sw template files (drwdot). however, i can't insert any drawing view in the template drawing.
in addition, i setup files as a read only in properties. however, i do not like the fact that i am getting the windows message that the file is read only and i have to click ok. if there were a way to open these files as a read only wihout getting the windows message i mentioned would be great. but i do not know how to do it.
my statement i have to close the part file is the following:
set part = swapp.activedoc
set part = nothing
debug.print "closing: " + "template.sldprt"
swapp.quitdoc "template.sldprt"
do you think there is a statement to close this file without saving it or get a window message mentioned above?
thanks.
maperalia
edited: 01/03/2009 at 02:08 am by mapea ralia
jeff;
i would accept a macro that open the file as a read only.
could you please provide me with an example.
kind regards.
maperalia
i don't know if it is sw bug or feature or if it is only with sw on my pc. if i have filename with an extra dot (name.number.sdlprt), file is allways read only. for me was it bug, for you maybe feature.
edited: 01/03/2009 at 07:26 pm by ivana kolin
ivon;
thanks for the informatiom. however, i changed my filename as you mentioned and it is not working as a read only in my pc.
kind regards.
maperalia
just open the original files read-only like so:
dim fileerror as long, filewarning as long
swapp.opendoc6 "d:\myfile.sldprt", swdocpart, swopendocoptions_silent or swopendocoptions_readonly, "", fileerror, filewarning
luke;
thanks for the code. even though, the read only is working it is blocking the statements in my module which does the "rebuilt" and "save as".
could you please tell me if i have missed something?
thanks.
maperalia
hi,
this works for me.
have the part, assembly, and drawing open with the part as the active document.
dim swapp as sldworks.sldworks
dim part as sldworks.modeldoc2
dim boolstatus as boolean
dim longstatus as long, longerrors as long, longwarnings as long
sub main()
set swapp = application.sldworks
'start with the part----------
set part = swapp.activedoc
'do something with the part
part.editrebuild3
part.clearselection2 true
part.saveas4 "c:\junk\2009part1-2.sldprt", 0, 0, longerrors, longwarnings
swapp.closedoc "2009part1-2.sldprt"
set part = nothing
'next the assembly------------------
swapp.activatedoc2 "2009testassem1.sldasm", false, longstatus
set part = swapp.activedoc
part.saveas4 "c:\junk\2009testassem1-2.sldasm", 0, 0, longerrors, longwarnings
swapp.closedoc "2009testassem1-2.sldasm"
set part = nothing
'finally the drawing-------------
swapp.activatedoc2 "2009testassem1 - sheet1", false, longstatus
set part = swapp.activedoc
part.saveas4 "c:\junk\2009testassem1-2.slddrw", 0, 0, longerrors, longwarnings
swapp.closedoc "2009testassem1-2 - sheet1"
set part = nothing
end sub
scott;
thanks for the code. i really appreciate it.
correct if i am wrong.
1.-you said that this code allow you to "save as" the sw files without changing the previous files.
2.- what sw version are you using?
3.- what do you 'part.saveas4 " i have "part.saveas2 " instead.
kind regards.
maperalia
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多