Jump to content

Recommended Posts

Posted

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!

Posted

Try this

(defun c:UP50 () (command "MOVE" pause "" pause "@50000<90"))
  • 2 months later...
Posted

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)?

Posted (edited)

Hi,

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

 

Edited by Tharwat
Posted

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

:)

 

Posted

 

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)?

Posted (edited)
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
Posted

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

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