Move Command

Move Command

garyl
Contributor Contributor
5,294 Views
5 Replies
Message 1 of 6

Move Command

garyl
Contributor
Contributor

Pretty much a newby to AutoLISP, I have workd in several other languages, I think this is just a syntax issue but I cant seem to find the solution.

 

Object: a simple LISP routin that rund from inside blockeditor, it moves all enities within the block to be centered on 0,0,0 by doing that when it is finished the block insertation point will be the center of the bolck.

 

here is my routine

 

(defun C:Myprog()
(command "_zoom" "extents")
(setq p1 (getvar "VIEWCTR"))
(setq ss1 (ssget "X"))
(command "_move" !ss1 "" !p1 "@0,0,0")
(princ)
)

 

When I run the commands interactivly here is what I get

 

Command: (command "_zoom" "extents")
_zoom
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: extents
Command: nil
Command: (setq p1 (getvar "VIEWCTR"))
(4.55988 6.96857 0.0)
Command: (setq ss1 (ssget "X"))
<Selection set: 228>
Command: (command "_move" !ss1 "" !p1 "@0,0,0")
_move
Select objects:
Command: @@0,0,0 Unknown command "@0,0,0". Press F1 for help
Command: nil

 

The problem seems to be with entering "@0,0,0" and the final destination point of the move, I have tried several different variation but cant seem to find the correct syntax for enterint that point into the move command.

 

 

0 Likes
Accepted solutions (1)
5,295 Views
5 Replies
Replies (5)
Message 2 of 6

Satoews
Advocate
Advocate

Nvm read to fast, I should never post at work.

Shawn T
0 Likes
Message 3 of 6

garyl
Contributor
Contributor
!p1
0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

Like this... or just...

 

(defun C:Myprog ( / p1 ss1)
  (command "_zoom" "extents")
  (setq p1 (getvar "VIEWCTR"))
  (setq ss1 (ssget "X"))
  (command "_move" ss1 "" "_none" p1 "_none" "0,0,0")
  (princ)
  )

(defun C:Myprog2 nil
  (command "_.zoom" "_extents"
	   "_.move" (ssget "_X") "" "_none" (getvar 'VIEWCTR) "_none" "0,0,0")
  (princ)
)

 Edit: it's important to turn the OSNAPs off. They are still running... you could get unexpected result. Put "_none" in front of point inside of (command) function.

0 Likes
Message 5 of 6

dbroad
Mentor
Mentor

Related to Beekee's post,  you only include the exclamation point when accessing lisp symbol values from the command line, not within the command function.  Also, the entry "@0,0,0" would move it nowhere from the last point.  As Beekee did, the point would be entered without the @ symbol.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 6 of 6

garyl
Contributor
Contributor
that works, I like the shortened version too.

Thanks
0 Likes