Jump to content

MOVE 3D filters HELP


leonucadomi
 Share

Recommended Posts

hello people:

 

 

 

can you help me with a routine to move objects but only move in coordinate "x"  or "y" or  "z"

 

something like moving with filters but in routine

 

thanks

 

Any help is welcome

 

Link to comment
Share on other sites

You can write little lisp for move  X Y Z etc. Load on say startup.

 

(defun C:CHX ( / ht sn)
  (SETVAR "CMDECHO" 0)
  (setq sn (getvar "osmode"))
  (command "osnap" "near")
  (princ "\nalters object in X direction")
  (setq ht (getstring "\n What is amount of change: "))
  (setq newht (strcat ht ",0,0"))
  (while 
    (setq newobj (entsel "\nPoint to object: "))
        (command "move" newobj "" "0,0,0" newht)
    )
    (setvar 'osmode sn)
    (princ)
)

 I will let you work out Y & Z

Link to comment
Share on other sites

I normally use this at work... When prompting points in AutoCAD, AutoCAD supports ".X", ".Y" and ".Z" filters that allows you to click a point that fixes the X, Y or Z depending on what's picked. What you're looking for is MX and MY (Move along X) and (Move along Y), but I had other command like COPY, STRETCH and LINE:

 

(defun c:lx nil (CommandDirection (list "_LINE" pause) ".Y"))
(defun c:ly nil (CommandDirection (list "_LINE" pause) ".X"))
(defun c:cx (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_COPY" ss "" pause) ".Y")))
(defun c:cy (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_COPY" ss "" pause) ".X")))
(defun c:mx (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_MOVE" ss "" pause) ".Y")))
(defun c:my (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_MOVE" ss "" pause) ".X")))
(defun c:sx (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_STRETCH" ss "" pause) ".Y")))
(defun c:sy (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_STRETCH" ss "" pause) ".X")))

;; Command Direction - Jonathan Handojo
;; Creates a command that constraints point prompts to X, Y or Z axis.
;; cmd - a list of strings to pass into the AutoCAD command function.
;;      => The last string in the list must be a point selection.
;; dir - a string of either ".X", ".Y" or ".Z"

(defun CommandDirection (cmd dir)
    (apply 'command cmd)
    (while (not (zerop (getvar "cmdactive"))) 
        (command dir "@0,0,0" pause)
    )
)

 

Edited by Jonathan Handojo
  • Like 1
Link to comment
Share on other sites

 

I use this one that I made but sometimes it works and sometimes it moves the object to another side I don't know what is wrong

 

 

(defun c:-7 (/ pt1 pt2 pt3 P1Y P1Z P2X)


 (princ "\nMove in X")
(setvar "cmdecho" 0)
(command "_osmode" "16383")
(setq ss (ssget))
(setq pt1 (getpoint "\nSelecciona punto de origen: "))
(setq pt2 (getpoint "\nSelecciona punto de destino: "))
(setq P1Y (cadr pt1))
(setq P1Z (caddr pt1))
(setq P2X (car pt2))
(setq pt3 (list P2X P1Y P1Z))
(progn
(command "_osmode" "0")
(command "_move" ss "" pt1 pt3 "")
(command "_osmode" "16383")
(setvar "cmdecho" 1)
)
(princ "\nObjeto desplazado...")
(princ)

  );fin defun

Link to comment
Share on other sites

6 hours ago, leonucadomi said:

 

I use this one that I made but sometimes it works and sometimes it moves the object to another side I don't know what is wrong

 

 

(defun c:-7 (/ pt1 pt2 pt3 P1Y P1Z P2X)


 (princ "\nMove in X")
(setvar "cmdecho" 0)
(command "_osmode" "16383")
(setq ss (ssget))
(setq pt1 (getpoint "\nSelecciona punto de origen: "))
(setq pt2 (getpoint "\nSelecciona punto de destino: "))
(setq P1Y (cadr pt1))
(setq P1Z (caddr pt1))
(setq P2X (car pt2))
(setq pt3 (list P2X P1Y P1Z))
(progn
(command "_osmode" "0")
(command "_move" ss "" pt1 pt3 "")
(command "_osmode" "16383")
(setvar "cmdecho" 1)
)
(princ "\nObjeto desplazado...")
(princ)

  );fin defun

 

 

I really don't see anything wrong with the code you've put up. It seems to work perfectly fine on my end. My guess is that you're probably working with xrefs and then your snap point when prompting just goes to the insertion point of the xref? It seems to be a very common problem  for me as well. But otherwise, you may need to describe what you mean by "another side".

 

If anything, you can simplify it to something like this:

 

(defun c:-7 ( / ) 
    (command "_move" (ssget) "" pause ".Y" "_non" "@0,0,0" pause)
)

 

Edited by Jonathan Handojo
Link to comment
Share on other sites

WHAT I SAY IS THAT SOMETIMES IT WORKS AND OTHERS IT DOESN'T.

 

ESPECIALLY WHEN I HAVE THE PERSPECTIVE VIEW

 

AS IF YOU DO NOT RESPECT THE SNAP

Link to comment
Share on other sites

 

 

 

(defun c:-7 ( / ) (command "_move" (ssget) "" pause ".Y" "_non" "@0,0,0" pause) )

 

 

DOES NOT WORK MOVE BY MODIFYING X , Y AND Z  :(

Link to comment
Share on other sites

Ah, I was under the assumption that you work in 2D. If you're working in 3D, then change ".Y" to ".YZ" to move along X, ".XZ" to move along Y, and ".XY" to move along Z.

Link to comment
Share on other sites

Almost forgot for X & Y

Move select objects

pick a point

press F8

drag mouse in direction required

type in the offset all done

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

 Share

×
×
  • Create New...