如何批量提取三维多段线的节点坐标和高程?
本帖最后由 wxn80 于 2021-6-15 18:41 编辑各位老师,在CAD中如何批量提取三维多段线的节点坐标和高程?如果可以在三维多段线节点上直接显示相应的高程点更好。或者把三维多段线节点坐标和高程导出成txt文件也可以。
做一个热心并受欢迎的人
做一个热心并受欢迎的人 空压、冷冻机房 如何批量提取三维多段线的节点坐标和高程? 好像有个命令来着,不太用忘记了 哪位老师知道有什么插件可以实现三维多段线的节点坐标和高程批量提取吗? 本帖最后由 dnbcgrass 于 2021-7-1 10:19 编辑
;提取单条三维多段线节点坐标数据存盘
(defun c:swddxjdzb()
(vl-load-com)
(if (setq ent (car (entsel "\n选取三维多段线:")))
(progn
(setq vob (vlax-ename->vla-object ent))
(setq name (vlax-get-property vob "ObjectName"))
(setq path (getvar "dwgprefix"))
(If (= name"AcDb3dPolyline")
(if (setq wjm (getfiled "请指定提取结果存盘文件" path "txt" 1))
(progn
(setq ptb (vlax-safearray->list
(vlax-variant-value
(vlax-get-property vob "Coordinates")
)
)
)
(setq fff (open wjm "w"))
(setq i 1)
(while ptb
(setq x (car ptb))
(setq y (cadrptb))
(setq z (caddr ptb))
(setq ptb (cdr (cdr (cdr ptb))))
(write-line (strcat (itoa i) "," ;节点编号
(rtos x 2 3) "," ;X坐标保留3位小数
(rtos y 2 3) "," ;Y坐标保留3位小数
(rtos z 2 3) ;高程保留3位小数
)
fff
)
(setq i (1+ i))
)
(close fff)
(alert (strcat "三维多段线节点坐标已保存到\"" wjm "\"文件中!"))
)
)
(alert (strcat "所选取的不是三维多段线(AcDb3dPolyline), 是" name "!"))
)
)
)
(princ)
)
;提取多条三维多段线节点坐标数据存盘
(defun c:swddxjdzb2()
(vl-load-com)
(if (progn
(princ "\n选取三维多段线:")
(setq ssa (ssget '((0 . "POLYLINE"))))
)
(progn
(setq j 0)
(setq n (sslength ssa))
(setq pts nil)
(repeat n
(setq ent (ssname ssa j))
(setq vob (vlax-ename->vla-object ent))
(setq name (vlax-get-property vob "ObjectName"))
(If (= name"AcDb3dPolyline")
(progn
(setq ptb (vlax-safearray->list
(vlax-variant-value
(vlax-get-property vob "Coordinates")
)
)
)
(setq i 1)
(while ptb
(setq pts (cons (strcat (itoa (1+ j)) "-" (itoa i) ","
(rtos (car ptb) 2 3) ","
(rtos (cadrptb) 2 3) ","
(rtos (caddr ptb) 2 3) ","
)
pts
)
)
(setq ptb (cdddr ptb))
(setq i (1+ i))
)
)
)
(setq j (1+ j))
)
(setq path (getvar "dwgprefix"))
(If pts
(if (setq wjm (getfiled "请指定提取结果存盘文件" path "txt" 1))
(progn
(setq pts (reverse pts))
(setq fff (open wjm "w"))
(foreach pt pts
(write-line pt fff)
)
(close fff)
(alert (strcat (itoa n) "条三维多段线共计" (itoa (length pts)) "个的节点坐标已保存到\"" wjm "\"文件中!"))
)
)
)
)
)
(princ)
) 做一个热心并受欢迎的人 非常好用,感谢分享!!!!
页:
[1]