![]() |
【转帖】macro to change the template for multiple drawing files
macro to change the template for multiple drawing files?
i have about 150 drawing files that need to be changed to have a new drawing template. some of the drawings have multiple sheets. does anyone have a macro that will batch change all of the drawing files? are you wanting to change the drawing template (.drwdot) or just the sheet format (.slddrt) ? thanks. really i could change either the template or the sheet format. all of the custom properties needed are in the parts/assemblies. i just need to add and remove certain properties from the drawings for a customer. now, how would be the best way to go about applying this macro to all of the files without going through each one manually? i was thinking it could be done in the solidworks task scheduler, but i seem to be missing how to run it for certain folders? one of these may also help. some of them change templates and/or sheet formats. was anyone able to get this problem solved for an entire folder of drawings? i have somewhere around 1200 that need the sheet format changed. thanks, matt mattbd, are you saying that none of the programs listed in the above faq worked for you? everything looked like it was specific to working with the currently open file. which one did you have in mind? i started a macro but am having trouble with the setupsheet4 function. -matt propagator from pac4swx_mac01.zip in conjunction with pac4swx, both from thanks cbl! i also want to learn, so if any vb/macro gurus can take a look at this and explain why i can't save the active document in my macro, i'd appreciate it. this is just meant to work - there's very little in the way of functionality or error handling. -matt code ' ****************************************************************************** ' chgfmt.swb - macro recorded on 08/11/08 by mdenardo ' ****************************************************************************** dim swapp as object dim part as object dim selmgr as object dim boolstatus as boolean dim longstatus as long, longwarnings as long dim feature as object dim mydir as string dim mysheet as string dim myfile as string sub main() set swapp = application.sldworks mydir = inputbox("enter the path that contains the files you want to change.") mysheet = inputbox("enter the full path, including file name and extension of the sheet format you want to use.") myfile = dir(mydir & "\*.slddrw") do while myfile <> "" myfile = dir() filename = split(myfile, ".") set part = swapp.opendoc6(mydir & "\" & myfile, 3, 0, "", longstatus, longwarnings) swapp.opendoc6 mydir & "\" & myfile, 3, 0, "", longstatus, longwarnings set part = swapp.activatedoc2(filename(0) & " - sheet1", false, longstatus) swapp.activedoc.activeview.frameleft = 0 swapp.activedoc.activeview.frametop = 0 swapp.activedoc.activeview.framestate = 1 swapp.activedoc.activeview.framestate = 1 boolstatus = part.extension.selectbyid2("sheet1", "sheet", 0.1391084233669, 0.2266029916164, 0, false, 0, nothing, 0) part.clearselection2 true part.setupsheet4 "sheet1", 12, 12, 1, 1, false, mysheet, 0.4318, 0.2794, "default" ', true part.viewzoomtofit2 retval1 = part.save3() set part = nothing swapp.closedoc filename(0) & " - sheet1" loop end sub hm. well, i solved it by changing that line to use the saveas method and gave it the same part name as the open part and that worked fine. no idea why save3 didn't work. code retval = part.saveas(mydir & "\" & myfile) |
所有的时间均为北京时间。 现在的时间是 09:56 AM. |