Jump to content

Need Lisp : create rectangle between rectangle


git_thailand

Recommended Posts

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • pBe

    9

  • git_thailand

    6

  • MSasu

    4

  • ReMark

    2

Top Posters In This Topic

Posted Images

Another way with lisp pick two diag corners xoff yoff can be different draws new rectang. 3pt answer if rectang on angle.

 

I would go 3pt you can bet if you make it square only you need an angle version.

Link to comment
Share on other sites

Need lisp for create rectangle (red colour) between rectangle (black colour)

 

Looks easy enough. The only existing entiy is the black pline? and youre wanting to create 5 more? or just 4 not including the inner rectangle?

Link to comment
Share on other sites

I guess there are only two , aren't they ?:)

 

Oh yeah. :lol:... but it could also be four depending on how you see it. 5 even if you include the middle one as a separate entity.

 

Oh well....

 

(defun c:BeatBox (/ _HiLow _Box _trans rec pts low high)
 (defun _HiLow (lev lst)
   (list
     (apply lev (mapcar 'car lst))
     (apply lev (mapcar 'cadr lst))
   )
 )
 (defun _Box (p1 p2)
   (command "_rectang" "_non" p1 "_non" p2)
 )
 (setq _trans (lambda (pt) (trans pt 0 1)))
 (if (and
   (setq dist (cond
                   (   (getdist
                           (strcat "\nOffset Distance"
                               (if dist (strcat " <" (rtos dist) ">: ") ": ")
                           )
                       )
                   )
                   (   dist   )
               )
           )
   (setq rec (ssget 
      '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))
      )
   ))
   [color=blue](progn
[/color]    [color=blue](repeat  (setq i (sslength rec))
[/color]    (setq pts (mapcar 'cdr
       (vl-remove-if-not
         '(lambda (j)
     (= (car j) 10)
   )
         (entget (setq e (ssname rec [color=blue](setq i (1- i))))[/color])
       )
      )
  pts (mapcar '_trans pts)
   )
   (setq Low  (_HiLow 'min pts)
  High (_HiLow 'max pts)
   )
 (_Box (list (car low) (+ (cadr low) dist))
       (list (car high) (- (cadr high) dist))
 )
 (_Box (list (+ (car low) dist) (cadr low))
       (list (- (car high) dist) (cadr high))
 )
)
     )
 )
)

 

HTH

UPDATED:

Edited by pBe
Updated for Multiple objects
Link to comment
Share on other sites

create rectangle between two rectangle

 

Geez. I was right the first time. It is indeed 4. :lol:

 

But then again...

 

You really need a lisp routine to do this? Really??

 

I am wondering myself.

Link to comment
Share on other sites

A simple AutoLISP routine that will draw a rectangle between two other (aligned) will be no gain in productivity - if you have Endpoint Osnap activated, then the use of RECTANGLE command require just two clicks to get the result, while a routine will require selection of two entities.

Presuming that you have a big bunch of rectangles to connect on horizontal and vertical, then a routine may increase speed by allowing you to select all and then filtering them and connecting in pairs - but I'm afraind this will be a quite complicated code since need to validate coordinates of pairs and also check for potential overlapps.

Link to comment
Share on other sites

- but I'm afraind this will be a quite complicated code since need to validate coordinates of pairs and also check for potential overlapps.

 

 

I'll pass Mircea :lol:.

Link to comment
Share on other sites

No one called you "stupid" and pBe gave you a lisp routine in post #7. If it does not suit your needs please explain where the routine falls short or try fixing it yourself.

Link to comment
Share on other sites

see pic #8

Some members posts a somewhat "odd" requests but it doesnt mean it can't be done and "stupid" they're not. No offense git_thailand but what you're asking would redefine the word lackadaisicalness to a new level.

Plus the first image you posted can be interpreted in many ways other than what you need [hence my mis-interpreted routine]

 

If you badly need a code, you can start by explaining to us what that image really meant, I know that a picture is worth a thousand words but can you give us more information.

Maybe there's more to it than what we like to think.

Link to comment
Share on other sites

Request like a boss ^^

 

:lol: Yeah, that works 99% of the time, but it doesnt mean you're going to get what you asked for ALL the time.

 

The result is only as good as the information you give us git_thailand.

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