![]() |
【转帖】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 |
所有的时间均为北京时间。 现在的时间是 11:47 AM. |