几何尺寸与公差论坛------致力于产品几何量公差标准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, 01:38 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】proccessing multiple files with api

proccessing multiple files with api
i would like to add a list of user selected files to a macro but i'm not sure where to start re achieving this goal, essentially to extend a save as pdf etc macro to more than one file. i have used the task manager but would like to add in the current revison etc.
any suggestions, example macros (i have been looking but none to date), and/or suggested reading
thanks
john
john fisher
there are many ways to do this. what do you have in mind for a process?
if you already have a macro for saving a single file, make that entire code into a module/method/function that accepts a filename as a variable, and then you can simply change the part of the code that asks the user for the filename and replace it with the variable passed in. then in the main code ask the user for the files (using a list where they can add files one at a file, select mutliple, or select a folder), and then with that list simply loop each file in a for loop and pass it into the function.
there are however another 100 ways to achieve this goal but it all depends on your preference and requirements.
i see two scenerios both while running solidworks (note i'm quite new to api)
open a dwg in solidworks
initiate the macro
the macro would then loop through all the files in the currently directory of drawingdoc type
or when wanting to select a range of files (from a large directory)
initiate the macro
enter required files in a list box
start the print/export process via a button
re using a list box, is it possible to define an array with a variable (driven by the number of selections) then use an if - next loop to process?
thanks for your input
john fisher
this reply is a little late, but if you would like to process a directory for all files in the directory, here's my fav. code snippet. you'll need to add a referenc to microsoft scripting runtime library. this code is vb6 (macro flava), but it ports well to .net if needed.
dim mypath as string
mypath = "c:\temp\" 'set to desired folder to process
dim fso as scripting.filesystemobject
set fso = createobject("scripting.filesystemobject")
dim myfiles as scripting.files
set myfiles = fso.getfolder(mypath).files
dim myfile as scripting.file
for each myfile in myfiles
'process the file here...
debug.print myfile.name
debut.print myfile.path
next myfile
mike spens
"automating solidworks using macros"
leap frog leap pad x64
this thread comes at the right time for me i'm looking for something that saves all the drawing document in a folder as pdf file. if any one got something pleas post it if possible
mohamed abdel moniem | mechanical engineer
cswp, cswa, cswp core, cswp-smtl
solidworks 2009 sp3.0
vista x64 sp1.0
intel q6600, 8gb ram
ati hd 4850
3dconnexions spacenavigator
all you'll need is the following additional code to upen the drawing, then save it as a pdf. add this in the for loop of the code earlier in the thread.
'===========
dim pathsize as long
dim pathnoextension as string
dim newfilepath as string
pathsize = strings.len(myfile.path)
pathnoextension = strings.left(filepath, pathsize - 6) 'remove extension
newfilepath = pathnoextension & "pdf"
dim mydoc as sldworks.modeldoc2
dim longerrors as long
dim longwarnings as long
set mydoc = swapp.opendoc6(myfile.path, swdocdrawing, _
swopendocoptions_silent, "", longerrors, longwarnings)
mydoc.saveas2 newfilepath, 0, true, false
swapp.closedoc mydoc.gettitle
'===========
**i don't have the declaration or attachment to swapp in this code, so make sure it is in your macro.
if you want to filter drawings, you can check myfile.extension to see if it is slddrw before opening and saving as pdf.
mike spens
"automating solidworks using macros"
leap frog leap pad x64
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】multiple file selection in macro yang686526 SolidWorks二次开发 0 2009-04-13 12:58 PM
【转帖】macro to change the template for multiple drawing files yang686526 SolidWorks二次开发 0 2009-04-13 12:39 PM
【转帖】importing multiple sat files into one assembly yang686526 SolidWorks二次开发 0 2009-04-13 12:12 PM
【转帖】外挂开发中的封包技术 huangyhg vc编程 0 2007-12-03 04:41 PM
【转帖】对于hook函数的一点认识 huangyhg vc编程 0 2007-03-27 11:53 AM


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


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