maq Posted November 1, 2022 Posted November 1, 2022 Hi guys! I'm trying to define a few points and put them in the right place on the screen. I followed the instruction from the website: LINK And here is a sample of my code: Quote (setq u1 (list 0 0)) ; create the point coordinates (setq u2 (list d 0)) ; create the point coordinates (setq u3 (list d 0.03)) ; create the point coordinates (setq u4 (list 0 0.03)) ; create the point coordinates (command "_POINT" u1 "") (command "_POINT" u2 "") (command "_POINT" u3 "") (command "_POINT" u4 "") The problem appears when I make Y a real number as you can see above ("0.03")... If I change it to integral number then the coordinates are working fine. Thanks in advance for any help! maq Quote
mhupp Posted November 1, 2022 Posted November 1, 2022 Are you applying a value to d? also you don't need the 2nd "" this repeats the last command and probably where you error is coming from. (command "_POINT" u1) I try an not use "(command" When I can. entmake is a little more code but less chance of error and is also much faster. (setq u1 (list 0 0)) (entmake (list (cons 0 "POINT") (cons 10 u1) ) ) y 1 Quote
ronjonp Posted November 1, 2022 Posted November 1, 2022 (edited) To add to this once your points are defined then you can create them like so: (foreach p (list u1 u2 u3 u4) (entmake (list '(0 . "POINT") (cons 10 p)))) Edited November 2, 2022 by ronjonp * missed an apostrophe 2 Quote
maq Posted November 1, 2022 Author Posted November 1, 2022 1 hour ago, mhupp said: Are you applying a value to d? also you don't need the 2nd "" this repeats the last command and probably where you error is coming from. (command "_POINT" u1) I try an not use "(command" When I can. entmake is a little more code but less chance of error and is also much faster. (setq u1 (list 0 0)) (entmake (list (cons 0 "POINT") (cons 10 u1) ) ) y Thanks for the quick response. Yes, I'm applying a value for d. My code is more advance, just quoted a part with points. I am using "command" temporarily to check where my points appear before I use this procedure to change UCS by "_UCS" command and slice the point cloud. I want to cut the slice the same way you draw the rectangle and do it in temporary UCS to make it easy. The thing is, my slice has to be thin like 0.03m but real numbers don't work for any reason, just integrals. I know the way I'm writing the code may look horrible for more advanced guys. I am a beginner and I'm focusing more on this what works for me in practice. There is more code, so maybe that will clarify my idea: Quote (defun c:test ( / S1 S2 Xs1 Xs2 AzR AzD d u1 u2 u3 u4 OZ) (setq S1 (getpoint "\n S1? : ")) (setq Xs1 (rtos (nth 0 S1))) (setq Ys1 (rtos (nth 1 S1))) (setq S2 (getpoint "\n S2? : ")) (setq Xs2 (rtos (nth 0 S2))) (setq Ys2 (rtos (nth 1 S2))) (setq XS1 (atof Xs1)) (setq YS1 (atof Ys1)) (setq XS2 (atof Xs2)) (setq YS2 (atof Ys2)); {PL: zamiana współrzędnych S1, S2 ze zmiannych tekstowych na liczbowe} (setq d (distance S1 S2)) (If (and (> Xs2 Xs1) (> Ys2 Ys1)) ; this is the first condition of 4 (test) (progn (setq OZ (list (+ Xs1 (/ d 2)) (+ Ys1 (/ d 2)))) (alert "OK!") ) ) (command "_UCS" S1 S2 OZ "") (setq u1 (list 0 0 0)) ; create the point coordinates (setq u2 (list d 0 0)) ; create the point coordinates (setq u3 (list d 1 0.03)) ; create the point coordinates (setq u4 (list 0 1 0.03)) ; create the point coordinates ;(command "_POINTCLOUDCROP" 1 "_P" u1 u2 u3 u4) ; I'm going to use this command (command "_POINT" u1) ; that's for test to see where the points are (command "_POINT" u2) ; that's for test to see where the points are (command "_POINT" u3) ; that's for test to see where the points are (command "_POINT" u4) ; that's for test to see where the points are ) I attatched a short video to show what I want to achieve but instead of slice 1m i need 0.03m. Quote
maq Posted November 1, 2022 Author Posted November 1, 2022 2 hours ago, ronjonp said: To add to this once your points are defined then you can create them like so: (foreach p (list u1 u2 u3 u4) (entmake (list (0 . "POINT") (cons 10 p)))) I pasted your line to my code but the console return the error: bad argument type: consp "POINT". Shall I edit something more..? Quote
mhupp Posted November 1, 2022 Posted November 1, 2022 31 minutes ago, maq said: I pasted your line to my code but the console return the error: bad argument type: consp "POINT". Shall I edit something more..? missing a ' (foreach p (list u1 u2 u3 u4) (entmake (list '(0 . "POINT") (cons 10 p)))) 1 Quote
maq Posted November 1, 2022 Author Posted November 1, 2022 Thanks mhupp for the tip. Good to know! Quote
BIGAL Posted November 2, 2022 Posted November 2, 2022 (edited) Just me to avoid errors when using ' to make lists I prefer to use cons for all (foreach p (list u1 u2 u3 u4) (entmake (list (cons 0 "POINT") (cons 10 p)))) Lee-mac has a good explanation about using quote ' v's cons, found it http://www.lee-mac.com/quote.html Another example (setq ss (ssget "x" '((0 . "POINT")(cons 8 layname)))) the layname is a variable so has to be evaluated for layer name a (8 . layname) will error. Edited November 2, 2022 by BIGAL 1 Quote
mhupp Posted November 2, 2022 Posted November 2, 2022 (edited) @BIGAL Your ssget will error as well because its wrapped inside '( ) meaning it wont be evaluated. (even tho their is a cons inside) only when you use (list do things get evaluated. Edited November 2, 2022 by mhupp Quote
BIGAL Posted November 2, 2022 Posted November 2, 2022 (edited) Thanks mhupp just typed off the top of my head. Hmmmm (setq layname "0") (setq ss (ssget "x" '((0 . "POINT")(cons 8 layname)))) <Selection set: 00000000639E11A0> (sslength ss) 7 Edited November 2, 2022 by BIGAL 1 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.