thereisnotime 发表于 2022-7-5 17:02:37

两次点击之间的角度

在我的主LISP中,提示用户在屏幕上选择2个点,我想根据这2次点击旋转文本。我试着让它保持简单,并在插入文本后运行TORIENT命令,但它总是给我一个错误,即TORIENT是一个未知的命令。。。。有什么想法吗?
 
(defun getTextData (lineObj textVal)
(setq pt1 (getpoint "\nSelect Insertion Point: "))
(setq ro1 (getpoint "\nRotation: Specify first point:"))
(setq ro2 (getpoint "Specify second point:"))

(entmake (list '(0 . "TEXT")
   '(8 . "DR_PJ_L") ; Change this for different Layer
   (cons 10 pt1)
   (cons 40 0.3) ; Change this for different height
   (cons 1 textVal)
   '(50 . 0.0) ; Text rotation
   '(7 . "ANNO TEXT_") ; change this for different Text Style
   '(71 . 0)
   '(72 . 0)
   '(73 . 0)
   ) ;_end list
) ;_end entmake
(setq e (entlast))
(command "_chprop" e "" "A" "Yes" "") ; Change text to annotative
(command "_torient" e ro1 ro2)
)

Lee Mac 发表于 2022-7-5 17:13:34

我建议您对代码进行以下修改:
(defun gettextdata ( lineobj str / ang ins txt )
   (if
       (and
         (setq ins (getpoint "\nSpecify insertion point: "))
         (setq ang (getangle "\nSpecify rotation: " ins))
         (setq txt
               (entmakex
                   (list
                      '(0 . "TEXT")
                      '(8 . "DR_RJ_L")
                     (cons 10 (trans ins 1 0))
                      '(40 . 0.3)
                     (cons1 str)
                     (cons 50 ang)
                     (cons7 (if (tblsearch "STYLE" "ANNO TEXT_") "ANNO TEXT_" (getvar 'textstyle)))
                   )
               )
         )
       )
       (command "_.chprop" txt "" "_A" "_Y" "")
   )
   txt
)

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

此外,您可能希望利用这一点:
;; Readable - Lee Mac
;; Returns an angle corrected for text readability.
(defun LM:readable ( a )
( (lambda ( a )
        (if (< a 0.0)
                (LM:readable a)
                (if (and (< (* pi 0.5) a) (<= a (* pi 1.5)))
                        (LM:readable (+ a pi))
                        a
                )
        )
)
(rem (+ a pi pi) (+ pi pi))
)
)
'(8 . "DR_RJ_L")

thereisnotime 发表于 2022-7-5 17:25:27

 
只是好奇。。。如果我知道DR_PJ_L层在图纸中,为什么需要额外检查?

Lee Mac 发表于 2022-7-5 17:34:53

 
你为什么要冒程序崩溃的风险?
如果在你的下一个程序中,你在图层的名称上打了一个错怎么办?

Grrr 发表于 2022-7-5 17:42:21

Entmake(x)将自动创建缺失层,不需要Grrr建议的检查。

thereisnotime 发表于 2022-7-5 17:42:57

 
罗伊是正确的,一如既往。。。该死的:
(cons 8 (if (tblsearch "LAYER" "DR_RJ_L") "DR_RJ_L" (getvar 'clayer)))
很抱歉

Grrr 发表于 2022-7-5 17:54:18

Roy_043 发表于 2022-7-5 17:57:56

Entmake(x) will automatically create missing layers there is no need for the check that Grrr has suggested.

Grrr 发表于 2022-7-5 18:09:19

 
Roy is correct, as always... dammit:

_$ (entmakex (list (cons 0 "LINE") (cons 8 "NewUnexistingLayer") (cons 10 (getpoint)) (cons 11 (getpoint))))_$
Sorry.
页: [1]
查看完整版本: 两次点击之间的角度