282765582 发表于 2008-6-27 11:48:00

怎么把图上n个点的坐标读取并输出到Txt或者excel?

<p>请教各位大虾</p><p>怎么把图上n个点的坐标读取并输出到Txt或者excel?</p>

www2002 发表于 2008-7-2 12:42:00

偶也想知道

yxp 发表于 2008-7-3 13:48:00

<p>这些点的坐标有什么特征?</p><p>是坐标值,还是一些直线或者点?</p>

yeqb4749659 发表于 2008-7-8 10:26:00

用getpoint循环读出点坐标

rark123 发表于 2008-7-8 20:57:00

<p>(defun c:dd (/ ss m n file file_obj VERTEX) ;将POLYLINE的点写入文件writefile<br/>&nbsp; (setvar "cmdecho" 0)<br/>&nbsp; (if (and (setq ss (ssget '((0 . "polyline"))))<br/>&nbsp;&nbsp;&nbsp; (setq file (getfiled "写polyline的点表" "" "txt" 1))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp; (progn<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (command "undo" "g")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq file_obj (open file "w")<br/>&nbsp;&nbsp;&nbsp;&nbsp; m&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (sslength ss)<br/>&nbsp;&nbsp;&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (repeat m<br/>&nbsp;(setq VERTEX (entnext (ssname ss n))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (1+ n)<br/>&nbsp;)<br/>&nbsp;(while (/= (cdr (assoc 0 (entget VERTEX))) "SEQEND")<br/>&nbsp;&nbsp; (setq&nbsp;point&nbsp; (assoc 10 (entget VERTEX))<br/>&nbsp;&nbsp;VERTEX (entnext VERTEX)<br/>&nbsp;&nbsp; )<br/>&nbsp;&nbsp; (write-line (strcat (rtos (nth 1 point) 2 2) "," (rtos (nth 2 point) 2 2)) file_obj)<br/>&nbsp;)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (close file_obj)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (command "undo" "e")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (prin1)<br/>&nbsp;&nbsp;&nbsp; )<br/>&nbsp; )<br/>)</p><p></p><p>其他对象类似 </p>

ty0030801 发表于 2008-8-11 23:36:00

<p>我有这程序</p><p>代码如下:</p><p>Sub xyz()<br/>Dim x As Double<br/>Dim y As Double<br/>Dim i<br/>Set fs = CreateObject("Scripting.FileSystemObject")<br/>&nbsp;&nbsp;&nbsp; Set a = fs.CreateTextFile("d:\查询结果.txt", True)<br/>&nbsp;&nbsp;&nbsp; i = 1<br/>On Error Resume Next<br/>Dim keywordlist As String<br/>keywordlist = "o"<br/>nextreturnpnt:<br/>ThisDrawing.Utility.InitializeUserInput 128, keywordlist<br/>Dim returnpnt As Variant<br/>returnpnt = ThisDrawing.Utility.GetPoint(, "输入一个点[完成/(o)]:")<br/>If Err Then<br/>If StrComp(Err.Description, "用户输入的是关键字", 1) = 0 Then<br/>Dim inputstring As String<br/>Err.Clear<br/>inputstring = ThisDrawing.Utility.GetInput<br/>a.Close<br/>Exit Sub<br/>Else<br/>MsgBox "选择点时发生错误:" &amp; Err.Description<br/>Err.Clear<br/>End If<br/>Else<br/>x = Format(Round(returnpnt(1), 4), "0.000")<br/>y = Format(Round(returnpnt(0), 4), "0.000")<br/>a.WriteLine (i &amp; ",," &amp; x &amp; "," &amp; y)<br/>i = i + 1<br/>End If<br/>GoTo nextreturnpnt<br/>End Sub<br/>在cad中运行上程序,结果保存在d:\查询结果.txt文件中,格式为:点号,X坐标,Y坐标</p>

www2002 发表于 2008-8-27 09:27:00

支持一下!!

guigang1974 发表于 2008-9-8 22:11:00

6楼的。。说清楚那代码咋用啊。。。。。先谢过。。。

jingqin0472 发表于 2009-9-10 12:39:00

<p>这个功能不难!想要联系我,VBA代码。252950152</p>

lxn1991 发表于 2009-10-8 18:19:00

加载lisp程序即可,
页: [1] 2 3 4
查看完整版本: 怎么把图上n个点的坐标读取并输出到Txt或者excel?