几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(VB.NET/C#)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-21, 04:31 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】求助:用vb.net获取选择的直线,多段线等的坐标

求助:用vb.net获取选择的直线,多段线等的坐标
www.dimcax.com
求助:用vb.net获取选择的直线,多段线等的坐标
书中没有用vb.net获取选择的直线,多段线等的坐标
'我想修改下书中的例子,把多段线的坐标输出到文本,请帮我改下
<commandmethod("testfilsel")> public sub testselection3()
dim db as database = hostapplicationservices.workingdatabase
dim ed as editor = application.documentmanager.mdiactivedocument.editor
' 新建文本文件或对其改写其内容.
dim textfile as new streamwriter("c:\3.txt", false)
' 关闭该文本文件.
textfile.close()

'定义过滤条件
dim value1 as typedvalue = new typedvalue(dxfcode.start, "polyline")
dim value2 as typedvalue = new typedvalue(dxfcode.layername, "0")
dim values() as typedvalue = {value1, value2}
dim sfilter as new selectionfilter(values)
' 定义一个选择集交互类.
dim optsel as new promptselectionoptions
' 选择操作时的提示文本.
optsel.messageforadding = "请选择位于0层的多段线"
' 返回选择集的用户提示类.
dim ressel as promptselectionresult = ed.getselection(optsel, sfilter)
' 得到选择集对象.
dim sset as selectionset = ressel.value
' 得到选择集中所有对象的objectid集合.
dim ids as objectid() = sset.getobjectids()
using trans as transaction = db.transactionmanager.starttransaction()
' 遍历选择集.
for each ssetentid as objectid in ids
...........
dim x() as double
dim y() as double
dim z() as double
dim i as integer
dim count as integer
for i = 0 to ...... step 1
count = i
redim preserve x(i)
redim preserve y(i)
redim preserve z(i)
x(i) = returnobj.coordinate(i)(0)
y(i) = returnobj.coordinate(i)(1)
z(i) = returnobj.elevation
count=count+1

dim str as string = x(i)& "," & y(i)& "," & z(i)& vbcrlf
' 向文本文件写入一和行文本.
my.computer.filesystem.writealltext("c:\3.txt", str, true)
next i
next ssetentid
trans.commit()
end using
end sub
dim db as database = hostapplicationservices.workingdatabase
dim ed as editor = application.documentmanager.mdiactivedocument.editor
' 新建文本文件或对其改写其内容.
dim textfile as new streamwriter("c:\4.txt", false)
'定义过滤条件
dim value1 as typedvalue = new typedvalue(dxfcode.start, "polyline")
dim value2 as typedvalue = new typedvalue(dxfcode.layername, "0")
dim values() as typedvalue = {value1, value2}
dim sfilter as new selectionfilter(values)
' 定义一个选择集交互类.
dim optsel as new promptselectionoptions
' 选择操作时的提示文本.
optsel.messageforadding = "请选择位于0层的多段线"
' 返回选择集的用户提示类.
dim ressel as promptselectionresult = ed.getselection(optsel, sfilter)
' 得到选择集对象.
dim sset as selectionset = ressel.value
' 得到选择集中所有对象的objectid集合.
dim ids as objectid() = sset.getobjectids()
using trans as transaction = db.transactionmanager.starttransaction()
dim linenum as integer = 0
dim linetext as string = ""
' 遍历选择集.
for each ssetentid as objectid in ids
dim plineobject as polyline3d = trans.getobject(ssetentid, openmode.forread)
linenum = linenum + 1
linetext = "线号" & linenum.tostring("000") & vbtab
dim pointnum as integer = 0
for each vertexid in plineobject
dim ve as polylinevertex3d = trans.getobject(vertexid, openmode.forread)
dim pointcoor = ve.position
pointnum = pointnum + 1
dim outtext as string = linetext & "点号" & pointnum.tostring("000") & vbtab
outtext = outtext & "x:" & pointcoor.x.tostring("0.0000") & vbtab
outtext = outtext & "y:" & pointcoor.y.tostring("0.0000") & vbtab
outtext = outtext & "z:" & pointcoor.z.tostring("0.0000")
textfile.writeline(outtext)
next
textfile.writeline()
next ssetentid
trans.commit()
end using
' 关闭该文本文件.
textfile.close()
end sub
复制代码
继续研究学习cad二次开发,从中寻觅人生乐趣!
线号001 点号001 x:2439.5533 y:1316.7224 z:0.0000
线号001 点号002 x:2292.7747 y:1286.0166 z:0.0000
线号001 点号003 x:2169.8902 y:1144.4286 z:0.0000
线号001 点号004 x:2060.6596 y:967.0171 z:0.0000
线号001 点号005 x:1821.7176 y:866.3702 z:0.0000
线号001 点号006 x:2321.1666 y:851.1874 z:0.0000
线号001 点号007 x:2209.1450 y:716.2528 z:0.0000
线号001 点号008 x:2490.7552 y:804.9585 z:0.0000
线号001 点号009 x:2548.7840 y:842.4879 z:0.0000
线号001 点号010 x:2635.8271 y:1004.5464 z:0.0000
线号002 点号001 x:557.3991 y:2068.3304 z:0.0000
线号002 点号002 x:410.6204 y:2037.6246 z:0.0000
线号002 点号003 x:287.7359 y:1896.0366 z:0.0000
线号002 点号004 x:178.5053 y:1718.6251 z:0.0000
线号002 点号005 x:-60.4367 y:1617.9782 z:0.0000
线号002 点号006 x:-186.7346 y:1594.0959 z:0.0000
线号002 点号007 x:211.3651 y:1090.8894 z:0.0000
线号002 点号008 x:608.6009 y:1556.5666 z:0.0000
线号002 点号009 x:666.6297 y:1594.0959 z:0.0000
线号002 点号010 x:753.6728 y:1756.1545 z:0.0000
继续研究学习cad二次开发,从中寻觅人生乐趣!
本人对vb.net不熟,改得不好,请多指教
继续研究学习cad二次开发,从中寻觅人生乐趣!
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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



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


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