几何尺寸与公差论坛

 找回密码
 注册
查看: 622|回复: 0

【转帖】setunits for a part or assembly

[复制链接]
发表于 2009-4-13 14:15:30 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-22 23:54 , Processed in 0.036054 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表