Jump to content

Recommended Posts

Posted

Given a specific block, how might I retrieve it's X, Y and Z coordinates, then move it's Z value to a specific depth (while keeping the x and y the same)?

 

Thanks

Posted
Given a specific block, how might I retrieve it's X, Y and Z coordinates, then move it's Z value to a specific depth (while keeping the x and y the same)?

 

Thanks

 

Something like this will helps:

 

 
(command "._move" block_entity_selected "" '(0 0 0) (list 0 0 Z))

 

~'J'~

Posted

Thanks Fixo,

Perhaps I need to clarify a bit - I need to add the value of a variable "depth" to the current Z value, and set that as the new Z value. I didn't think I could do that using a command call...?

Posted

then so

(setq Z (getreal "\nEnter delta Z value: "))
(princ "\nSelect block")
(setq ss (ssget "_:L" '((0 . "INSERT"))))
(command "_.MOVE" ss "" "0,0,0" (strcat "@0,0," (rtos Z 2 15)))

Posted
Thanks Fixo,

Perhaps I need to clarify a bit - I need to add the value of a variable "depth" to the current Z value, and set that as the new Z value. I didn't think I could do that using a command call...?

 

Here is Q&D example

Try it also

(defun C:MZ (/ elist en sset zv)
(setq zv (getreal "\nEnter a Z value to add to an existing Z value: "))
(princ "\n >>   Select block instance   >>")
 (if 
(setq sset (ssget "_:S:E:N" '((0 . "INSERT"))))
(progn
 (setq en (ssname sset 0))
 (setq elist (entget en)
ptlist (assoc 10 elist)
)
 (entmod (subst
    (cons 10 (list (car (cdr ptlist))
     (cadr (cdr ptlist))
     (+ (last (cdr ptlist)) zv)))
    ptlist
    elist)
  )
 (entupd en)
 )
)
 (princ)
 )

 

~'J'~

Posted

Thanks for your help Fixo

 

I'm sure there are better ways, but I ended up with this before the block insertion:

 

(setq x (car pt))
                 (setq y (cadr pt))
                 (setq Z1 (caddr pt))
                 (setq Z2 (+ depth Z1))
                 (setq PT2 (list x y Z2))

Posted
Thanks for your help Fixo

 

I'm sure there are better ways, but I ended up with this before the block insertion:

 

(setq x (car pt))
                 (setq y (cadr pt))
                 (setq Z1 (caddr pt))
                 (setq Z2 (+ depth Z1))
                 (setq PT2 (list x y Z2))

You're welcome

Happy computing :)

 

~'J'~

Posted
You're welcome

Happy computing :)

 

~'J'~

 

 

Ha, Let's call it "Happy LEARNING!"

 

Thanks

Posted

Easier still if you know the elavtion required before you insert the block just "Elevation" "Elev" and set value dont forget though set it back to 0.0

Posted
Easier still if you know the elavtion required before you insert the block just "Elevation" "Elev" and set value dont forget though set it back to 0.0

 

I don't in this case. I only know the depth below surface. The elevation is taken fromt he point on a 3D Pline - then moved below it.

 

...I just realized I am adding in my code where I need to subtract...:oops:

Posted

What about the Change command?

Command: change

Select objects: Specify opposite corner: 1 found

Select objects:
Specify change point or [Properties]: p

Enter property to change 
[Color/Elev/LAyer/LType/ltScale/LWeight/Thickness/Material/Annotative]: e

Specify new elevation <25.0000>: 52

Enter property to change 
[Color/Elev/LAyer/LType/ltScale/LWeight/Thickness/Material/Annotative]:

For fun...

(defun c:BEC (/ elev ss)
 (if (and (setq elev (getreal "\nSpecify elevation : "))
          (setq ss (ssget "_:L" '((0 . "INSERT"))))
     )
   ((lambda (i / ent)
      (while (setq e (ssname ss (setq i (1+ i))))
        (setq ent (entget e))
        (entmod (subst (reverse (cons elev (cdr (reverse (assoc 10 ent))))) (assoc 10 ent) ent))
      )
    )
     -1
   )
 )
 (princ)
)

FYI: a double reverse for each object is incredibly inefficient, but for a 4 item list, I figured I'd do it anyway. What's life without a little whimsy?

Posted

Interesting - always more than one way to do anything :)

Posted
Interesting - always more than one way to do anything :)

Only hurts the cat. :lol:

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