I've done all sorts of modification to this routine and can't seem to get it to work right. It's supposed to do the following:
1- get 2 user points (GP1 & GP2)
2- Create 2 points (PT1 & PT2) based off GP1
3- Create a selection set (SEL) using PT2 and PT1
4- Move objects in SEL from GP1 to GP2
5- Move objects in SEL again .25 units to the right.
(defun C:DETAILMOVE (/ PROGRAM GP1 GP2 PT1 PT2) (while (/= nil (setq GP1 (getpoint "Move detail from [press ENTER to finish]: "))) (princ GP1) (setq GP2 (getpoint "Move detail to [press ENTER to finish]: ")) (princ GP2) (setq PT1 '((0.05- (car GP1)) (0.05- (cadr GP1)))) (setq PT2 '((5.1225+ (car GP1)) (7.05+ (cadr GP1)))) (setq SEL (ssget (PT2 PT1))) (command "._move" "BOX" SEL "" GP1 GP2 "._move" SEL "" "0,0" "@.25<0") ) ) (princ)
Solved! Go to Solution.
Solved by gccdaemon. Go to Solution.
Solved by Lee_Mac. Go to Solution.
Command: detailmove
Move detail from [press ENTER to finish]: Move detail to [press ENTER to finish]: ; error: bad function: (11.2095 7.05)
Command:
Even added the "Z" elevation and got the following:
Command: detailmove
Move detail from [press ENTER to finish]: Move detail to [press ENTER to finish]: ; error: bad function: (11.2095 7.05 0.0)
Command:
Here is the current code:
(defun C:DETAILMOVE (/ GP1 GP2 PT1 PT2 SEL) (while (/= nil (setq GP1 (getpoint "Move detail from [press ENTER to finish]: "))) (setq GP2 (getpoint "Move detail to [press ENTER to finish]: ") PT1 (list (- (car GP1) 0.05) (- (cadr GP1) 0.05) (caddr GP1)) PT2 (list (+ (car GP1) 5.1225) (+ (cadr GP1) 7.05) (caddr GP1)) SEL (ssget (PT2 PT1))) (command "._move" "BOX" SEL "" GP1 GP2 "._move" SEL "" "0,0" "@.25<0") ) ) (princ)
I did removed the box option, it needs two points...
And the bad function error was the (ssget (PT2 PT1))
(defun C:DETAILMOVE (/ GP1 GP2 PT1 PT2 SEL) (while (/= nil (setq GP1 (getpoint "Move detail from [press ENTER to finish]: ")) ) (setq GP2 (getpoint "Move detail to [press ENTER to finish]: ") PT1 (list (- (car GP1) 0.05) (- (cadr GP1) 0.05) (caddr GP1)) PT2 (list (+ (car GP1) 5.1225) (+ (cadr GP1) 7.05) (caddr GP1)) SEL (ssget "_C" PT2 PT1) ) (command "._move" SEL "" GP1 GP2 "._move" SEL "" "0,0" "@.25<0") ) (princ) )
HTH
Henrique
Some minor additions/changes:
(defun c:detailmove ( / gp1 gp2 sel ) (while (and (setq gp1 (getpoint "Move detail from <Done>: ")) (setq gp2 (getpoint "Move detail to <Done>: " gp1)) ) (if (setq sel (ssget "_C" (mapcar '- gp1 '(0.0500 0.05 0.0)) (mapcar '+ gp2 '(5.1225 7.05 0.0)) ) ) (command "_.move" sel "" "_non" gp1 "_non" gp2 "_.move" sel "" "_non" '(0.0 0.0) "_non" '(0.25 0.0) ) (princ "\nNo objects found.") ) ) (princ) )
Hmsilva: Your routine doesn't move the 0.25 to the right. Tried messing with it and it still wouldn't go almost like the last "move" command didn't work.
Lee: I tried yours and it did the move correctly, but the selection area was off. Looks like you had the SSget set to GP1 AND GP2. It just needed GP1.
Did some mods and this is what worked.
(defun C:DETAILMOVE (/ GP1 GP2 PT1 PT2 SEL) (while (and (setq gp1 (getpoint "Move detail from <Done>: ")) (setq gp2 (getpoint "Move detail to <Done>: " ))) (if (setq sel (ssget "_C" (mapcar '- gp1 '(0.0500 0.05 0.0)) (mapcar '+ gp1 '(5.1725 7.1 0.0)))) (command "_.move" sel "" "_non" gp1 "_non" gp2 "_.move" sel "" "_non" '(0.0 0.0) "_non" '(0.25 0.0)) (princ "\nNo objects found.")) ) (princ) )
Thanks again everyone!
@gccdaemon wrote:Lee: I tried yours and it did the move correctly, but the selection area was off. Looks like you had the SSget set to GP1 AND GP2. It just needed GP1.
Ah yes! - I overlooked that on your code
Glad you spotted my mistake & got it working!
It doesn't happen often, so I'd call myself lucky for finding it! You've found my mistakes in the past so I promise I won't rub it in, but I can't guarantee someone else won't...lol.
@gccdaemon wrote:
Hmsilva: Your routine doesn't move the 0.25 to the right. Tried messing with it and it still wouldn't go almost like the last "move" command didn't work.
...
Maybe some osnap issue?
On this side works...
Try
(defun C:DETAILMOVE (/ GP1 GP2 PT1 PT2 SEL) (while (/= nil (setq GP1 (getpoint "Move detail from [press ENTER to finish]: ")) ) (setq GP2 (getpoint "Move detail to [press ENTER to finish]: ") PT1 (list (- (car GP1) 0.05) (- (cadr GP1) 0.05) (caddr GP1)) PT2 (list (+ (car GP1) 5.1225) (+ (cadr GP1) 7.05) (caddr GP1)) SEL (ssget "_C" PT2 PT1) ) (command "._move" SEL "" "_non" GP1 "_non" GP2 "._move" SEL "" "_non" "0,0" "_non" "@.25<0") ) (princ) )
Henrique