Jump to content

Move an Object along an Axis using Coordinate Filters


Randolph

Recommended Posts

Hi,

 

I already had this issue in the thread Move objects to match x (y,z) -coordinate of another point. Alan helped me a lot with this, but somehow, it didn't work (to be precise, It works only once and only if the first value is 0).

 

What I'm looking for, is a routine to do the following example:

 

I have a column on the correct x,y-position n the floor plan, but positioned somewhere in height along the z-axis. Now I want to drop it onto a balcony, the z-height of which I also do not know by heart.

 

What I would love to do now would be to enter "tzp" (translate along z-axis to point), click any point on the base of the column, click any point on the floor level of the balcony, and the column will drop to the correct height.

 

What I'm doing now is either

1) to measure the distance, copy the z-value, enter "tz" (for translate in z-direction), paste the value, and enter or

2) use point filters. Enter "t" for translate, choose base point, click "xy", choose base point again, click "z", choose aim point.

 

Both ways are somewhat tiresome ... does anybody want to make me happy? Of course, it would be great, if this worked along all axis, but I'm 'fit' enough to make copies and change the axis parameters myself ... :)

 

Find attached what I'm working at right now and thanx!

Preview DOC sand-sand resized.jpg

Link to comment
Share on other sites

Kind of hack, but it does the job. I'm pretty sure this is what you wanted:

 

(defun c:tzp( / a b c s)
 (princ "Select objects: ")
 (setq s (ssget)
   a (getpoint "\nSelect item base point: ")
   b (getpoint "\nSelect target point: ")
   c (list (car a) (cadr a) (caddr b)))
 (vl-cmdf "move" s "" a c)
 )

 

Incidentally, that's one hell of a drawing. Very nice! :D

Link to comment
Share on other sites

Thanx it worx!

 

But concerning my boast to be fit enough to make copies and change the coordinates I must say that I am afraid I will have to give up.

 

Looks as if the trick was somewhere in the car, cadr and caddr ... car a and cadr a must be x and y of the first point ... ah - move from a to c where c is a with the 3rd value replaced by the 3rd value of b ... hell. Means for Y-axis I would have to write:

 

 
c (list (car a) (cadr b) (caddr a)))

Right? The code is astonishingly short!

 

I know there is also a possibility of using the mapcar command to get the commands for all 3 axis (txp, typ, tzp) in 1 code ...

 

Anyhow, here is a "duplicate" version dzp!

 

 
(defun c:dzp( / a b c s)
 (princ "Select objects: ")
 (setq s (ssget)
   a (getpoint "\nSelect item base point: ")
   b (getpoint "\nSelect target point: ")
   c (list (car a) (cadr a) (caddr b)))
 (vl-cmdf "copy" s "" a c)
 )

 

Not that I'm proud of my programming :wink:, but this is extremely practical when working with floors in architecture and your floor height is 3,2752 m! :D

Link to comment
Share on other sites

If it works, you're allowed a bit of pride, regardless of how "pretty" it is. :P

 

And good on you for actually studying and tweaking the code. You're allowed to take a bit of pride in the fact that you're going the extra mile to learn it, as well. :)

Link to comment
Share on other sites

Hi Tharwat,

 

sorry, as a non native speaker, I don't get your point ... what newspaper? And there is no turning of any axis to be monitored ...

Link to comment
Share on other sites

Here is the result - as I said, I know that this can be done more elegantly using mapcar, but I don't know how.

 

 
(defun c:TXP ( / a b c s)
 (princ "Select objects: ")
 (setq s (ssget)
   a (getpoint "\nSelect item base point: ")
   b (getpoint "\nSelect target point: ")
   c (list (car b) (cadr a) (caddr a)))
 (vl-cmdf "move" s "" a c)
 )
(defun c:TYP ( / a b c s)
 (princ "Select objects: ")
 (setq s (ssget)
   a (getpoint "\nSelect item base point: ")
   b (getpoint "\nSelect target point: ")
   c (list (car a) (cadr b) (caddr a)))
 (vl-cmdf "move" s "" a c)
 )
(defun c:TZP ( / a b c s)
 (princ "Select objects: ")
 (setq s (ssget)
   a (getpoint "\nSelect item base point: ")
   b (getpoint "\nSelect target point: ")
   c (list (car a) (cadr a) (caddr b)))
 (vl-cmdf "move" s "" a c)
 )

 

And here are the "copy" - versions:

 

 
(defun c:DXP ( / a b c s)
 (princ "Select objects: ")
 (setq s (ssget)
   a (getpoint "\nSelect item base point: ")
   b (getpoint "\nSelect target point: ")
   c (list (car b) (cadr a) (caddr a)))
 (vl-cmdf "copy" s "" a c)
 )

(defun c:DYP ( / a b c s)
 (princ "Select objects: ")
 (setq s (ssget)
   a (getpoint "\nSelect item base point: ")
   b (getpoint "\nSelect target point: ")
   c (list (car a) (cadr b) (caddr a)))
 (vl-cmdf "copy" s "" a c)
 )

(defun c:DZP ( / a b c s)
 (princ "Select objects: ")
 (setq s (ssget)
   a (getpoint "\nSelect item base point: ")
   b (getpoint "\nSelect target point: ")
   c (list (car a) (cadr a) (caddr b)))
 (vl-cmdf "copy" s "" a c)
 )

 

I hope this is useful for somebody else - for me it is definitely. Very happy and thanx Freerefill for your hack! :)

Link to comment
Share on other sites

What about using point filters?

 

eg.

(defun c:XYZ (/ axis ss pt)
 ;; Alan J. Thompson, 06.15.10
 (initget 0 "X Y Z")
 (if (and (setq axis (getkword "\nAxis filter [X/Y/Z]: "))
          (not (initget 0 "Copy Move"))
          (setq *XYZ:Mode*
                 (cond ((getkword (strcat "\nSpecify mode [Copy/Move] <"
                                          (cond (*XYZ:Mode*)
                                                ((setq *XYZ:Mode* "Copy"))
                                          )
                                          ">: "
                                  )
                        )
                       )
                       (*XYZ:Mode*)
                 )
          )
          (setq ss (ssget "_:L"))
          (setq pt (getpoint "\nSpecify base point: "))
     )
   (command (strcat "_." *XYZ:Mode*) ss "" "_non" pt (strcat "." axis) "_non" pt)
 )
 (princ)
)

Link to comment
Share on other sites

Hi Alan,

 

back again! Thanxalot, but personally, I prefer commands not to require options for the sake of the workflow. This is the reason for my nomenclature of commands (e.g. move commands will always start with a t). Also, I find Freerefills version of just replacing coordinate values quite elegant.

 

Anyhow, I don't want to bother you more than necessary - and I will need your help soon! :whistle:

Link to comment
Share on other sites

Hi Alan,

 

back again! Thanxalot, but personally, I prefer commands not to require options for the sake of the workflow. This is the reason for my nomenclature of commands (e.g. move commands will always start with a t). Also, I find Freerefills version of just replacing coordinate values quite elegant.

 

Anyhow, I don't want to bother you more than necessary - and I will need your help soon! :whistle:

I was just showing my example with options (X/Y/Z and Copy/Move). The biggest thing I like about it is it shows the object as you pick your second point.

More than anything, I wanted to show point filters. The other options can easily be removed as it's just an example with many options.

Link to comment
Share on other sites

  • 4 years later...

Hi Folks,

 

I was wondering if you know how to copy [Multiple]. I'm surprised none of you mentioned it so far. :o :facepalm: :rofl:

 

I have my own lisp which I modified to try make it work (to somewhat unsatisfactory results):

 

See below:

(defun c:CX ()
 (setq ss (ssget))
 (command "._copy" ss "" "M" pause ".yz" "@" pause)
 (setq ss nil);; add this line to clean the selection
 (princ)
)
(defun c:CY ()
 (setq ss (ssget))
 (command "._copy" ss "" "M" pause ".xz" "@" pause)
 (setq ss nil);; add this line to clean the selection
 (princ)
)
(prompt "\n:: Lock_Copy_X&Y.lsp loaded ::") (princ)
(prompt "\n:: Invoke by typing 'CX' (Copy on X-axis) or 'CY' (Copy on Y-axis) ::") (princ)

This locks on the first copy but on the subsequent ones after it doesn't. Any help would be greatly appreciated. Thanks.

Link to comment
Share on other sites

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