Jump to content
masterfal

move objects specific distance

Recommended Posts

masterfal

Hi, i'm trying to set up a lisp routine that lets me move selected objects a specific distance in specific direction

eg - typing up50 moves selected objects vertically 50000 (i'd like to be able to skip the base point selection as its somewhat irrelevant. and if it could use the selected objects as opposed to asking for which objects to move that would also save some time)

 

failed attempt below..

(defun c:UP50 () (command "MOVE" pause "" pause @50000<90))

any help appreciated!

Share this post


Link to post
Share on other sites
satishrajdev

Try this

(defun c:UP50 () (command "MOVE" pause "" pause "@50000<90"))

Share this post


Link to post
Share on other sites
masterfal

the code above works but only for selecting 1 object at a time.. can it be amended to allow for multiple objects (or even better currently selected objects)?

Share this post


Link to post
Share on other sites
Tharwat

Hi,

(defun c:up50 (/ ss)
  (if (setq ss (ssget "_:L-I"))
    (command "_.MOVE" ss "" "_non" '(0. 0.) "_non" '(0. 5000.))
  )
  (princ)
)

 

Edited by Tharwat

Share this post


Link to post
Share on other sites
masterfal

perfect!!!!

Share this post


Link to post
Share on other sites
Grrr

Hi @Tharwat,

You don't need the second ssget prompt, since the "_:L-I" mode will try to obtain the implied selection (if theres one) else it will prompt for a new selection, hence simulating (ssget "_:L").

:)

 

Share this post


Link to post
Share on other sites
Tharwat

 

3 minutes ago, Grrr said:

Hi @Tharwat,

You don't need the second ssget prompt, since the "_:L-I" mode will try to obtain the implied selection (if theres one) else it will prompt for a new selection, hence simulating (ssget "_:L").

:)

 

Apparently you did not read what the OP wrote in their second reply. ;) 

6 hours ago, masterfal said:

the code above works but only for selecting 1 object at a time.. can it be amended to allow for multiple objects (or even better currently selected objects)?

Share this post


Link to post
Share on other sites
Grrr
27 minutes ago, Tharwat said:

Apparently you did not read what the OP wrote in their second reply. ;) 

 

I see, but what I'm saying (in my previous post) is that theres no difference in the behaviour between:

(setq ss (ssget "_:L-I"))

and:

(or (setq ss (ssget "_:L-I"))
  (setq ss (ssget "_:L"))
)

hence including the  (setq ss (ssget "_:L")) and wrapping it within the or function is redundant.

Edited by Grrr
  • Thanks 1

Share this post


Link to post
Share on other sites
Tharwat

Aha, you are right. :thumbsup: 

Thank you for pointing this out to me.

  • Like 1

Share this post


Link to post
Share on other sites
BIGAL

Something to think about is that you can have a reactor that looks at say the 1st character and then looks at the distance required eg u5000 is move 5000 up, R250 move 250 to right what I am saying is that rxxxx can be any distance you like, the reactor detects that an error has occured, L345 is not a valid command so checks the error looks for "L" then pulls the distance out 345.

 

I use this for fillet circle offset, If I type C23 it will draw a circle with radius 23.

 

Its a bit of code I have used for around 3 years now and should work nicely for what you want. It will have to be modified for move so have a go if you get stuck post again.

 

 

Command reactor C O F etc.lsp

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×