几何尺寸与公差论坛

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

【转帖】add custom properties

[复制链接]
发表于 2009-4-13 08:41:36 | 显示全部楼层 |阅读模式
add custom properties
hi all,
i have yrs of programing in vb6 and inventor vba; howver, am just a newbie here
i got this code from matthew lorono and it works great so far
my question is: if i open a new file with no custom property, how to change the program to create these 7 custom properties?
thx, chris
sub main()
set swapp = createobject("sldworks.application")
set currentdoc = swapp.activedoc
set part = swapp.activedoc
' no document loaded error handler
if part is nothing then
msgbox "no document loaded!", vbcritical
end
else
end if
part.clearselection2 true
' assign custom properties
propname(0) = "number"
propname(1) = "description"
propname(2) = "current revision"
propname(3) = "originator"
propname(4) = "drawn date"
propname(5) = "finish"
propname(6) = "material"
' add custom properties (won't overwrite if they already exist)
prop = currentdoc.addcustominfo3("", propname(0), swcustominfotext, " ")
prop = currentdoc.addcustominfo3("", propname(1), swcustominfotext, " ")
prop = currentdoc.addcustominfo3("", propname(2), swcustominfotext, " ")
prop = currentdoc.addcustominfo3("", propname(3), swcustominfotext, " ")
prop = currentdoc.addcustominfo3("", propname(4), swcustominfotext, " ")
prop = currentdoc.addcustominfo3("", propname(5), swcustominfotext, " ")
prop = currentdoc.addcustominfo3("", propname(6), swcustominfotext, " ")
msgbox "check ok here"
call checkprops
end sub
solidworks 2007 (office pro.) sp5.0
testing solidworks 2009 (pro) sp0.0
dell precision t3400
2 cpu (8500) 3.16 ghz, 3.25 gb of ram
window xp pro sp2
nvidia fx 570 6.14.11.6262
this will automatically create the custom properties when you run the macro. just run the macro on your drawing and/or part model templates, then save the templates. any new parts will come in with the custom props already created.
for any existing files, you can just run the macro and save (no values needed).
matt lorono
solidworks 2007 sp3.1
cad engineer/ecn analyst
thanks for a quick response, matt
i got it working now
thx, chris
solidworks 2007 (office pro.) sp5.0
testing solidworks 2009 (pro) sp0.0
dell precision t3400
2 cpu (8500) 3.16 ghz, 3.25 gb of ram
window xp pro sp2
nvidia fx 570 6.14.11.6262
edited: 04/16/2008 at 04:22 pm by chris ch
can someone tell me how to manually add custome properties so that they are selectable from the pull down menu in the summary information window under file>properties?
that is found in the c:\program files\solidworks\lang\english\properties.txt file. open the txt file and add what ever you want.
make sure that this is where your list is reading from. do this by selecting tools>options>file locations. there will be a path here for the properties.txt file. hope this helps.
tony szuta
cswa, cswp, cswp-smtl
i'm not sure if you were aware of this
but if you run this macro and use the x in the corner to close the window
then all custom properties values are deleted
thx, chris
solidworks 2007 (office pro.) sp5.0
testing solidworks 2009 (pro) sp0.0
dell precision t3400
2 cpu (8500) 3.16 ghz, 3.25 gb of ram
window xp pro sp2
nvidia fx 570 6.14.11.6262
it's not that they are deleted per se. they are simply not created if they already don't exist.
matt lorono
solidworks 2007 sp3.1
cad engineer/ecn analyst
hi matt,
i tested the program many times. every button works fine.
however, when i tried to use the x button in the form's corner to quit (exit) the program, all the file properties values are wiped out.
thx, chris
solidworks 2007 (office pro.) sp5.0
testing solidworks 2009 (pro) sp0.0
dell precision t3400
2 cpu (8500) 3.16 ghz, 3.25 gb of ram
window xp pro sp2
nvidia fx 570 6.14.11.6262
i'm not experiecing what you are describing. are you saying that once the properties are established, they are being deleted? if so, this isn't how the macro functions at all. i would have to actually add code to the x button for it to do that. i have tested this scenerio on my system. let me look into this further. in the meantime, just use the cancel button.
matt lorono
solidworks 2007 sp3.1
cad engineer/ecn analyst
thanks for a quick response, matt.
the cancel button works correctly as well as all the buttons on the macro
as a habit, i sometimes used the x button to exit the program and got all the values wipted out.
chris
solidworks 2007 (office pro.) sp5.0
testing solidworks 2009 (pro) sp0.0
dell precision t3400
2 cpu (8500) 3.16 ghz, 3.25 gb of ram
window xp pro sp2
nvidia fx 570 6.14.11.6262
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-24 02:16 , Processed in 0.035951 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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