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

part properties through drawing
does anyone know how to access custom properties of a part through a drawing?
i am writing some code which runs on a drawing but i also need to access some of the properties of the part/assembly that it references.
any ideas?
thanks
you will need to get a handle for the modeldoc2 object of the part in the view you are interested in.
i'll get you eh steve, if it's the last thing i dooooo!
then
swmodel.filesummaryinfo
that should bring it up the window to change the property settings.
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
thanks but i need to be able to access these programatically without user intervention.
i already have a handle for the modeldoc2 object but that is only enables me access to the properties of the drawing ifself not the part/assembly on the drawing.
you need to get a handle for the modeldoc2 object of the part in the view you are interested in. each view in a drawing points to a modeldoc2 object. each drawing document can have multiple sheets. each sheet can have multiple views all pointing to different parts/assemblies. how are you planning to handle that possibility? if you think it's not likely to happen in your case, you can probably get away with drawingdoc::getfirstview and then cycling through the views with view::getnextview until you find a view that returns a valid pointer to a modeldoc2 object from view::referenceddocument.
i'll get you eh steve, if it's the last thing i dooooo!
this is what i have so far...
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swselmgr as sldworks.selectionmgr
dim swview as sldworks.view
dim swdrawmodel as sldworks.modeldoc2
dim smodelname as string
set swapp = application.sldworks
set swview = swapp.activedoc.getfirstview
while not swview is nothing
debug.print " " & swview.getname2 & " [" & swview.type & "]"
set swview = swview.getnextview
wend
end sub
but it still refuses to work...i get to a drawing view and try to get the referenceddocument but it does not work....
any ideas?
thanks
just worked it out...little trickier than the help files made out but i got there in the end.
thanks to all who contributed
david:
i know you've already worked out a solution, but i thought i'd share this in case it might help someone else.
i use swmodelref.getdependencies2 and act upon the returned array. i assume the first referenced document is the intended one, so if there are more than one this may not work as expected. the following code snippet should work:
vdepend = swmodelref.getdependencies2(false, false, false)
if ubound(vdepend) = -1 then
vresponse = msgbox("no model is associated with this drawing", vbokonly)
shutdown (false)
end if
if right(vdepend(1), 6) = "sldprt" then
set swmodel = swapp.opendoc6(vdepend(1), swdocpart, swopendocoptions_silent, "", 0, 0)
elseif right(vdepend(1), 6) = "sldasm" then
set swmodel = swapp.opendoc6(vdepend(1), swdocassembly, swopendocoptions_silent, "", 0, 0)
else
vresponse = msgbox("invalid filetype is associated with this drawing", vbokonly)
shutdown (false)
end if
you could augment this to handle multiple references. for example, you could gather all of the filenames and prompt the user to choose one of them.
regards,
john.
sw 2007 sp5
optimist: "the glass is half full"
pessimist: "the glass is half empty"
engineer: "the glass is twice as big as it needs to be"
edited: 02/03/2009 at 01:42 pm by john manly
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】macro for adding customconfiguration properties yang686526 SolidWorks二次开发 0 2009-04-12 09:37 PM
【转帖】how to save to dxf in active drawing file location yang686526 SolidWorks二次开发 0 2009-04-12 09:23 PM
【转帖】how to save to dxf in active drawing file location yang686526 SolidWorks二次开发 0 2009-04-12 06:38 PM
如何得到MessageBox窗口里的提示文本? huangyhg vc编程 1 2008-07-24 01:07 AM
【转帖】续实例解析socket编程模型之异步通信篇 yogy C# 1 2007-08-01 03:01 PM


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


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