malix Posted May 22, 2011 Posted May 22, 2011 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. Quote
fixo Posted May 22, 2011 Posted May 22, 2011 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") Quote
Tharwat Posted May 22, 2011 Posted May 22, 2011 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 Quote
dbroada Posted May 22, 2011 Posted May 22, 2011 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? Quote
Lee Mac Posted May 22, 2011 Posted May 22, 2011 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. Quote
malix Posted May 22, 2011 Author Posted May 22, 2011 Wow, I was way off. Thanks for the help, these worked perfectly. Quote
BIGAL Posted May 23, 2011 Posted May 23, 2011 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. Quote
Recommended Posts
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.