Jump to content

Lisp needed for Move objects with specific distance


dreams

Recommended Posts

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • dreams

    5

  • BIGAL

    4

  • mihaibantas

    4

  • Tharwat

    3

Top Posters In This Topic

Posted Images

Having seen a quite similar request in the SIMILAR THREADS box,

it certainly looks like this lisp of Lee's from the other thread could be made to work for you by adjusting the X & Y values highlighted in yellow. :)

 

Replace the -20 in the X field with 0. and the Y value with -10, and I am guessing you should be good to go.

trust Lee, he's usually correct.JPG

Link to comment
Share on other sites

Thanks Dadgad...

 

Having seen a quite similar request in the SIMILAR THREADS box,

it certainly looks like this lisp of Lee's from the other thread could be made to work for you by adjusting the X & Y values highlighted in yellow.

 

Replace the -20 in the X field with 0. and the Y value with -10, and I am guessing you should be good to go.

 

Yes..I had checked with Lee's lisp with changing Y value but I need to move objects from selected point with distance..

 

I am not familiar with visual lisp... Can i have any suggestion to edit that lee's lisp...?

Link to comment
Share on other sites

Yes..I had checked with Lee's lisp with changing Y value but I need to move objects from selected point with distance..

 

The point from which the displacement is measured is irrelevant, you would receive the same result for any base point in the drawing.

Link to comment
Share on other sites

The point from which the displacement is measured is irrelevant, you would receive the same result for any base point in the drawing.

 

Thanks Lee...I got your point but I want to move selected objects with distance to another location that where I have to pick point (New location)...

Link to comment
Share on other sites

Things like this ?

 

(defun c:Test (/ ss p1 p2)
 (if (and (setq ss (ssget "_:L"))
          (setq p1 (getpoint "\n Specify base point :"))
          (setq p2 (getpoint "\n Specify New base point :" p1))
          )
   (progn (command "_.move" ss "" "_non" p1 "_non" p2)
          (command "_.move" ss "" "_non" p1 "_non" (polar p1 (* pi 1.5) (* 25.4 10.)))
          )
   (princ)
   )
 (princ)
 )

Edited by Tharwat
Link to comment
Share on other sites

Hi Tharwat...Its working fine...but I expected objects to be move in -Y axis (ie. Below picked point)...Is it possible to modify your lisp?

Link to comment
Share on other sites

  • 4 years later...

Hi all, I tried to modify lisp above ... I want to sit 4 sets of objects in the following scheme.

1

2

3

4

to

1 3

2 4

where am I wrong ??? Thank you for your time.

 

(defun c:test ( / p1 p2 p3 p4 ss )
   (if
       (and
           (setq ss (ssget "_:L"))
           (setq p1 (getpoint "\Point for Basepoint1: "))
           (setq p2 (getpoint "\Point for Basepoint2: "))
           (setq p3 (getpoint "\Point for Basepoint3: "))
           (setq p4 (getpoint "\Point for Basepoint4: "))
       )
       (progn(command "_.move" ss "" 
       "_none" p1 "_none" '(25.00 166.00 0.00)
       "_none" p2 "_none" '(25.00 45.00 0.00)
       "_none" p3 "_none" '(217.50 166.00 0.00)
       "_none" p4 "_none" '(217.50 45.00 0.00)
       )
   )
)
   (princ)
)

Link to comment
Share on other sites

Depending on the objects an alternative would be pick lower left, hor space, ver space. This would be applicable for blocks text etc or as per a recent post using a bounding box. You can then have grid combos 2x2 2x3 etc.

Link to comment
Share on other sites

Hello Lee Mac,

Firstly I want to thank you for the answers given.

I tried to invoke the MOVE command in the above code ... I do not know where I'm wrong.

Attached you will find my attempt to introduce give command MOVE.

 

(defun c:test ( / p1 p2 p3 p4 ss )
   (if
       (and
           (setq ss (ssget "_:L"))
           (setq p1 (getpoint "\Point for Basepoint1: "))
           (setq p2 (getpoint "\Point for Basepoint2: "))
           (setq p3 (getpoint "\Point for Basepoint3: "))
           (setq p4 (getpoint "\Point for Basepoint4: "))
       )
       (progn
       (command "_.move" ss "" "_none" p1 "_none" '(25.00 166.00 0.00)) ;want to move Basepoint1 in x, y coordinate 25.00, 166.00
       (command "_.move" ss "" "_none" p2 "_none" '(25.00 45.00 0.00))
       (command "_.move" ss "" "_none" p3 "_none" '(217.50 166.00 0.00))
       (command "_.move" ss "" "_none" p4 "_none" '(217.50 45.00 0.00))
       )
)
   (princ)
)

 

Here's some pictures of what I want to do.

attachment.php?attachmentid=60540&cid=1&stc=1

 

and finally selected objects to place in positions x, y wanted

attachment.php?attachmentid=60541&cid=1&stc=1

 

Thank you in advance for your cooperation. I wish you a good day.

Initial.jpg

FINAL.jpg

Link to comment
Share on other sites

Hello Lee Mac and BIGAL

Firstly I want to thank you for the answers given.

Lee Mac i tried to invoke the MOVE command in the above code ... I do not know where I'm wrong.

Attached you will find my attempt to introduce give command MOVE.

BIGAL i want to move objects such as lines, polylines and text blocks.

 

(defun c:test ( / p1 p2 p3 p4 ss )
   (if
       (and
           (setq ss (ssget "_:L"))
           (setq p1 (getpoint "\Point for Basepoint1: "))
           (setq p2 (getpoint "\Point for Basepoint2: "))
           (setq p3 (getpoint "\Point for Basepoint3: "))
           (setq p4 (getpoint "\Point for Basepoint4: "))
       )
       (progn
       (command "_.move" ss "" "_none" p1 "_none" '(25.00 166.00 0.00)) ;want to move Basepoint1 in x, y coordinate 25.00, 166.00
       (command "_.move" ss "" "_none" p2 "_none" '(25.00 45.00 0.00))
       (command "_.move" ss "" "_none" p3 "_none" '(217.50 166.00 0.00))
       (command "_.move" ss "" "_none" p4 "_none" '(217.50 45.00 0.00))
       )
)
   (princ)
)

 

 

Thank you in advance for your time.

Link to comment
Share on other sites

Moving multiple objects will be a bit more difficult but can be done using "Group" or individual selection sets if you have say 1 lot of lines, 1 text, 1 block, and line/arcs etc the easiest way would be to multiple pick the 4 selections, looking for gaps in one big selection would require a lot more coding. Back to my lower left and hor and ver. Pick group 1, pick group 2 etc all done.

Link to comment
Share on other sites

Hi all, I managed to make my code to bring the four frames in the desired points .... thank you for the advice given.

 

code has the following operations:

select items first frame > select the point where the objects of first frame to be moved ... and keep operations up to four frame.

 

(defun c:test ( / p1 p2 p3 p4 ss1 )
   (if
       (and
           (setq ss1 (ssget "_:L"))
               (setq p1 (getpoint "\Point for Basepoint1: "))
               (setq ss2 (ssget "_:L"))
               (setq p2 (getpoint "\Point for Basepoint2: "))
               (setq ss3 (ssget "_:L"))
               (setq p3 (getpoint "\Point for Basepoint3: "))
               (setq ss4 (ssget "_:L"))
               (setq p4 (getpoint "\Point for Basepoint4: "))
       )
       (progn
       (command "_.move" ss1 "" "_none" p1 "_none" '(25.00 166.00 0.00))
       (command "_.move" ss2 "" "_none" p2 "_none" '(25.00 45.00 0.00))
       (command "_.move" ss3 "" "_none" p3 "_none" '(217.50 166.00 0.00))
       (command "_.move" ss4 "" "_none" p4 "_none" '(217.50 45.00 0.00))
       )
)
   (princ)
)

Link to comment
Share on other sites

For that particular example I think:

  • Initially create the sorted pointlist: (list '(25.00 166.00 0.00) '(25.00 45.00 0.00) '(217.50 166.00 0.00) '(217.50 45.00 0.00) )
  • Prompt for a single selection of rectangle-LWPolylines
  • For each LWPolyline look for a object with TextString, wcmatching to "#"
  • Get BBOX for each LWPolyline
  • For the list of ( ) sort the list by the numerical TextString
  • For each point of the pointlist, Move the SS from its lower-left bbox point to the corresponding point

Link to comment
Share on other sites

I agree Grr see my post #12 bounding box still think pick lower left, pick right, pick up, do we really need to hard code the points shift use (getdist pt1 "next point') etc can still type a number if required.

Link to comment
Share on other sites

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