Jump to content

Recommended Posts

Posted

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.

Posted

It is very doable, however the comma will probably lead to errors. What is it's use? -David

Posted

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))
)

Posted
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.

Posted

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)))
)

Posted

Thanks Tharwat, that worked well. I think I can figure out the rest from here. Thanks guys.

Posted

Perhaps even so...

 

 

(foreach point l
   (setq pt
            (cons
                (list
                    (atof (rtos (car  point) 2 2))
                    (atof (rtos (cadr point) 2 2))
                )
                pt
           )
   )
)

Posted
Thanks Tharwat, that worked well. I think I can figure out the rest from here. Thanks guys.

 

You're welcome Rick

  • 2 years later...
Posted

hi -Remove Z coordinates points in autocad

 

1-all select points

2-command: properties

3-selection /point

4-geometry / position z =0

:) ما توی فارسی میگیم برو حالشو ببر

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...