几何尺寸与公差论坛------致力于产品几何量公差标准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, 08:41 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】add custom properties

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


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】setting custom properties yang686526 SolidWorks二次开发 0 2009-04-12 10:24 PM
【转帖】macro for adding customconfiguration properties yang686526 SolidWorks二次开发 0 2009-04-12 09:37 PM
【转帖】is it possible to edit custom properties with a script outside of sw yang686526 SolidWorks二次开发 0 2009-04-12 09:30 PM
【转帖】setting custom properties yang686526 SolidWorks二次开发 0 2009-04-12 07:36 PM
【转帖】is it possible to edit custom properties with a script outside of sw yang686526 SolidWorks二次开发 0 2009-04-12 06:45 PM


所有的时间均为北京时间。 现在的时间是 02:16 PM.


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