Rick_Ismael Posted January 10, 2012 Posted January 10, 2012 Hi guys, I'm stuck and need your help. I have a list: ( setq l ((34.1795 -24.8328 0.0) (21.1241 -65.0132 0.0) (-21.1241 -65.0132 0.0) (-34.1795 -24.8328 0.0))) I want to remove the Z coordinate, round off the value to the nearest hundreds and put comma after the X coordinates. I can't figure out on how to use mapcar on the list. My goal is to have values like this: ((34.18, -24.83) (21.12, -65.01) (-21.12, -65.01) (-34.18, -24.83)) Thank you. Quote
David Bethel Posted January 10, 2012 Posted January 10, 2012 It is very doable, however the comma will probably lead to errors. What is it's use? -David Quote
Tharwat Posted January 10, 2012 Posted January 10, 2012 Check this out ..... (setq l '((34.1795 -24.8328 0.0) (21.1241 -65.0132 0.0) (-21.1241 -65.0132 0.0) (-34.1795 -24.8328 0.0) ) ) (foreach point l (setq pt (cons (list (car point) (cadr point)) pt)) ) Quote
Rick_Ismael Posted January 10, 2012 Author Posted January 10, 2012 It is very doable, however the comma will probably lead to errors. What is it's use? -David I'm trying to get all the points on a pline assign each point on a variable and schedule all points. It's use for plotting the highs and lows of a certain stock (stock market) via coordinates. Quote
Lee Mac Posted January 10, 2012 Posted January 10, 2012 I see no need for the comma, here is a quick example: (defun c:test ( / l ) (setq l '( ( 34.1795 -24.8328 0.0) ( 21.1241 -65.0132 0.0) (-21.1241 -65.0132 0.0) (-34.1795 -24.8328 0.0) ) ) (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length l)) '(70 . 0) ) (mapcar (function (lambda ( p ) (list 10 (round (car p) 0.01) (round (cadr p) 0.01) ) ) ) l ) ) ) (princ) ) ;;; Written by Doug Broad ;;; If value given 'to' argument is a real, a real is returned. ;;; Rounds to nearest multiple of 'to' real or integer. (defun round (value to) (setq to (abs to)) (* to (fix (/ ((if (minusp value) - +) value (* to 0.5)) to))) ) Quote
Rick_Ismael Posted January 10, 2012 Author Posted January 10, 2012 Thanks Tharwat, that worked well. I think I can figure out the rest from here. Thanks guys. Quote
GP_ Posted January 10, 2012 Posted January 10, 2012 Perhaps even so... (foreach point l (setq pt (cons (list (atof (rtos (car point) 2 2)) (atof (rtos (cadr point) 2 2)) ) pt ) ) ) Quote
Tharwat Posted January 11, 2012 Posted January 11, 2012 Thanks Tharwat, that worked well. I think I can figure out the rest from here. Thanks guys. You're welcome Rick Quote
ali565 Posted June 12, 2014 Posted June 12, 2014 hi -Remove Z coordinates points in autocad 1-all select points 2-command: properties 3-selection /point 4-geometry / position z =0 ما توی فارسی میگیم برو حالشو ببر 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.