几何尺寸与公差论坛------致力于产品几何量公差标准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-12, 09:49 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】modifying design table values with a macro

modifying design table values with a macro??
does anyone know of a way to use a macro to change the value of the cells in the design table?
for example... if i have a form where the user enters a value... say beam size... the macro will edit the cell of the design table that corresponds to the beam size and the design table can update the part.
my design tables are internal inside my solidworks part. what i'm having trouble with isn't the code to actually change the value of a cell, but how to access the cell that is inside the design table in the part so that i can change it.
christina,
look for 'modeldoc2::getdesigntable' in the api help. there are several examples.
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
there are several examples in there of how to access the design table... but nothing with how to get it to change the value of a cell and that's proving to be more problematic than i initially thought it would be.
any thoughts on how to get it to actually change the value of a cell and update the table??
hey christina,
modifying cells in design tables uses the same principles as doing so in excel.
i'll attach below a small code sample of how to do it and if you have more issues reply again here.
code:
'get the design table
set destable = modeldoc.getdesigntable()
'get the work sheet
set wsheet = destable.edittable2(true)
' assign values to cells
wsheet.cells(2, 2) = "a value"
wsheet.cells(2, 3) = "another value"
'close the table to update
modeldoc.closefamilytable
''''''''''''''''''
hope this helps,
cheers,
--stav.
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
edited: 11/10/2008 at 04:27 am by stavros antoniou
i want to do this as well.
i have already written all the code for the forms to modify the design table.
-----
the first attempt i did this....
part.insertfamilytableedit
set exapp = getobject(, "excel.application")
set exwb = exapp.workbooks.application.activeworkbook
set exws = exwb.worksheets(1)
.
.
.run all code with exws. to access work sheet
everything works fine until i close
i used
exapp.quit
when i did the changes would not affect the part. when i tried to reopen the design table it said "file not found"
-------
per your suggestion i tried
part.insertfamilytableedit
dim destable as designtable
set destable = swmodeldoc.getdesigntable()
set exws = destable.edittable2(true)
.
.
.
do stuff
.
.
swmodeldoc.closefamilytable
again i get the same problem where file not found if i try to open again and changes are not made to the design table.
any suggestions?
edit:
strange...i wrote a macro with two lines
set part = swapp.activedoc
part.closefamilytable
when i run this macro with design table open it worked properly
edited: 02/27/2009 at 12:54 pm by kevin hardin
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
Scheme 程序语言介绍之一 huangyhg 专家系统 6 2010-02-18 01:22 PM
【转帖】macro for general table yang686526 SolidWorks二次开发 0 2009-04-12 09:37 PM
【转帖】copy info from design table to seperate file yang686526 SolidWorks二次开发 0 2009-04-12 08:31 PM
【转帖】copy an existent sketch into a macro yang686526 SolidWorks二次开发 0 2009-04-12 08:31 PM


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


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