![]() |
【转帖】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 |
所有的时间均为北京时间。 现在的时间是 11:11 PM. |