几何尺寸与公差论坛

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

【转帖】line name

[复制链接]
发表于 2009-4-12 21:33:53 | 显示全部楼层 |阅读模式
line name
how can i retrieve the line name that is created below.
l2 = part.createline2(0, 0, 0, 0.05, 0, 0) ' create line
and also how can i change its name late.
regards,
aqeel ahmed
aqeel.ahmed@live.com
l2 would be a pointer to a linesegment object not a string name. lines do not have names to change
thanx sir,
but when u right click on line segment it shows u an attribute as the "selected entity(line name)" how can we change that name or how can v get that attribute.
regards,
option explicit
sub main()
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swsketchtext as sldworks.sketchtext
dim swsketchsegment as sldworks.sketchsegment
dim swselmgr as sldworks.selectionmgr
dim vid as variant
dim sname as string
' connect to solidworks
set swapp = application.sldworks
' get active document
set swmodel = swapp.activedoc
set swselmgr = swmodel.selectionmanager
if swselmgr.getselectedobjectcount = 0 then
msgbox "select line"
else
select case swselmgr.getselectedobjecttype3(1, -1)
case swselsketchsegs
set swsketchsegment = swselmgr.getselectedobject6(1, -1)
select case swsketchsegment.gettype
case swsketchline
sname = "line"
case swsketcharc
case swsketchellipse
case swsketchspline
case swsketchtext
case swsketchparabola
end select
vid = swsketchsegment.getid
sname = sname & vid(1)
msgbox sname
swmodel.clearselection2 true
bret = swmodel.extension.selectbyid2(sname, "sketchsegment", 0, 0, 0, false, -1, nothing, 0)
end select
end if
end sub
again it is not a name it is just a persistent id and cannot be changed. as shown in the example above that name is just the id prepended with a string. the only persistent ids you can change are that of imported body edges.
it is the text which you see when you right clickt a line, or in selection box, or can use with selectbyid2.
and you can't change it.
thanx guys i got the way to keep the name with me for all time so that when ever i want to get any line segment with my own name i can.
may b that will help u .
i am keeping the line index(pointer to line in my xml fine with my own name so ) when ever i need e.g line1 that i have saved as horizontal line tage i just get it and it give me the pointer to exact the same line where i want to do some more customizations.
but, if u think there are other nice and short ways plz let me know.
regards,
aqeel
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-1-11 10:37 , Processed in 0.039039 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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