Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

alignment

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
eswartwout
928 Views, 17 Replies

alignment

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

 

17 REPLIES 17
Message 2 of 18
p_mcknight
in reply to: eswartwout

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

Message 3 of 18
eswartwout
in reply to: p_mcknight

I have no idea how to edit this or run it.

Message 4 of 18
p_mcknight
in reply to: eswartwout

In that case, if you're up for a little back and forth I can probably help you make it work the way you want. I have included an attachment of the file as a .txt. Save it to your hard drive (inspect the contents if you'd like to make sure its legit, and then rename it to .lsp. Once you do that you can just drag and drop from windows explorer into your AutoCAD editing screen. Once done, type ax enter, select a bunch of blocks, enter, pick a point, see what happens. Next, ax, enter, select a diagonal line, enter, pick a point, see what happens. Let me know how far it is off from what you want and I will see if I can edit it to do what you would like it to. Any questions, let me know.
Message 5 of 18
eswartwout
in reply to: p_mcknight

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

Message 6 of 18
p_mcknight
in reply to: eswartwout

Didn't attach before.  I am trying to upload it again.

Message 7 of 18
eswartwout
in reply to: p_mcknight

ok it is saved as lsp
Message 8 of 18
eswartwout
in reply to: eswartwout

I loaded it and typed AX selected the objects then selected a pick point. hit enter and it did not do anything
Message 9 of 18
eswartwout
in reply to: eswartwout

Should I not be using the quick reply option?

 

Message 10 of 18
eswartwout
in reply to: eswartwout

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

 

Message 11 of 18
p_mcknight
in reply to: eswartwout

Thats doable, just give me a bit.

Message 12 of 18
p_mcknight
in reply to: p_mcknight

Try this one.  Same gig, save to drive, drag and drop, type ax enter.

 

Message 13 of 18
eswartwout
in reply to: p_mcknight

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

 

Message 14 of 18
p_mcknight
in reply to: eswartwout

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.

Message 15 of 18
eswartwout
in reply to: p_mcknight

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

Message 16 of 18
p_mcknight
in reply to: eswartwout

Did you hit F2.  That will bring up a separate window showing your command history.

Message 17 of 18
eswartwout
in reply to: p_mcknight

Command: LSP
Enter an option [?/Commands/Functions/Variables/Load]: l
_.appload ax.lsp successfully loaded.
Command:
Command: ; error: malformed list on input
Command:

Message 18 of 18
eswartwout
in reply to: eswartwout

Command: AX
Select objects: 1 found
Select objects: 1 found, 2 total
Select objects: 1 found, 3 total
Select objects:
Specify alignment point: .undo Current settings: Auto = On, Control = All, Combine = Yes, Layer = Yes
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: begin
Command: .undo Current settings: Auto = On, Control = All, Combine = Yes, Layer = Yes
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: end
Command:
Command:
AX

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

Post to forums  

Autodesk Design & Make Report

”Boost