放置偏移为的结果
当前,我在标记管道管路时根据结果进行剪切和粘贴。我编译了一个简单的程序从零碎和多个网站的参考资料。我现在需要帮助将lisp中的文本结果放置在选定行中点上方的偏移位置。
感谢您的帮助
;; label_run.lsp
;; lisp commands used referenced at: cadtutor.com, jefferypsanders.com, afralisp.net, ronleigh.com, lee-mac.com
;; Credits - Noted Assistance: hanhphuc, ymg
;; Objective:
;; User To Pick By Line Or Two Points From Screen To Retrieve Distance(d) With Length Rounded Off And Compute Slope Percentage Of Selection
;; To Be Used For:
;; 1) As An Inquiry - For Display Only
;; 2) With Option To Paste Results Above Selected Line As Label
;; Wish List Add Ons
;; 1) Possible Pipe Size And Material Add To String
;; 2) Use Leader If Text Exceeds line
;;
;;**************************************************************************************;;
(defun C:label_run ( / *error* a1 a2 el e2 x1 y1 z1 x2 y2 z2 d tx pt txsize rot kw); Defined Functions Used -
(setq oldlayer (getvar "clayer"))
(setq oldsnap (getvar "osmode"))
;; User Option: Select Two Points Or Line - To Retrieve Distance Between And (z) Elevation At Each Selected Point
(initget 0 "Line")
(setq a1 (getpoint "\nPoint or "))
(if (= a1 nil); If nil then select line
(setq a1 "Line")
)
;; If line option selected then:
(if (= a1 "Line")
; true
(progn
(setq el (ut-get-object "LINE" "\nSelect Line:"))
(setq a1 (cdr (assoc 10 el)))
(setq a2 (cdr (assoc 11 el)))
)
;; If point - pick point
(progn
(setq a2 (getpoint a1 "\nSelect second point: "))
)
)
(if (= a2 nil) (exit)); line option selected
;get z value of points
(setq x1 (car a1)
y1 (cadr a1)
z1 (caddr a1)
x2 (car a2)
y2 (cadr a2)
z2 (caddr a2)
)
;; Determine slope percentage -
(if (> (abs (- z1 z2)) 0.1)
(setq s1 "%"
a1 (subst 0.0 z1 a1)
a2 (subst 0.0 z2 a2)
d(distance a1 a2); Get Distance / Length Of Line
slp (/ (- z2 z1) d); Formula For Slope: Z Value Point(1) Minus Z Value Point(2) (can Be Opposite 2-1) Divided By Length Of Line
)
(setq s1 "%"; Determine Percent
d (distance a1 a2)
slp (/ (- y2 y1) d)
)
)
(setq slp (* slp 1.000))
;; Make Angle Readable ;credit to ymg
(defun MakeReadable (a)
(setq a (rem (+ a pi pi) (+ pi pi)))
(rem (if (< (* pi 0.5) a (* pi 1.5))
(+ a pi)
a
) ;_ end of if
(+ pi pi)
) ;_ end of rem
) ;_ end of defun
;; Results Displayed On Screen
(terpri)
(princ (setq tx ( strcat (rtos d 2 0)" LF @ "(rtos slp 2 2) s1 " Slope")))
;; Option To Paste Results In Drawing offset Midpoint Above Line From Display
(initget "Yes No")
(setq kw (getkword "\nPlace Above Line? :"))
(if (= kw "Yes")
(progn (setq txsize (getvar 'textsize) pt (polar (apply 'mapcar (cons ''((a b) (* 0.5 (+ a b))) (list a1 a2)))
(+ rot (/ pi 2.))
(* txsize 3.0)
) ;_ end of polar
) ;_end of setq
(entmake (list '(0 . "TEXT")
'(72 . 1) ; justify
(cons 1 tx)
(cons 10 pt)
(cons 11 pt) ; justify
(cons 40 txsize)
(cons 50 (MakeReadable (apply 'angle lst)))
) ; list
) ;entmake
) ;_ end of progn
) ;_ end of if
;;;; NOTED ERROR AT THIS POINT
;;;; ; error: bad argument type: numberp: nil
;; ERROR RESEARCH: A function requiring an integer argument has been passed an argument of incorrect data type with the value noted in the error message.
(princ)
)
(princ)
;; To Reset Original Varibles - End
(setq olderr *error*)
(setvar "osmode" 11)
(princ)
嗨runner214试试这个旧线程
这有帮助吗?
建议:
;; label_run.lsp
;; lisp commands used referenced at: cadtutor.com, jefferypsanders.com, afralisp.net, ronleigh.com, lee-mac.com
;; Credits - Noted Assistance: hanhphuc, ymg
;; Objective:
;; User To Pick By Line Or Two Points From Screen To Retrieve Distance(d) With Length Rounded Off And Compute Slope Percentage Of Selection
;; To Be Used For:
;; 1) As An Inquiry - For Display Only
;; 2) With Option To Paste Results Above Selected Line As Label
;; Wish List Add Ons
;; 1) Possible Pipe Size And Material Add To String
;; 2) Use Leader If Text Exceeds line
;;
;;**************************************************************************************;;
;; Make Angle Readable ;credit to ymg
(defun MakeReadable (a)
(setq a (rem (+ a pi pi) (+ pi pi)))
(rem (if (< (* pi 0.5) a (* pi 1.5))
(+ a pi)
a
) ;_ end of if
(+ pi pi)
) ;_ end of rem
) ;_ end of defun
(defun C:label_run ( / *error* a1 a2 el e2 x1 y1 z1 x2 y2 z2 d tx pt txsize rot kw lst ); Defined Functions Used -
(setq oldlayer (getvar "clayer"))
(setq oldsnap (getvar "osmode"))
;; User Option: Select Two Points Or Line - To Retrieve Distance Between And (z) Elevation At Each Selected Point
(initget 0 "Line")
(setq a1 (getpoint "\nPoint or "))
(if (= a1 nil); If nil then select line
(setq a1 "Line")
)
;; If line option selected then:
(if (= a1 "Line")
; true
(progn
(setq el (ut-get-object "LINE" "\nSelect Line:"))
(setq a1 (cdr (assoc 10 el)))
(setq a2 (cdr (assoc 11 el)))
)
;; If point - pick point
(progn
(setq a2 (getpoint a1 "\nSelect second point: "))
)
)
(if (= a2 nil) (exit)); line option selected
;get z value of points
(setq x1 (car a1)
y1 (cadr a1)
z1 (caddr a1)
x2 (car a2)
y2 (cadr a2)
z2 (caddr a2)
)
;; Determine slope percentage -
(if (> (abs (- z1 z2)) 0.1)
(setq s1 "%"
a1 (subst 0.0 z1 a1)
a2 (subst 0.0 z2 a2)
d(distance a1 a2); Get Distance / Length Of Line
slp (/ (- z2 z1) d); Formula For Slope: Z Value Point(1) Minus Z Value Point(2) (can Be Opposite 2-1) Divided By Length Of Line
)
(setq s1 "%"; Determine Percent
d (distance a1 a2)
slp (/ (- y2 y1) d)
)
)
(setq slp (* slp 1.000))
;; Results Displayed On Screen
(terpri)
(princ (setq tx ( strcat (rtos d 2 0)" LF @ "(rtos slp 2 2) s1 " Slope")))
;; Option To Paste Results In Drawing offset Midpoint Above Line From Display
(initget "Yes No")
(setq kw (getkword "\nPlace Above Line? :"))
(if (= kw "Yes")
(progn (setq txsize (getvar 'textsize)
lst (list a1 a2)
rot (MakeReadable (apply 'angle lst))
pt(polar (apply 'mapcar (cons ''((a b) (* 0.5 (+ a b))) lst))
(+ rot (/ pi 2.))
(* txsize 3.0)
) ;_ end of polar
) ;_end of setq
(entmake (list '(0 . "TEXT")
'(72 . 1) ; justify
(cons 1 tx)
(cons 10 pt)
(cons 11 pt) ; justify
(cons 40 txsize)
(cons 50 rot)
) ; list
) ;entmake
) ;_ end of progn
) ;_ end of if
(princ)
)
(princ)
;; To Reset Original Varibles - End
(setq olderr *error*)
(setvar "osmode" 11)
(princ)
HTH公司 谢谢hanhphuc,明天早上会查出来的
我对lisp结果的结果感到满意。-ie:27 LF@。02%斜率-。我只是不确定如何获取结果并将其放置在偏离所选线中点的位置。
我试图使用lisp作为查询(显示)的工具,如果我想标记文本结果,还可以使用Y或N选项将其放置在行上。。 hanhphuc公司
插入您建议的更改。YES响应出错,并收到错误。NO选项关闭时没有任何错误。
然后,我根据Lee Mac的教程运行了Visual Lips editor程序,结果如下:
日志监视
...............
*最后一个值*=
(+ROT(/PI 2.0))=
(SETQ DEC 2)=2
12 = 12
...............
更新代码:
;; label_run.lsp
;; lisp commands used referenced at: cadtutor.com, jefferypsanders.com, afralisp.net, ronleigh.com, lee-mac.com
;; Credits - Noted Assistance: hanhphuc, ymg
;; Debugging
;; Current - 020815
;; Objective:
;; User To Pick By Line Or Two Points From Screen To Retrieve Distance(d) With Length Rounded Off And Compute Slope Percentage Of Selection
;; To Be Used For:
;; 1) As An Inquiry - For Display Only
;; 2) With Option To Paste Results Above Selected Line As Label
;; Wish List Add Ons
;; 1) Possible Pipe Size And Material Add To String
;; 2) Use Leader If Text Exceeds line
;;
;;**************************************************************************************;;
(defun C:label_run ( / *error* a1 a2 el e2 x1 y1 z1 x2 y2 z2 d tx pt txsize rot kw); Defined Functions Used -
(setq oldlayer (getvar "clayer"))
(setq oldsnap (getvar "osmode"))
;; User Option: Select Two Points Or Line - To Retrieve Distance Between And (z) Elevation At Each Selected Point
(initget 0 "Line")
(setq a1 (getpoint "\nPoint or "))
(if (= a1 nil); If nil then select line
(setq a1 "Line")
)
;; If line option selected then:
(if (= a1 "Line")
; true
(progn
(setq el (ut-get-object "LINE" "\nSelect Line:"))
(setq a1 (cdr (assoc 10 el)))
(setq a2 (cdr (assoc 11 el)))
)
;; If point - pick point
(progn
(setq a2 (getpoint a1 "\nSelect second point: "))
)
)
(if (= a2 nil) (exit)); line option selected
;get z value of points
(setq x1 (car a1)
y1 (cadr a1)
z1 (caddr a1)
x2 (car a2)
y2 (cadr a2)
z2 (caddr a2)
)
;; Determine slope percentage -
(if (> (abs (- z1 z2)) 0.1)
(setq s1 "%"
a1 (subst 0.0 z1 a1)
a2 (subst 0.0 z2 a2)
d(distance a1 a2); Get Distance / Length Of Line
slp (/ (- z2 z1) d); Formula For Slope: Z Value Point(1) Minus Z Value Point(2) (can Be Opposite 2-1) Divided By Length Of Line
)
(setq s1 "%"; Determine Percent
d (distance a1 a2)
slp (/ (- y2 y1) d)
)
)
(setq slp (* slp 1.000))
;; Make Angle Readable ;credit to ymg
(defun MakeReadable (a)
(setq a (rem (+ a pi pi) (+ pi pi)))
(rem (if (< (* pi 0.5) a (* pi 1.5))
(+ a pi)
a
) ;_ end of if
(+ pi pi)
) ;_ end of rem
) ;_ end of defun
;; Results Displayed On Screen
(terpri)
(princ (setq tx ( strcat (rtos d 2 0)" LF @ "(rtos slp 2 2) s1 " Slope")))
;; Option To Paste Results In Drawing offset Midpoint Above Line From Display
(initget "Yes No")
(setq kw (getkword "\nPlace Above Line? :"))
(if (= kw "Yes")
(progn (setq txsize (getvar 'textsize) pt (polar (apply 'mapcar (cons ''((a b) (* 0.5 (+ a b))) (list a1 a2)))
(+ rot (/ pi 2.))
(* txsize 3.0)
) ;_ end of polar
) ;_end of setq
(entmake (list '(0 . "TEXT")
'(72 . 1) ; justify
(cons 1 tx)
(cons 10 pt)
(cons 11 pt) ; justify
(cons 40 txsize)
(cons 50 (MakeReadable (apply 'angle lst)))
) ; list
) ;entmake
) ;_ end of progn
) ;_ end of if
;;;; NOTED ERROR AT THIS POINT
;;;; ; error: bad argument type: numberp: nil
;; ERROR RESEARCH: A function requiring an integer argument has been passed an argument of incorrect data type with the value noted in the error message.
(princ)
)
(princ)
;; To Reset Original Varibles - End
(setq olderr *error*)
(setvar "osmode" 11)
(princ)
有什么想法吗? 我的道歉,
这是由于rot值不是setq,
lst (list a1 a2)
rot (MakeReadable (apply 'angle lst))
代码更新后#2 hanhphuc公司
成功了!
谢谢你的帮助。我读了一整天都没有成功。
谢谢你的时间。
欢迎你runner214。坚持下去这是你的负担
页:
[1]