几何尺寸与公差论坛

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

【转帖】display the weight of a part in text bo

[复制链接]
发表于 2009-4-13 10:25:52 | 显示全部楼层 |阅读模式
display the weight of a part in text box
hi
i am trying to display the weight of a part in a text box of a form in my macro. can anybody help me? or just use the weight to multiply it by something. thanks in advance.
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
sub main()
dim swapp as sldworks.sldworks
dim part as sldworks.modeldoc2
dim mass as sldworks.massproperty
set swapp = application.sldworks
set part = swapp.activedoc
set mass = part.extension.createmassproperty
mass.usesystemunits = false
debug.print mass.mass
end sub
instead of using debug.print, you can assign the value of mass.mass to your textbox. the format is up to you. when i ran this, the mass was being extracted as grams. you can then use mass.mass in a formula if you like.
ex: yourtextboxnamehere.text = (mass.mass)/100
hope this helps.
tony szuta
cswa, cswp, cswp-smtl
thanks alot i will try that
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
it does exactly what i want it to when i run it as a seperate macro but when i run it as a module inside of a different macro then it gives me a compile error. any ideas?
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
what error exactly do you get and also post the code
problem was i did not have sw reference added in thanks luke!
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-24 09:03 , Processed in 0.034505 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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