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

selectbyid2 on edge
here's my problem. i'm creating a part automatically on the fly. i have all the geometry created. but when i have the code try to add some fillets by means of selectbyid2 and the entities i'm trying to select are hidden or behind other geometry the selectbyid2 doesn't select. but if i rotate the view and rerun the code it selects. is this an issue or bug or is there a better way of doing this? remember this part is being created on the fly automatically so no human interface can occur. any help would be greatly appreciated.
' rotate to part to back view for selection
for i = 0 to 22
swdoc.viewrotateplusy
i = i + 1
next i
itemstatusb = swmodeldocext.selectbyid2("", "edge", -(itempartjointwid / 2), 0, -(itempartjointthk / 2), false, 1, nothing, 0)
' debug.print itemstatusb
itemstatusb = swmodeldocext.selectbyid2("", "edge", 0, -(itempartjointhgt / 2), -(itempartjointthk / 2), true, 0, nothing, 0)
' debug.print itemstatusb
itemstatusb = swmodeldocext.selectbyid2("", "edge", -(itempartjointwid / 2), -(itempartjointhgt / 2), 0, true, 0, nothing, 0)
' debug.print itemstatusb
swfeatmgr.featurefillet 195, itempartjointrad, 0, 0, 0, 0, 0
cadcam systems analyst
-solidworks office premium 2009 sp3.0
-solidworks simulation premium 2009 sp3.0
-solidworks flow simulation 2009 sp3.0
-2 cpu (fx-62), 2.0 gb of ram
-window xp pro sp2
-nvidia geforce 7950 gx2 (512mb) 6.14.11.6921
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swpart as sldworks.partdoc
dim vbodyarr as variant
dim vbody as variant
dim swbody as sldworks.body2
dim nretval1 as long
dim nretval2 as long
dim vedgearr as variant
dim vedge as variant
dim swedge as sldworks.edge
set swapp = application.sldworks
set swmodel = swapp.activedoc
set swpart = swmodel
vbodyarr = swpart.getbodies2(swallbodies, true): debug.assert not isempty(vbodyarr)
for each vbody in vbodyarr
set swbody = vbody
debug.print " body[" & swbody.gettype & "] --> " & swbody.getselectionid
nretval1 = swbody.check ' obsolete method
nretval2 = swbody.check2 ' obsolete method
debug.print " body2::check (1 if valid; 0 if not) = " & nretval1
debug.print " body2::check2(number of faults) = " & nretval2
vedgearr = swbody.getedges
for each vedge in vedgearr
set swedge = vedge
swedge.select false
next vedge
next vbody
hi william,
i had the same issue and there's a simple solution to it!
in order to select edges and/or faces that are hidden you need to enable a couple of solidworks options found in:
tools-->options-->display/selection
there you'll find two check boxes undere the "selection of hidden edges" group box named "allow selection in wireframe and hlv modes"
"allow selection in hlr and shaded modes" these two boxes need to be checked.
now to do that with the code you need to use the following function calls:
swapp.setuserpreferencetoggle swuserpreferencetoggle_e.swedgeshiddenedgeselectioninwireframe, true
swapp.setuserpreferencetoggle swuserpreferencetoggle_e.swedgeshiddenedgeselectioninhlr, true
the code above will check the check boxes and allow you to select hidden edges.
by changing the boolean value to false it will uncheck the boxes.
hope this helps,
--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
answer ivana,
nice loop code to select each edge but one problem. you don't know what specific edge you have stored in the vedgearr. also wouldn't they change order based on how the geometry was constructed? thank you for some insight on capturing edges. i might need this later.
stav,
thank you, this is what i was looking for. i know what my targets are and know what direction they are in, just needed the selectbyid2 to know it's ok to select these edges/entities even if they are not visible. this will allow the code to select the edges no matter what order they were created in.
cadcam systems analyst
-solidworks office premium 2009 sp3.0
-solidworks simulation premium 2009 sp3.0
-solidworks flow simulation 2009 sp3.0
-2 cpu (fx-62), 2.0 gb of ram
-window xp pro sp2
-nvidia geforce 7950 gx2 (512mb) 6.14.11.6921
hi, may i know how can i change the name of line segment using api in any language or even macro.
within assembly or sketch part.
regards,
aqeel ahmed.
aqeel.ahmed@vvi.cc
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【求助】How to select a vertex of an edge if I aleady know the coordinate? slayerran SolidWorks二次开发 1 2009-01-14 03:12 PM
【转帖】图基本操作的实现 huangyhg 数学基础库 0 2008-10-27 11:46 AM
【转帖】如何实现两条edge的拼接? yogy ACIS 1 2007-06-06 11:22 AM


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


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