motee-z 发表于 2022-7-6 06:30:06

通过拾取x值绘制三维样条线

你好
有没有关于绘制三维样线的帮助,可以让我从drwaing中选择坐标作为文本,而不是在命令行中用点名称编写坐标
我将点坐标表作为单个文本n x y z
序列拾取x拾取y拾取z输入名称绘制的第一个点,然后是第二个点等。。。。
非常感谢。

motee-z 发表于 2022-7-6 06:49:30

好的,这是我的尝试,但无法添加点名称,非常感谢您的帮助
 
(defun c:pltx(/ )
;;;;;;;;;;;;;;;;;;;;
(command "._3dpoly")
(while (eq 1 (logand 1 (getvar "cmdactive")))
(if a
    (progn
      (princ"pick x value")
(setq x (ssget))

(setq oldobj1 (entget (ssname x 0)))      
(setq txtstr1 (assoc 1 oldobj1))
(setq xv (atof(cdr txtstr1)))
(princ xv)
(princ"pick y value")   
(setq y (ssget))
(setq oldobj2 (entget (ssname y 0)))      
(setq txtstr2 (assoc 1 oldobj2))
(setq yv (atof(cdr txtstr2)))
(princ yv)
(princ"pick z value")   
(setq z (ssget))
(setq oldobj3 (entget (ssname z 0)))      
(setq txtstr3 (assoc 1 oldobj3))
(setq zv (atof(cdr txtstr3)))
(princ zv)
(setq a(list xv yv zv))
      
)

;;;;;;;;;;;;;;;;;;;;;;;
    (progn
(princ"pick start x value")   
(setq x (ssget))

(setq oldobj1 (entget (ssname x 0)))      
(setq txtstr1 (assoc 1 oldobj1))
(setq xv (atof(cdr txtstr1)))
(princ xv)
(princ"pick start y value")
(setq y (ssget))
(setq oldobj2 (entget (ssname y 0)))      
(setq txtstr2 (assoc 1 oldobj2))
(setq yv (atof(cdr txtstr2)))
(princ yv)
(princ"pick start z value")
(setq z (ssget))
(setq oldobj3 (entget (ssname z 0)))      
(setq txtstr3 (assoc 1 oldobj3))
(setq zv (atof(cdr txtstr3)))
(princ zv)
(setq a(list xv yv zv))   
)
    )
    ;;;;;;;;;;;;;;;;;;;;;

(if a
(command a)
(command)             
)
    )

(princ)
)

Lee Mac 发表于 2022-7-6 07:01:16

以下是一些帮助您入门的代码:
(defun c:pltx ( / pt )
   (if (setq pt (gettextpoint))
       (progn
         (command "_.3dpoly" "_non" pt)
         (while (setq pt (gettextpoint))
               (command "_non" pt)
         )
         (command "")
       )
   )
   (princ)
)

(defun gettextpoint ( / x y z )
   (if
       (and
         (setq x (getnumericaltext "\nSelect X-Value Text <Exit>: "))
         (setq y (getnumericaltext "\nSelect Y-Value Text <Exit>: "))
         (setq z (getnumericaltext "\nSelect Z-Value Text <Exit>: "))
       )
       (list x y z)
   )
)

(defun getnumericaltext ( msg / ent enx num )
   (while
       (progn (setvar 'errno 0) (setq ent (car (nentsel msg)))
         (cond
               (   (= 7 (getvar 'errno))
                   (princ "\nMissed, try again.")
               )
               (   (= 'ename (type ent))
                   (setq enx (entget ent))
                   (cond
                     (   (not (wcmatch (cdr (assoc 0 enx)) "TEXT,MTEXT,ATTRIB"))
                           (princ "\nPlease select Text, MText or Attribute.")
                     )
                     (   (not (setq num (distof (cdr (assoc 1 enx)))))
                           (princ "\nSelected text is not numerical.")
                     )
                   )
               )
         )
       )
   )
   num
)

motee-z 发表于 2022-7-6 07:27:50

非常感谢李先生的回复,请添加需要点名称的用户并标记此点

motee-z 发表于 2022-7-6 07:44:18

李,你在哪儿
页: [1]
查看完整版本: 通过拾取x值绘制三维样条线