几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-04-13, 02:05 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】save to custom properties

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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】custom properties yang686526 SolidWorks二次开发 0 2009-04-13 10:09 AM
【转帖】custom properties for multiple part configurations yang686526 SolidWorks二次开发 0 2009-04-13 10:08 AM
【转帖】add custom properties yang686526 SolidWorks二次开发 0 2009-04-13 08:41 AM
【转帖】macro for adding customconfiguration properties yang686526 SolidWorks二次开发 0 2009-04-12 09:37 PM
【转帖】setting custom properties yang686526 SolidWorks二次开发 0 2009-04-12 07:36 PM


所有的时间均为北京时间。 现在的时间是 03:59 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多