Grrr 发表于 2022-7-5 17:20:04

下面是另一个-使用一些列表操作和visual lisp(在学习LM的代码后):

; Pline's vertices to txt file
(defun C:test ( / LM:group-n SS i o e L fp opn )

;; Group by Number-Lee Mac
;; Groups a list 'l' into a list of lists, each of length 'n'

(defun LM:group-n ( l n / r )
   (if l
   (cons
       (reverse (repeat n (setq r (cons (car l) r) l (cdr l)) r))
       (LM:group-n l n)
   )
   )
)
(cond
   (
   (not
       (progn
         (setq SS (ssget '((0 . "*POLYLINE"))))
         (repeat (setq i (sslength SS))
         (setq o (vlax-ename->vla-object (setq e (ssname SS (setq i (1- i))))))
         (if (vlax-property-available-p o 'Coordinates)
             (setq L (cons (cons (cdr (assoc 210 (entget e))) (LM:group-n (vlax-get o 'Coordinates) 3)) L))
         )
         ); repeat
         L
       )
   )
   (princ "\nInvalid objects selected.")
   )
   ( (not (setq fp (getfiled "Create vertices data" "" "txt" 1)))
   (princ "\nText file not specified.")
   )
   ( (setq opn (open fp "w"))
   (princ "X \tY \tZ" opn)
   (mapcar
       '(lambda (a b)
         (mapcar
         '(lambda (x)
             (princ
               (strcat "\n"
               (vl-string-left-trim "\t"
                   (vl-string-right-trim ", "
                     (apply 'strcat (mapcar '(lambda (n) (strcat "\t" (rtos n 2 2) ", ")) (trans x a 1)))
                   )
               )
               )
               opn
             )
         )
         b
         )
       )
       (mapcar 'car L)
       (mapcar 'cdr L)
   )
   (close opn)
   (initget "Yes No")
   (if (= "Yes" (cond ((getkword "\nDo you want to open the file? <Yes>: ")) ("Yes")))
       (startapp "explorer" fp)
   )
   )
); cond
(princ)
);| defun |; (vl-load-com) (princ)

David Bethel 发表于 2022-7-5 17:25:09

 
一个绘图示例会有帮助,我不知道你是否可以发布一个文件附件,直到你有10个帖子-达武德

SLW210 发表于 2022-7-5 17:30:13

 
他们可以发布任何东西,链接是有节制的,通过“高级”>“管理附件”将图像和文件发布到CADTutor,无需任何节制。

GerIng 发表于 2022-7-5 17:36:46

非常感谢!这正是我需要的。工作起来很有魅力。
页: 1 [2]
查看完整版本: 获取三维Po的UCS坐标