Jump to content

Recommended Posts

Posted

I'm a beginner with AutoLISP, and for some reason I can't get this move command to work right. All I want to do is select everything in a crossing window from (12,0) to (0,4) and move it all 12 inches to the right.

 

This is what I have, but when I run the program it's only grabbing the title block and leaving everything else in place.

 

(command "move" "12,0" "0,4" "" "@" "@12,0" )

 

Do I need to use ssget or some other selection command to pick multiple entities?

 

Thanks in advance.

Posted

There are many ways how to do it, e.g.:

 

(setq wpt1 '(12 0)
     wpt2 '(0 
4)      
     disp 
12
     ang 0

movept (mapcar '+ wpt1 (list disp 0));;you can use instead : move pt (list (+ 
(car wpt1 disp)(cadr wpt1)))
     )
(command 
"move" (ssget "w" wpt1 wpt2) "" "_non" wpt1 "_non" movept)

 

this code should work as well

 

(command "_select" "_w" "12,0" "0,4" "" "move" "_p" "" "@" "@12,0")

Posted

Another ...

 

(defun c:test (/ ss l sset)(vl-load-com)
 (if (setq ss (ssget "_w" '(12. 0. 0.) '(0. 4. 0.)))
   (repeat
     (setq l (sslength ss))
      (setq sset (ssname ss (setq l (1- l))))
      (vla-move (vlax-ename->vla-object sset)
                (vlax-3d-point 0. 0. 0.)
                (vlax-3d-point 12. 0. 0.)
      )
   )
 )
 (princ)
)

Tharwat

Posted

this code should work as well

 

(command "_select" "_w" "12,0" "0,4" "" "move" "_p" "" "@" "@12,0")

shouldn't that be "_c" for a crossing window?
Posted

I would approach it this way:

 

(defun c:test ( / ss )
 (if (setq ss (ssget "_C" '(12.0 0.0) '(0.0 4.0)))
   (command "_.move" ss "" "_non" '(0. 0. 0.) "_non" '(12. 0. 0.))
 )
 (princ)
)

 

Since ssget will provide a more versatile and reliable selection.

Posted

Wow, I was way off.

 

Thanks for the help, these worked perfectly. :D

Posted

WoW WOW if i add another way that makes 5 different ways to do a simple move does this beat the record.

 

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

 

Sorry to go off track.

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