Hello everyone
Situation:
If theres blocks A,B,C,D,E and they're all placed radomly (all have different xyz)
Thought:
Need a lisp that user picks first block (eg "Block A) as insertion point reference then routine ask which coordinate to follow (x, y, or z?) then select blocks to follow alignment. When user picks to follow block A's x-coordinate.....block B,C,D,E should have same x-coordinate but maintain y & z unchanged.
This can be done manually but very tedious in a way. Please Help!
Thanks in advance
Here is one I have that will align text/blocks horizontaly. I'm sure it can easily be modified to meet your needs.
(defun c:blkalign () (setq OS (getvar "OSMODE")) (setvar "OSMODE" 0) (princ "\nSelect blocks or text to align horizontaly evenly: ") (setq ss (ssget)) (setq albl (entsel "\nSelect text or block to align with: ")) (setq albl (car albl)) (setq alpt (cdr (assoc 10 (entget albl)))) (setq alpty (cadr alpt)) (setq ctr 0) (while (setq ename (ssname ss ctr)) (setq inpt (cdr (assoc 10 (entget ename)))) (setq inptx (car inpt) ) (setq inpty (cadr inpt)) (setq newpt (list inptx alpty)) (command "move" ename "" inpt newpt) (setq ctr (+ ctr 1)) ) (setvar "OSMODE" OS) )
Manual way isn't very tedious. Select the blocks (quick select if needed), plug the appropriate ordinate value into the Properties palette.
Thanks for the reply smaher12,
It works horizontally, thanks for sharing! The routine just breaks when ucs is rotated but it works fine on world ucs. And it must not take out snap settings. Works more better than the align command (which is essentially no different from "move" 😉
JCprog wrote:Situation:
If theres blocks A,B,C,D,E and they're all placed radomly (all have different xyz)
Thought:
Need a lisp that user picks first block (eg "Block A) as insertion point reference then routine ask which coordinate to follow (x, y, or z?) then select blocks to follow alignment. When user picks to follow block A's x-coordinate.....block B,C,D,E should have same x-coordinate but maintain y & z unchanged.
Hi JCprog,
as a start point...
(defun c:demo ( / ans ent i pt pt1 s ss) (if (and (not (prompt "\nSelect Block to follow coordinate: ")) (setq s (ssget "_+.:E:S" '((0 . "INSERT")))) (not (initget "X Y Z")) (setq ans (getkword "\nEnter the coordinate to follow [X/Y/Z] <exit>:")) ) (if (and ans (not (prompt "\nSelect Blocks to change coordinates: ")) (setq ss (ssget "_:L" '((0 . "INSERT")))) ) (progn (setq pt (cdr (assoc 10 (entget (ssname s 0))))) (repeat (setq i (sslength ss)) (setq ent (entget (ssname ss (setq i (1- i))))) (setq pt1 (cdr (assoc 10 ent))) (cond ((= ans "X") (entmod (subst (cons 10 (list (car pt) (cadr pt1) (caddr pt1))) (assoc 10 ent) ent ) ) ) ((= ans "Y") (entmod (subst (cons 10 (list (car pt1) (cadr pt) (caddr pt1))) (assoc 10 ent) ent ) ) ) ((= ans "Z") (entmod (subst (cons 10 (list (car pt1) (cadr pt1) (caddr pt))) (assoc 10 ent) ent ) ) ) ) ) ) ) ) (princ) )
HTH
Henrique
Thanks for the reply Henrique!
I dont think thats simply a "startpoint".....Thats technically a "nailed-down-finishpoint" to me....lol
Thanks a million!!!!!!!!! as always.....it works awesome!!!!!!!!
Hi @hmsilva,
The routine works great for the geometries in the block. However, the attributes in the block are not moved by the routine (please see attached screenshot). Can the routine be modified to include attributes in the block?
Thank you.
@bananaking365 wrote:
.... the attributes in the block are not moved by the routine (please see attached screenshot). Can the routine be modified to include attributes in the block?
....
Does ATTSYNC move them to appropriate locations in relation to the moved Blocks?
Can't find what you're looking for? Ask the community or share your knowledge.