Align then rotate perpendicular ?

Discussion in 'AutoCAD' started by Miles, Nov 3, 2004.

  1. Miles

    Miles Guest

    All,
    Below is a snippet of code that I am using to align a block to a selected
    object (i.e. line). However, I am trying to modify it so that the object is
    set perpendicular to the selected line instead of perfectly aligned. I have
    several options, including getting the angle of the selected line then
    adding 90, etc., however, nothing seems to work.

    *snippet*
    (while (< INDEX LEN)
    (setq EN2 (entget (ssname S INDEX)))
    (if (= (cdr (assoc 0 EN2)) "LINE")
    (setq PT3 (cdr (assoc 10 EN2))
    PT4 (cdr (assoc 11 EN2))
    DIST2 (distance PT3 PT4)
    PT5 (polar PT3 ANG DIST2)
    EN2 (subst (cons 11 PT5) (cons 11 PT4) EN2)
    )
    (setq EN2 (subst (cons '50 ANG) (assoc 50 EN2) EN2))
    )
    (entmod EN2)
    (setq INDEX (1+ INDEX))
    )

    Any ideas ?
     
    Miles, Nov 3, 2004
    #1
  2. Miles

    Fatty Guest

    Try this:

    *snippet*

    (if (not (member "geom3d.arx" (arx)))
    (arxload "geom3d.arx")
    )
    (setq ss (ssget)
    oldec (getvar "CMDECHO")
    osm (getvar "OSMODE")
    ); setq
    (setvar "CMDECHO" 0)
    (setvar "OSMODE" 1)
    (setq pt1 (getpoint "\nSpecify first point on object axis: ")
    pt2 (getpoint "\nSpecify second point on object axis: ")
    pt3 (getpoint "\nSpecify first point of the vector: ")
    pt4 (getpoint "\nSpecify second point of the vector: ")
    ); setq
    (setvar "OSMODE" 0)
    (align ss pt1 pt3
    pt2 pt4 "" "n")
    (command "_.MOVE" (ssname ss 0) "" pt3 pt1)
    (setvar "OSMODE" osm)
    (setvar "CMDECHO" oldec)
    (princ)
     
    Fatty, Nov 3, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.