Author Topic: Subtrat or add Z to all items  (Read 143 times)

0 Members and 1 Guest are viewing this topic.

renkor

  • Mosquito
  • Posts: 20
Subtrat or add Z to all items
« on: June 11, 2019, 02:21:21 PM »
Hello all,

I need help you. I has a drawing with different elements (lines, plines, block, arcs....) with different Z value each one. And I would like to be able to subtract or add Z to all items (not move to Z=0)

Example:

Line 1-->original Z=5.
Line 1--> Desired Z=6+2 (2 or whatever I need)= 8. Or 6-2=4

ronjonp

  • Needs a day job
  • Posts: 6921
Re: Subtrat or add Z to all items
« Reply #1 on: June 11, 2019, 04:26:18 PM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ b i s)
  2.  ;; RJP 2019-06-11
  3.  (cond
  4.    ((and (setq i (getreal "\nEnter number [+ or -]: "))
  5.  (setq s (ssget ":L" '((0 . "arc,circle,insert,line,lwpolyline,*text"))))
  6.     )
  7.     (foreach a (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
  8.       (foreach x '(insertionpoint center elevation startpoint endpoint)
  9. (cond ((= 'list (type (vl-catch-all-apply 'vlax-get (list a x))))
  10. (setq b (vlax-get a x))
  11. (vl-catch-all-apply 'vlax-put (list a x (list (car b) (cadr b) (+ (caddr b) i))))
  12.       )
  13. )
  14.       )
  15.     )
  16.    )
  17.  )
  18.  (princ)
  19. )
« Last Edit: June 11, 2019, 04:30:10 PM by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12214
  • London, England
Re: Subtrat or add Z to all items
« Reply #2 on: June 11, 2019, 04:53:47 PM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:chz ( / s z )
  2.    (if (and (setq z (getreal "\nSpecify elevation change: "))
  3.             (setq s (ssget "_:L"))
  4.        )
  5.        (vl-cmdf "_.move" s "" "_non" '(0 0 0) "_non" (list 0 0 z))
  6.    )
  7.    (princ)
  8. )

ronjonp

  • Needs a day job
  • Posts: 6921
Re: Subtrat or add Z to all items
« Reply #3 on: June 12, 2019, 09:20:39 AM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:chz ( / s z )
  2.    (if (and (setq z (getreal "\nSpecify elevation change: "))
  3.             (setq s (ssget "_:L"))
  4.        )
  5.        (vl-cmdf "_.move" s "" "_non" '(0 0 0) "_non" (list 0 0 z))
  6.    )
  7.    (princ)
  8. )
Nice :)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12214
  • London, England
Re: Subtrat or add Z to all items
« Reply #4 on: June 12, 2019, 12:28:15 PM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:chz ( / s z )
  2.    (if (and (setq z (getreal "\nSpecify elevation change: "))
  3.             (setq s (ssget "_:L"))
  4.        )
  5.        (vl-cmdf "_.move" s "" "_non" '(0 0 0) "_non" (list 0 0 z))
  6.    )
  7.    (princ)
  8. )
Nice :)

Thanks  :-)

renkor

  • Mosquito
  • Posts: 20
Re: Subtrat or add Z to all items
« Reply #5 on: Today at 01:44:48 PM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ b i s)
  2.  ;; RJP 2019-06-11
  3.  (cond
  4.    ((and (setq i (getreal "\nEnter number [+ or -]: "))
  5.  (setq s (ssget ":L" '((0 . "arc,circle,insert,line,lwpolyline,*text"))))
  6.     )
  7.     (foreach a (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
  8.       (foreach x '(insertionpoint center elevation startpoint endpoint)
  9. (cond ((= 'list (type (vl-catch-all-apply 'vlax-get (list a x))))
  10. (setq b (vlax-get a x))
  11. (vl-catch-all-apply 'vlax-put (list a x (list (car b) (cadr b) (+ (caddr b) i))))
  12.       )
  13. )
  14.       )
  15.     )
  16.    )
  17.  )
  18.  (princ)
  19. )

Thanks for your time!

renkor

  • Mosquito
  • Posts: 20
Re: Subtrat or add Z to all items
« Reply #6 on: Today at 01:45:20 PM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:chz ( / s z )
  2.    (if (and (setq z (getreal "\nSpecify elevation change: "))
  3.             (setq s (ssget "_:L"))
  4.        )
  5.        (vl-cmdf "_.move" s "" "_non" '(0 0 0) "_non" (list 0 0 z))
  6.    )
  7.    (princ)
  8. )
Nice :)

Thanks  :-)

Now, I have two options hehe, thanks!