|
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 |
|