几何尺寸与公差论坛------致力于产品几何量公差标准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-13, 12:39 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】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)
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】change a drawing views display state yang686526 SolidWorks二次开发 0 2009-04-13 09:36 AM
【转帖】can you modelize a drawing view yang686526 SolidWorks二次开发 0 2009-04-13 09:31 AM
【转帖】bulk change descriptions for files in the vaul yang686526 SolidWorks二次开发 0 2009-04-13 09:23 AM
【转帖】macro to do not save the part, drawing and assembly yang686526 SolidWorks二次开发 0 2009-04-12 06:55 PM


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


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