Jump to content
Paul H

Spacing LISP

Recommended Posts

Paul H

Hi

 

Does anyone know of a LISP routine that would create a space between objects? Array would be fine for one object repeated, what if the objects were all different?

 

I spend a lot of time manually spacing objects...

 

Thanks

Share this post


Link to post
Share on other sites
ReMark

Is the spacing random?

 

I know of a VLX lisp program called Scatter:

 

"move selected objects randomly in 2D or 3D - orchard, parking, crowd..."

Share this post


Link to post
Share on other sites
pBe
Hi

 

Does anyone know of a LISP routine that would create a space between objects? Array would be fine for one object repeated, what if the objects were all different?

 

I spend a lot of time manually spacing objects...

 

Thanks

 

Whats the reason for the spacing? just moving the entities away from the next entitiy for clarity?

Share this post


Link to post
Share on other sites
Tharwat
Whats the reason for the spacing? just moving the entities away from the next entitiy for clarity?

 

Hi pBe.

 

Suppose that he has tens of Circles and Texts and wanted to separate them from each other with a specific length of distance ! So Array command won't

allow him to select more than one entity at the same time .

 

And to go with Move command , that's a matter of long time to do the trick .

 

Thanks

Share this post


Link to post
Share on other sites
pBe
Hi pBe.

 

Suppose that he has tens of Circles and Texts and wanted to separate them from each other with a specific length of distance !

Thanks

 

You think so tharwat? Anyway lets be patient. Its best that we wait for the OP to clarify that for us.

 

Cheers

Share this post


Link to post
Share on other sites
Tharwat

I guess so , because he mentioned objects which gave me the inspiration to say it might be different sorts of entities . :)

 

Cheers.

Share this post


Link to post
Share on other sites
BIGAL

It does not matter what it is, what counts is how you work out box size that contains the object, if you took 100 blocks and did a 10x10 grid chances are some blocks would be to big and overlap.

 

You could do this in a number of ways read file/excell that sets size of box, create a new layout tab place block or objects and work out its extents min max this gives box size then erase all jump back and add object keep a record of x max and y max if multi rows required but do able. This is definately do able you get a different answer for extmin extmax for every layout tab.

Share this post


Link to post
Share on other sites
alanjt

Quickie. I'll clean it up and post some code tomorrow.

spacer.gif

 

EDIT:

ahh, screw it, here (be forewarned, it's sloppy as hell):

 

(defun _bboxAndMid (obj / a b l)
 (vla-getboundingbox obj 'a 'b)
 (list (car (setq l (mapcar 'vlax-safearray->list (list a b))))
       (apply '(lambda (a b) (mapcar '(lambda (a b) (/ (+ a b) 2.)) a b)) l)
       (cadr l)
 )
)

(defun ss->lst (ss / i l)
 (if (eq (type ss) 'PICKSET)
   (repeat (setq i (sslength ss))
     (setq l (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) l))
   )
 )
)




(defun c:Test (/ lst p1 g p2 a d)
 (if (and (setq lst (ss->lst (ssget "_:L")))
          (setq p1 (getpoint "\nSpecify first point: "))
     )

   (while (eq 5 (car (setq g (grread T 15 0))))
     (redraw)
     (grdraw p1 (polar (setq p2 (cadr g)) (angle p1 p2) 10000000.) 1 -1)

     (setq p1 (trans p1 1 0)
           p2 (trans p2 1 0)
           a  (angle p1 p2)
           d  (/ (distance p1 p2) (float (length lst)))
     )

     (vla-move (car lst) (vlax-3d-point (cadr (_bboxAndMid (car lst)))) (vlax-3d-point p1))

     (mapcar
       '(lambda (o1 o2 / l)
          (vla-move o2
                    (vlax-3d-point (cadr (_bboxAndMid o2)))
                    (vlax-3d-point
                      (polar (cadr (setq l (_bboxAndMid o1)))
                             a
                             (+ d (distance (car l) (caddr l)))
                      )
                    )
          )
        )
       lst
       (cdr lst)
     )
   )
 )
 (redraw)
 (princ)
)

Share this post


Link to post
Share on other sites
Paul H

Thanks for all the quick responses guys!

 

Thanks reMark, I do need ordered spacing though...

 

Yeah pBe, it's basically laying out structures in order to dim up and annotate...

 

Looks like alnajt's routine should do the trick, thanks mate...

 

Love this site!

Share this post


Link to post
Share on other sites
ReMark

Nice job Alan.

Share this post


Link to post
Share on other sites
alanjt

Thanks guys, but like I said, it's sloppy. I was waiting on my wife to finish American Idol so I could watch Spaceballs. I wrote this in about five minutes, using the fist bad idea that popped in my head.

Share this post


Link to post
Share on other sites
Paul H
Thanks guys, but like I said, it's sloppy. I was waiting on my wife to finish American Idol so I could watch Spaceballs. I wrote this in about five minutes, using the fist bad idea that popped in my head.

 

Heh!

 

One last thing alanjt, I'm just being dumb...what is the command to launch the routine? I'm fairly new to LISP, is it _bboxandmid?

 

Ta

 

Paul

Share this post


Link to post
Share on other sites
alanjt
Heh!

 

One last thing alanjt, I'm just being dumb...what is the command to launch the routine? I'm fairly new to LISP, is it _bboxandmid?

 

Ta

 

Paul

Sorry, I needed two subroutines and I wrote them on the forefront - like I said, this is sloppy as hell. The actual routine is at the bottom, and I just called it test - rename it what you like.

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

×