TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Fabricio28 on July 28, 2017, 07:39:48 AM
-
Hello guys!
I'm using that excellent code to align a text from line or curve.
But sometimes when I try to align a text from a line shows that alert bellow.
Alert!
Select object: ; error: bad argument type: numberp: nil
Anybody could help me please?
I think Lee Mac's is the author for this code.
Thank in advance
Fabricio
(defun c:rtr ( / a e i p s )
(if (setq s (LM:ssget "\nSelect Text: " '("_:L" ((0 . "*TEXT")))))
(progn
(while
(progn (setvar 'errno 0) (setq e (entsel))
(cond
( (= 7 (getvar 'errno))
(princ "\nMissed, try again.")
)
( (= 'ename (type (car e)))
(if
(vl-catch-all-error-p
(setq p
(vl-catch-all-apply 'vlax-curve-getclosestpointto
(list (car e) (trans (cadr e) 1 0))
)
)
)
(princ "\nInvalid object selected.")
)
)
)
)
)
(if (= 'ename (type (setq e (car e))))
(progn
(setq a (angle '(0.0 0.0) (vlax-curve-getfirstderiv e (vlax-curve-getparamatpoint e p))))
(if (and (< (* 0.5 pi) a) (<= a (* 1.5 pi)))
(setq a (+ pi a))
)
(repeat (setq i (sslength s))
(setq e (entget (ssname s (setq i (1- i)))))
(entmod (subst (cons 50 a) (assoc 50 e) e))
)
)
)
)
)
(princ)
)
;; ssget - Lee Mac
;; A wrapper for the ssget function to permit the use of a custom selection prompt
;;
;; Arguments:
;; msg - selection prompt
;; params - list of ssget arguments
(defun LM:ssget ( msg params / sel )
(princ msg)
(setvar 'nomutt 1)
(setq sel (vl-catch-all-apply 'ssget params))
(setvar 'nomutt 0)
(if (not (vl-catch-all-error-p sel)) sel)
)
(vl-load-com)
(princ)
-
After a cursory review of the program, I don't see any issue with the code - therefore, could you please follow the first section of this tutorial (http://lee-mac.com/debugvlide.html#where) and post the expression which is highlighted when the program errors?
-
After a cursory review of the program, I don't see any issue with the code - therefore, could you please follow the first section of this tutorial (http://lee-mac.com/debugvlide.html#where) and post the expression which is highlighted when the program errors?
Hi Lee
How are you?
I've made the workflow about "Where did the Code Fail?".
After that step Debug » Last Break Source (Ctrl+F9). Showed this message.
-
Maybe try something like this:
(defun _angleatpoint
(ename pt
/ p2 param
) )
)
)
;; Usage in routine
(progn (if (and (< (* 0.5 pi
) a
) (<= a
(* 1.5 pi
))) )
)
)
)
-
Maybe try something like this:
(defun _angleatpoint
(ename pt
/ p2 param
) )
)
)
;; Usage in routine
(progn (if (and (< (* 0.5 pi
) a
) (<= a
(* 1.5 pi
))) )
)
)
)
Perfect ronjonp!
Thank you very much.
I've made some test and worked perfect now.
I really appreciate the help. :)
Fabricio
-
Glad to help :)
-
Hello everyone
I had sometimes the same problem in sharp-bending splines.
After checking everything, I found out that the problem :
Original Program :
(setq pt (vlax-curve-getclosestpointto s po nil))
(setq di (vlax-curve-getdistatpoint obj pt))
Modified Program :
(setq pt (vlax-curve-getclosestpointto s po nil))
(setq pt (vlax-curve-getclosestpointto s pt nil))
(setq di (vlax-curve-getdistatpoint obj pt))
The middle line doesn't seem to be necessary, BUT It's Necessary !!
It is not logical, but it works !!!