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

save as step
i have this macro (which was a saves as iges file) that i want to use to save a step file. i want to save as version ap214. can this be done?
here is the current code
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 fs as new filesystemobject
dim name as string
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
set selmgr = part.selectionmanager
name = fs.getbasename(part.getpathname)
part.saveas2 "c:\step files\" & name & ".step", 0, true, false
step.show
end sub
rob jensen
southern mn solidworks user group leader
make sure to include this line
sldworks.setuserpreferencevalue(swstepap, 214)
solidworks 2007 (office pro.) sp5.0
testing solidworks 2009 (pro) sp0.0
dell precision t3400
2 cpu (8500) 3.16 ghz, 3.25 gb of ram
window xp pro sp2
nvidia fx 570 6.14.11.6262
from the api help,
sldworks.getuserpreferenceintegervalue (swstepap,214)
this should work though i have not tested it.
kevin kenny, cswp
sw 2009 sp3.0
hp xw4300
originally posted by: kevin kenny
from the api help,
sldworks.getuserpreferenceintegervalue (swstepap,214)
this should work though i have not tested it.
i don't think this will work. "get" should say "set"
if you wanted to get the current setting you would use getuserpreferenceintegervalue like this
retval = sldworks.getuserpreferenceintegervalue ( swstepap)
you could use that to store the original value, and then after saving the file return the systems settings back to the original state.
drc inc.
minneapolis, mn
.designreadycontrols.com
sw2007 sp5.0
core2 quad
3gb ram
xp pro sp2
ati firegl v3600
thanks!!
i'm not good at writing code, so the next question is where do i put this line? i've tried adding it and i get a error.
rob jensen
southern mn solidworks user group leader
hi rob,
what error do you get?
i'd say it should go anywhere after the line where you set your swapp object.
after this line:
set swapp = application.sldworks
make sure that you type swapp.setuserpreferenceintegervalue(swstepap, 214)
as thats what you define your sldworks object to be.
cheers,
--stav.
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
edited: 07/15/2008 at 09:01 am by stavros antoniou
nothing seems to be working....
i get a compile error: expected: = (whatever that means)
when i hover my mouse over the code string, it says name = ""
i'm going to be taking clasees this fall in vb, so i hope that will help be right some better api....
rob jensen
southern mn solidworks user group leader
rob, i don't know much vba or programming in general, but i got this to work. it saves the file to the current directory, but probably could be changed easily to a specific folder you want.
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 step as long
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
set selmgr = part.selectionmanager
step = swapp.setuserpreferenceintegervalue(swstepap, 214)
spathname = part.getpathname
spathname = left(spathname, len(spathname) - 6)
spathname = spathname + "step"
part.saveas2 spathname, 0, true, false
end sub
drc inc.
minneapolis, mn
.designreadycontrols.com
sw2007 sp5.0
core2 quad
3gb ram
xp pro sp2
ati firegl v3600
hi rob,
i have written a small macro of what i think you might be after. this successfully saves as step.
try it and change it to work as you want it to.
cheers,
--stav.
dim swapp as sldworks.sldworks
dim modeldoc as sldworks.modeldoc2
dim name as string
dim retval as boolean
dim errors as long, warnings as long
sub main()
set swapp = application.sldworks
set modeldoc = swapp.activedoc
'get the title of the active document
name = modeldoc.gettitle
'chop the extension off (make sure you have saved the document at least once i.e. it has a file extension)
name = left(name, len(name) - 7)
'change the step file options
retval = swapp.setuserpreferenceintegervalue(swuserpreferenceintegervalue_e.swstepap, 214)
'save
retval = modeldoc.extension.saveas("c:\step files\" & name & ".step", swsaveasversion_e.swsaveascurrentversion, swsaveasoptions_e.swsaveasoptions_silent, nothing, errors, warnings)
end sub
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
thanks guys...!
rob jensen
southern mn solidworks user group leader
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】inserting and mating parts in an assembly yang686526 SolidWorks二次开发 0 2009-04-12 06:43 PM
step标准QQ群:8569767 huangyhg STEP Standards 6 2008-09-25 05:04 PM
Example - a basic calculation on uncertainty yogy 坐标测量机 0 2007-07-22 05:26 PM


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


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