Mirror Block

Discussion in 'AutoCAD' started by Matt W, Oct 29, 2004.

  1. Matt W

    Matt W Guest

    I've got this code (see below) that will rotate a selected block 180
    degrees.
    I'd like to modify it to MIRROR a selected block, regardless of it's angle,
    but I just can't seem to be able to put 2 + 2 together.

    Code:
    (defun DXF (code lst)
    (cdr (assoc code lst))
    )
    
    (defun C:BlockRot ( / objEnt ent entList ins)
    (if (setq objEnt (entsel "Select block to auto-rotate... "))
    (progn
    (setq ent (entget (setq entList (car objEnt))))
    (setq ins (DXF 10 ent))
    (command "rotate" objEnt "" ins "180")
    )
    (princ "\n Nothing selected.  Please try again.")
    )
    (princ)
    )
    

    TIA
     
    Matt W, Oct 29, 2004
    #1
  2. Matt W

    T.Willey Guest

    T.Willey, Oct 29, 2004
    #2
  3. Matt W

    Matt W Guest

    nope.
     
    Matt W, Oct 29, 2004
    #3
  4. Matt W

    T.Willey Guest

    I guess you would have to find a second point, useing the first as the insertion point of the block, along the angle you want. Then mirror your block along that axis. I guess it depends on the block, with how you get your second point. Just some food for thought. I guess you could get the rotation angle of the block, then find a point pependicular to that, but how would you know if to mirror it on the "x" or "y" axis?

    Sorry I can't be more help. Maybe if you can explain a little more as far as what you expect it to do.
    Tim
     
    T.Willey, Oct 29, 2004
    #4
  5. Matt W

    Douglas Barr Guest

    Or he could just 'negativize' the assoc41,42,43 (x,y,z) of the insert
    entity.

    insertion point of the block, along the angle you want. Then mirror your
    block along that axis. I guess it depends on the block, with how you get
    your second point. Just some food for thought. I guess you could get the
    rotation angle of the block, then find a point pependicular to that, but how
    would you know if to mirror it on the "x" or "y" axis?
     
    Douglas Barr, Oct 29, 2004
    #5
  6. Matt W

    Matt W Guest

    "Negativize"???
    What I ended up doing was getting the location of a hidden attrbute and
    using that as a second (reference) point with which to mirror.
    Works pretty slick.
     
    Matt W, Oct 29, 2004
    #6
  7. Matt W

    T.Willey Guest

    Cool, glad you got it to work.

    Tim
     
    T.Willey, Oct 29, 2004
    #7
  8. Matt W

    Don Butler Guest

    Matt:

    I haven't tried this enough to know if there may be any unseen problems.

    (defun c:MirX (/ enam InsObj Xscal)
    (setq enam (car (entsel "\nSelect Insert...")))
    (if (= (cdr (assoc 0 (entget enam))) "INSERT")
    (progn
    (setq InsObj (vlax-ename->vla-object enam))
    (setq Xscal (vla-get-xscalefactor InsObj))
    (if (minusp Xscal)
    (vla-put-xscalefactor Insobj (abs Xscal))
    (vla-put-xscalefactor Insobj (- (abs Xscal) (* (abs Xscal) 2)))
    )
    )
    (alert "Selected entity not an INSERT!")
    )
    (princ)
    )

    (defun c:MirY (/ enam InsObj Yscal)
    (setq enam (car (entsel "\nSelect Insert...")))
    (if (= (cdr (assoc 0 (entget enam))) "INSERT")
    (progn
    (setq InsObj (vlax-ename->vla-object enam))
    (setq Yscal (vla-get-yscalefactor InsObj))
    (if (minusp yscal)
    (vla-put-yscalefactor Insobj (abs Yscal))
    (vla-put-yscalefactor Insobj (- (abs Yscal) (* (abs Yscal) 2)))
    )
    )
    (alert "Selected entity not an INSERT!")
    )
    (princ)
    )

    Don



     
    Don Butler, Nov 1, 2004
    #8
  9. Matt W

    Matt W Guest

    I'll take a look at it when I get a free minute or two.
    Thanks for the post.

    --
    I support two teams: The Red Sox and whoever beats the Yankees.

     
    Matt W, Nov 2, 2004
    #9
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.