I am looking for a way to line up oblects like lines and shapes so that the line up vertically. Alignment is not the right command because I am not joining objects. I really want to left or right justify objects but NOT text objects. Currently I draw a vertical line and drag obects over to that line then delete the vertical line. It is very time consuming. \
Solved! Go to Solution.
Solved by eswartwout. Go to Solution.
Below is a routine I use to line up blocks and line vertically. You could make it line up just about whatever you want if you change the (if to a (cond and add some routines in. As this is in the main AutoCAD forum and not the customization forum I will ask, do you know how to load and run this or edit it in AutoCAD?
;*************************************************************************************
; Align X: Aligns selected object's insertion point's x-coordinate with a selected *
; point *
;*************************************************************************************
(defun c:ax (/ objs p1 alignX cnt obj vlobj currentInsertion destinationList arraySpace sArray destinationVariant sp ep vlZero)
(setq objs (ssget))
(initget 1)
(setq p1 (getpoint "\n Specify alignment point: "))
(command ".undo" "begin")
(setq alignX (car (trans p1 1 0)))
(setq cnt 0)
(if (and (= 1 (sslength objs)) (= "AcDbLine" (vla-get-objectname (setq vlZero (vlax-ename->vla-object (ssname objs 0))))))
(progn
(setq sp (vlax-safearray->list (vlax-variant-value (vla-get-StartPoint vlZero)))
ep (vlax-safearray->list (vlax-variant-value (vla-get-EndPoint vlZero)))
)
(setq sp (list alignX (cadr sp) (caddr sp))
ep (list alignX (cadr ep) (caddr ep))
)
(setq sp (vlax-3d-point sp)
ep (vlax-3d-point ep)
)
(vla-put-StartPoint vlZero sp)
(vla-put-EndPoint vlZero ep)
)
(while (< cnt (sslength objs))
(setq obj (ssname objs cnt))
(setq vlobj (vlax-ename->vla-object obj))
(if (vlax-property-available-p vlobj 'InsertionPoint)
(progn
(setq currentInsertion (vlax-get-property vlobj 'InsertionPoint))
(setq currentInsertion (vlax-variant-value currentInsertion))
(setq currentInsertion (vlax-safearray->list currentInsertion))
(setq destinationList (list alignX (cadr currentInsertion) (caddr currentInsertion)))
(setq arraySpace (vlax-make-safearray vlax-vbdouble (cons 0 (- (length destinationList) 1))))
(setq sArray (vlax-safearray-fill arraySpace destinationList))
(setq destinationVariant (vlax-make-variant sArray))
(vlax-put-property vlobj 'InsertionPoint destinationVariant)
)
)
(setq cnt (1+ cnt))
)
)
(command ".undo" "end")
(princ)
)
;END x<-------------------------------------------------------------------------------------------------------
I can try. This is a first for me in the forums. I spent three hours on the phone tryign to get ahold of someone from Autodesk to help me out. I only draw electrial drawings using only Autocad. I need to lineup circuit breakers, fuses connecting lines etc. How do I get an attachment
sometimes it places the objects directly on top of one another making the start xy coordinate exactly the same. I want to leave the object in the same vertical location and only align them vertically. I have 20 horizonal lines on a model space all scattered around the page. I want them all to line up along a leftmost coordinate but be still spaced out vertically
Try this one. Same gig, save to drive, drag and drop, type ax enter.
I mus tbe missing something. I select three horizonal lines, then I hit enter, it lets me pick one end point then I hit enter then nothing
Just to be sure its not something in the code I added several lines to print letters to the command line to let me see where it is breaking down on your machine. Same gig with this one. This time, if you hit F2 to see the command history after you execute you should see several letters. Either post a copy of what is on your command history or at least let me know what the last letter shown was. Thanks.
I do not see any letters. It does the same thing. History of commands fades away in about 3 seconds and I dont know how to get to them. I can show command history but not anything else
Did you hit F2. That will bring up a separate window showing your command history.
Command: LSP
Enter an option [?/Commands/Functions/Variables/Load]: l
_.appload ax.lsp successfully loaded.
Command:
Command: ; error: malformed list on input
Command: