几何尺寸与公差论坛

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

【转帖】selectbyid2 on edge

[复制链接]
发表于 2009-4-12 22:20:49 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 19:33 , Processed in 0.036147 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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