|
setunits for a part or assembly
hi all,
my api skills are a little rusty, and i need some help. i have a bunch of parts and assemblies that we want to change from imperial to metric. i've been trying to get the following command to work , but keep getting various errors, according to how i have it coded
sub main()
dim swapp as sldworks.sldworks 'the solidworks model
dim model_tm as sldworks.modeldoc2
dim userunit as sldworks.userunit 'defines the userunit
dim computedvalue as double
dim un as boolean
dim retval_units as variant
un = true
set swapp = getobject(, "sldworks.application") 'grabs connection to sw (assuming sw is already running)
set model_tm = swapp.activedoc 'grabs the active document (assumes there is one)
set userunit = swapp.getuserunit(0)
retval_units = model_tm.getunits()
metric = userunit.ismetric()
'problem line
duh = model_tm.setunits(0, 0, 16, 2, false)
'''''
exitsub:
set userunit = nothing
set modeldoc = nothing
set swapp = nothing
end sub
the error i usually get is "complie error: expected funtion or variable"
thanks for any help
tom
howdy,
not sure if this will help.
hi tobin,
thanks for the macro. that is basically what i did, as i had used teh setuserpreferences in another macro,and actually added some more codes...
'duh = model_tm.setunits(0, 0, 16, 2, false)
retval = model_tm.setuserpreferenceintegervalue(swunitslinear, 0) ' to millimeters
retval = model_tm.setuserpreferenceintegervalue(swunitslineardecimaldisplay, 1) ' to decimal display
retval = model_tm.setuserpreferenceintegervalue(swunitslineardecimalplaces, 2) ' number of decimal places
retval = model_tm.setuserpreferenceintegervalue(swdetailingdimtrailingzero, 1) ' show trailing zeros
'now for dual units..
retval = model_tm.setuserpreferenceintegervalue(swunitsduallinear, 3) ' to inches
retval = model_tm.setuserpreferenceintegervalue(swunitsduallineardecimaldisplay, 1) ' to decimal display
retval = model_tm.setuserpreferenceintegervalue(swunitsduallineardecimalplaces, 2) ' number of decimal places
i was hoping to use the setunits command, as it seem to be less work, but alas...
thanks again,
tom
hey tom,
i like your additions, very nice.
tobin sparks
.nov.com
quick |
|