Nikon Posted February 5 Posted February 5 (edited) After entering the scaling factor, the code returns an error: ; error: invalid argument type: numberp: nil (defun c:SclCrQuadr ( / quadrant ss scl ent elst center radius basePt ) (prompt "\nSelect the quadrant to scale [Upper/Bottom/Right/Left]: ") (setq quadrant (getstring)) (setq quadrant (substr (strcase quadrant) 1 1)) (prompt "\nSelect the circles to scale...") (setq ss (ssget '((0 . "CIRCLE")))) (if (not ss) (progn (prompt "\nNo circles are selected. Interruption.\n") (exit) ) ) (setq scl (getreal "\nEnter the scaling factor: ")) (if (not scl) (progn (prompt "\nScaling factor is not set. Interruptionе.\n") (exit) ) ) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i)))) elst (entget ent) center (cdr (assoc 10 elst)) radius (cdr (assoc 40 elst)) ) (cond ((= quadrant "U") (setq basePt (list (car center) (+ (cadr center) radius)))) ((= quadrant "B") (setq basePt (list (car center) (- (cadr center) radius)))) ((= quadrant "R") (setq basePt (list (+ (car center) radius) (cadr center)))) ((= quadrant "L") (setq basePt (list (- (car center) radius) (cadr center)))) (T (progn (prompt "\nAn incorrect quadrant has been entered. Interruption.\n") (exit) ) ) ) (command "_.SCALE" ent "" basePt scl) (prompt "\nScaling is completed.\n") (princ) ) How can this be fixed? Thank ... Edited February 5 by Nikon Quote
Emmanuel Delay Posted February 5 Posted February 5 (edited) The first obvious problem is this first line. You close the bracket for setq at the end of line 1. This means that the rest of the lines don't do setq. So elst, radius, center do not get set (setq ent (ssname ss (setq i (1- i)))) elst (entget ent) center (cdr (assoc 10 elst)) radius (cdr (assoc 40 elst)) ) -------- I removed that bracket. And put it way down below the code. That bracket now closes the repeat loop. (defun c:SclCrQuadr ( / i quadrant ss scl ent elst center radius basePt ) (prompt "\nSelect the quadrant to scale [Upper/Bottom/Right/Left]: ") (setq quadrant (getstring)) (setq quadrant (substr (strcase quadrant) 1 1)) (prompt "\nSelect the circles to scale...") (setq ss (ssget '((0 . "CIRCLE")))) (if (not ss) (progn (prompt "\nNo circles are selected. Interruption.\n") (exit) ) ) (setq scl (getreal "\nEnter the scaling factor: ")) (if (not scl) (progn (prompt "\nScaling factor is not set. Interruptionе.\n") (exit) ) ) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i))) elst (entget ent) center (cdr (assoc 10 elst)) radius (cdr (assoc 40 elst)) ) (cond ((= quadrant "U") (setq basePt (list (car center) (+ (cadr center) radius)))) ((= quadrant "B") (setq basePt (list (car center) (- (cadr center) radius)))) ((= quadrant "R") (setq basePt (list (+ (car center) radius) (cadr center)))) ((= quadrant "L") (setq basePt (list (- (car center) radius) (cadr center)))) (T (progn (prompt "\nAn incorrect quadrant has been entered. Interruption.\n") (exit) ) ) ) (princ "*") (command "_.SCALE" ent "" basePt scl) ) ;; Her is where the repeat must end (prompt "\nScaling is completed.\n") (princ) ) Edited February 5 by Emmanuel Delay 1 Quote
Nikon Posted February 5 Author Posted February 5 44 minutes ago, Emmanuel Delay said: I removed that bracket. And put it way down below the code. That bracket now closes the repeat loop. Thanks a lot, it's working the way it should now! 1 Quote
Nikon Posted February 5 Author Posted February 5 Is it possible to add the ability to scale circles and text inside them together to this code? Quote
Nikon Posted Thursday at 12:41 PM Author Posted Thursday at 12:41 PM On 2/5/2025 at 12:27 PM, Nikon said: Is it possible to add the ability to scale circles and text inside them together to this code? The code added a selection of objects inside the circle for joint scaling, but there is an error... ; error: no function definition: CIRCLE->POLYGON Please help me find the error. Thank... (defun c:SclCircQuadrObj (/ quadrant ss scl ent elst center radius basePt i ssInside polyPts) (defun circle->polygon (cen rad / i N ang x y ptlst) (setq N 36 i 0 ptlst '() ) (while (< i N) (setq ang (* 2.0 pi (/ i (float N)))) x (+ (car cen) (* rad (cos ang))) y (+ (cadr cen) (* rad (sin ang)))) (setq ptlst (append ptlst (list (list x y)))) (setq i (1+ i)) ) (setq ptlst (append ptlst (list (car ptlst)))) ptlst ) (prompt "\nSelect the quadrant to scale [Upper/Bottom/Right/Left]: ") (setq quadrant (getstring)) (setq quadrant (substr (strcase quadrant) 1 1)) (prompt "\nnSelect the circles to scale...") (setq ss (ssget '((0 . "CIRCLE")))) (if (not ss) (progn (prompt "\nNo circles are selected. Interruption.\n") (exit) ) ) (setq scl (getreal "\nEnter the scaling factor: ")) (if (not scl) (progn (prompt "\nScaling factor is not set. Interruption?.\n") (exit) ) ) (setq i (sslength ss)) (while (> i 0) (setq i (1- i)) (setq ent (ssname ss i) elst (entget ent) center (cdr (assoc 10 elst)) radius (cdr (assoc 40 elst)) ) (cond ((= quadrant "U") (setq basePt (list (car center) (+ (cadr center) radius)))) ((= quadrant "B") (setq basePt (list (car center) (- (cadr center) radius)))) ((= quadrant "R") (setq basePt (list (+ (car center) radius) (cadr center)))) ((= quadrant "L") (setq basePt (list (- (car center) radius) (cadr center)))) (T (progn (prompt "\nAn incorrect quadrant has been entered. Interruption.\n") (exit) ) ) ) (setq polyPts (circle->polygon center radius)) (setq ssInside (ssget "_WP" polyPts)) (setq ssInside (cond (ssInside (ssadd ent ssInside)) (t (ssadd ent)) ) ) (command "_.SCALE" ssInside "" basePt scl) ) ;; end while (prompt "\nScaling is completed.\n") (princ) ) Quote
GLAVCVS Posted Thursday at 01:26 PM Posted Thursday at 01:26 PM I think you have an extra parenthesis after '... (* rad (without ang))))' There should be 3 parentheses, not 4 1 Quote
Nikon Posted Thursday at 04:30 PM Author Posted Thursday at 04:30 PM 3 hours ago, GLAVCVS said: I think you have an extra parenthesis after '... (* rad (without ang))))''' There should be 3 parentheses, not 4 Unfortunately, it gives an error again. ; error: invalid list of points Quote
GLAVCVS Posted Thursday at 06:56 PM Posted Thursday at 06:56 PM There is some other parentheses misplaced in the 'circle->polygon' function. (defun circle->polygon (cen rad / i N ang x y ptlst) (setq N 36 i 0 ptlst '() ) (while (< i N) (setq ang (* 2.0 pi (/ i (float N))) x (+ (car cen) (* rad (cos ang))) y (+ (cadr cen) (* rad (sin ang))) ) (setq ptlst (append ptlst (list (list x y)))) (setq i (1+ i)) ) (setq ptlst (append ptlst (list (car ptlst)))) ptlst ) 1 Quote
GLAVCVS Posted Thursday at 07:01 PM Posted Thursday at 07:01 PM You can find these errors with the Visual Lisp debugger. Don't you use it? 1 Quote
Nikon Posted Thursday at 07:30 PM Author Posted Thursday at 07:30 PM 23 minutes ago, GLAVCVS said: You can find these errors with the Visual Lisp debugger. Don't you use it? I thought that the error might be in the function, I checked the closing brackets, but found nothing. Thanks a lot for your help, now the code scales circles with objects inside. Here is the corrected code: (defun c:SclCircQuadrObject (/ quadrant ss scl ent elst center radius basePt i ssInside polyPts) (defun circle->polygon (cen rad / i N ang x y ptlst) (setq N 36 i 0 ptlst '() ) (while (< i N) (setq ang (* 2.0 pi (/ i (float N))) x (+ (car cen) (* rad (cos ang))) y (+ (cadr cen) (* rad (sin ang))) ) (setq ptlst (append ptlst (list (list x y)))) (setq i (1+ i)) ) (setq ptlst (append ptlst (list (car ptlst)))) ptlst ) (prompt "\nSelect the quadrant to scale [Upper/Bottom/Right/Left]: ") (setq quadrant (getstring)) (setq quadrant (substr (strcase quadrant) 1 1)) (prompt "\nnSelect the circles to scale...") (setq ss (ssget '((0 . "CIRCLE")))) (if (not ss) (progn (prompt "\nNo circles are selected. Interruption.\n") (exit) ) ) (setq scl (getreal "\nEnter the scaling factor: ")) (if (not scl) (progn (prompt "\nScaling factor is not set. Interruption?.\n") (exit) ) ) (setq i (sslength ss)) (while (> i 0) (setq i (1- i)) (setq ent (ssname ss i) elst (entget ent) center (cdr (assoc 10 elst)) radius (cdr (assoc 40 elst)) ) (cond ((= quadrant "U") (setq basePt (list (car center) (+ (cadr center) radius)))) ((= quadrant "B") (setq basePt (list (car center) (- (cadr center) radius)))) ((= quadrant "R") (setq basePt (list (+ (car center) radius) (cadr center)))) ((= quadrant "L") (setq basePt (list (- (car center) radius) (cadr center)))) (T (progn (prompt "\nAn incorrect quadrant has been entered. Interruption.\n") (exit) ) ) ) (setq polyPts (circle->polygon center radius)) (setq ssInside (ssget "_WP" polyPts)) (setq ssInside (cond (ssInside (ssadd ent ssInside)) (t (ssadd ent)) ) ) (command "_.SCALE" ssInside "" basePt scl) ) ;; end while (prompt "\nScaling is completed.\n") (princ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.