Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Distribute blocks equally between two points

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
JCprog
2078 Views, 8 Replies

Distribute blocks equally between two points

Hello everyone:)

 

Need help on a routine that will ask user to pick two points as reference then ask to select blocks to distribute equally between the two reference points. Must work either direction x or y but z position must remain unchanged. Please help!

 

Thanks in advanceSmiley Happy

8 REPLIES 8
Message 2 of 9
hmsilva
in reply to: JCprog


@JCprog wrote:

Need help on a routine that will ask user to pick two points as reference then ask to select blocks to distribute equally between the two reference points. Must work either direction x or y but z position must remain unchanged. Please help!


Hi JCprog,


from the code I posted at your previous post, you should get some ideas to start this code.


Try to write it.
If you have any doubts, just ask.

 

Henrique

EESignature

Message 3 of 9
dbroad
in reply to: JCprog

An aside:  If you have AutoCAD Architecture or AutoCAD MEP, a command to do just that is included (LINEWORKSPACEEVENLY).

Architect, Registered NC, VA, SC, & GA.
Message 4 of 9
3wood
in reply to: JCprog

You can draw a temporary line between 2 points then use command DIVIDE B to divide them with a selected block.

Message 5 of 9
Kent1Cooper
in reply to: JCprog

A little clarification....  It sounds to me from your description as though the User would select some already-inserted Blocks, which are not at the same elevation, and the routine would move them into equally spaced [as to XY coordinates only] locations between the reference points.  If so, might they be Blocks of different names, and/or at varying scales and rotations as well as being at different elevations?  DIVIDE certainly can't do that; I couldn't say about LINEWORKSPACEEVENLY.  And if that's the intent, how should the sequence of them in the spaced relocations be determined?  By order of selection?  By current positions relative to one of the coordinate axes?  Should one of them be placed at each reference point with the others spaced in between, or should they all be spaced in between without any at the reference points [which is the way DIVIDE does it]?  I think a sample drawing or image with before and after situations would be helpful.

Kent Cooper, AIA
Message 6 of 9
JCprog
in reply to: Kent1Cooper

Attached is a sample drawing of what I wish to achieve. distribute objects in equal space between two point (e.g. object A & B)

Message 7 of 9
Kent1Cooper
in reply to: JCprog


@JCprog wrote:

Attached is a sample drawing of what I wish to achieve. distribute objects in equal space between two point (e.g. object A & B)


That looks like the positions of the outermost [in the desired direction] of the set of Blocks are to remain where they are, themselves defining the ends of the range of positions, and the others moved to be spaced between those two.  Your original description sounds more like the User would designate the ends of the range of positions by picking reference points.  Either way could certainly be done, but it would need to be one or the other, or perhaps a routine for each [or an option in one routine] would be appropriate.  Either way, might that range of positions sometimes not run in an orthogonal direction?  If the User is to pick points not necessarily at current Block locations, I repeat: should the end Blocks in the series go at those points, or be away from them by the same distance as that between Blocks, the way Divide would do it?  Also, is it fair to conclude that the order of the ones between should be determined from their initial relative position in the desired direction, rather than from some other criterion such as order of selection?

Kent Cooper, AIA
Message 8 of 9
smaher12
in reply to: JCprog

Well, I took a stab at it and modified hmsilva code from your previous post.

 

(defun c:demo (/ ent i p1 p2 p3 p4 pt1 c cc s s1 ss)
  (if
    (and
      (not (prompt "\nSpecify first Block: "))
      (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
      (not (prompt "\nSpecify second Block: "))
      (setq s1 (ssget "_+.:E:S" '((0 . "INSERT"))))
    )
    
  (if (and
	(not (prompt "\nSelect Blocks to change coordinates: "))
	(setq ss (ssget "_:L" '((0 . "INSERT"))))
      )

    (progn
      (setq c (sslength ss)
	    cc (1+ c)
	    p1 (cdr (assoc 10 (entget (ssname s 0))))
	    p2 (cdr (assoc 10 (entget (ssname s1 0))))
	    p3 p1
	    )

      (repeat (setq i (sslength ss))
	(setq p4 (polar p3 (angle p1 p2) (/ (distance p1 p2) (fix cc))))
	(setq p3 p4)
	(setq ent (entget (ssname ss (setq i (1- i)))))
	(setq pt1 (cdr (assoc 10 ent)))

	(entmod (subst (cons 10 (list (car p3) (cadr p3) (caddr pt1)))
		       (assoc 10 ent)
		       ent
		       )
		)
	)
      )
    )
   )
  (princ)
)

 

Message 9 of 9
JCprog
in reply to: smaher12

Thank you very much smasher12!!!!!!!!!!Smiley Very Happy

 

It works perfectly!!!!!!!! so awesome thanks again!!!!!!!!!!!!!!!!!!!!!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost