Jump to content

Spacing LISP


Paul H

Recommended Posts

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

Link to comment
Share on other sites

Is the spacing random?

 

I know of a VLX lisp program called Scatter:

 

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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