![]() |
【转帖】求助:用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二次开发,从中寻觅人生乐趣! |
所有的时间均为北京时间。 现在的时间是 01:48 PM. |