Avcit 发表于 2022-7-5 17:34:14

Lisp用于导出文本和l

大家好,
我无法将行的长度添加到csv。

我想这样提取:
K5172,60/60720
 
 
有人能帮我处理这个代码吗?
 
(defun c:rp2 (/ ent1 ent2 ent3 len fh fname)
(setq fname (strcat (getvar "dwgprefix") (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4 )) ".csv")
          fh (open fname "a")
)
(command "_-LAYER" "_M" "SELECTED" "_C" 2 "" "")
(while (setq en1 (car (entsel "\nPick Text: ")))
   (setq ent1(entget en1)
         ent1(subst (cons 8 "SELECTED") (assoc 8 ent1) ent1)
   )
   (entmod ent1)
   (setq en2 (car (entsel "\nPick another text: ")))
   (setq ent2(entget en2)
         ent2(subst (cons 8 "SELECTED") (assoc 8 ent2) ent2)
   )   
   (entmod ent2)
(setq en3 (car (entsel "\nPick the line: ")))
   (setq ent3(entget en3)

len (distance
(cdr (assoc 10 ent3)) (cdr (assoc 11 ent3)) )
)


   
   (write-line (strcat (cdr (assoc 1 ent1)) ", "(cdr (assoc 1 ent2))) fh)
)
(princ (strcat "\nFile: " fname " Created."))                                             
(close fh)
)

Tharwat 发表于 2022-7-5 17:46:12

添加此部分:

(write-line (strcat (cdr (assoc 1 ent1)) ", "(cdr (assoc 1 ent2)) ", " (rtos len 2 4)) fh)

Avcit 发表于 2022-7-5 17:51:22

谢谢它起作用了
 
如何定义多段线的长度和面积?
 
我只想单击一条多段线,它会将其长度和面积导出为csv。

Tharwat 发表于 2022-7-5 17:59:39

不客气。
 
 
请尝试以下操作,并希望您能够将其添加到代码中:
 

(if (and (setq s (car (entsel "\nSelect Polyline :")))
      (= (cdr (assoc 0 (entget s))) "LWPOLYLINE")
      )
   (setq lgth (vlax-curve-getdistatparam s (vlax-curve-getendparam s))
         area (vlax-curve-getarea s)
         )
(princ "\nNull selection or object is not a LWpolyline !")
)

Avcit 发表于 2022-7-5 18:01:40

它给出了一个错误。
Pick Text:
Pick another text:
Pick the line:
Select Polyline :; error: no function definition: VLAX-CURVE-GETENDPOINT
 
我不需要“if循环”,因为我所有的多段线都是闭合的。(如图所示)

Tharwat 发表于 2022-7-5 18:09:46

只需添加以下函数即可在例程的顶部或末尾加载VL*函数库。
(vl-load-com)

Avcit 发表于 2022-7-5 18:20:52

 
感谢您的关注。除了长度外,它都有效。它给出了闭合多段线的长度0.0000。
我需要闭合多段线的长度代码

Tharwat 发表于 2022-7-5 18:21:42

抱歉,我修改了代码,请重试。

Avcit 发表于 2022-7-5 18:33:05

谢谢
 
你是个很棒的程序员

Tharwat 发表于 2022-7-5 18:40:50

 
非常欢迎你。
 
你这么说真是太好了
页: [1]
查看完整版本: Lisp用于导出文本和l