几何尺寸与公差论坛

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

【转帖】save to custom properties

[复制链接]
发表于 2009-4-13 14:05:55 | 显示全部楼层 |阅读模式
save to custom properties
i am having a little bit of trouble with this code, it is suppose to save a certain value to the custom properties and display the same result in a text box on the form. the saving it to the custom properties is not happening i get no error but it does not save it the showing it in a terxt box is working though can someone see the problem:
if length and width > height then
retval = true
'remove existing properties
retval = part.deletecustominfo2(configname, "width")
retval = part.deletecustominfo2(configname, "length")
'add latest values
retval = part.addcustominfo3(configname, "width", swcustominfonumber, width)
retval = part.addcustominfo3(configname, "length", swcustominfonumber, length)
'display width and lenght in textbox
userform1.txtboundingbox.text = width & " x " & length
elseif width and height > length then
'remove existing properties
retval = part.deletecustominfo2(configname, "height")
retval = part.deletecustominfo2(configname, "width")
'add latest values
retval = part.addcustominfo3(configname, "height", swcustominfonumber, height)
retval = part.addcustominfo3(configname, "width", swcustominfonumber, width)
'display width and lenght in textbox
userform1.txtboundingbox.text = width & " x " & height
elseif height and length > width then
'remove existing properties
retval = part.deletecustominfo2(configname, "height")
retval = part.deletecustominfo2(configname, "length")
'add latest values
retval = part.addcustominfo3(configname, "height", swcustominfonumber, height)
retval = part.addcustominfo3(configname, "length", swcustominfonumber, length)
'display width and lenght in textbox
userform1.txtboundingbox.text = height & " x " & length
else
exit sub
end if
end sub
any replies will be appreciated.
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
i didn't get to put much thought into your code yet, but before you are closing the part, are you saving it?
part.save2 (false)
also, i don't believe that you don't need to delete the custom property before overwriting it.
tony szuta
cswa, cswp, cswp-smtl
so far i just leave the part open and the code is just suppose put the data in the custom properties and then do nothing with it. i will try it with out the delete property for overwriting it. thanks
one weird thing i took the exact code and put it in a new macro and then it works just fine this is very strange to me.
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
edited: 09/19/2008 at 12:36 pm by ben guenther
i tried removing the delete code it made no difference i tried putting in the part.save2 (false) and it saved the part just like it should but the properties are still empty. not sure if it would have anything to do with it but i am calling that code from a different module. the macro has 2 modules and one form.
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
if run the code in a new macro with no forms then swcustominfonumber = 3
if i run the code in the original macro then it = empty
but i can't figure out why or if this is the problem.
any suggestions?
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
the problem is you have not included the solidworks constants library in your macro, so swcustominfonumber is just an undefined variable. tools->references and add the reference and it will work

edited: 09/26/2008 at 04:31 am by luke malpass
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 04:39 , Processed in 0.035829 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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