Author Topic: Dimension flip lisp needed  (Read 10565 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
Dimension flip lisp needed
« on: March 21, 2007, 09:45:44 AM »
I was wondering if anyone has a lisp for accomplishing what i want or could help me write something? The drawing I have attached has a dimension whose text I want to flip from the right side to the left. I know that I could use the dimtedit command and select the left option but the trick is I want to grab the text below it and flip that as well as shownin the drawing. It would also be nice to have the option to select multiple dimensions as well as the dimtedit command only allows a single. So if anyone has a little time could you help me out with this? Thanks

Dimension flip test

whdjr

  • Guest
Re: Dimension flip lisp needed
« Reply #1 on: March 21, 2007, 09:50:30 AM »
Try this:

Code: [Select]
(defun c:dimflip (/ ss num ent val nvl)
 (princ "\nSelect Dimensions to flip...\n")
 (if (setq ss (if (ssget '((0 . "DIMENSION")))
       (ssget "P")
       nil
      )
     )
  (repeat (setq num (sslength ss))
   (setq num (1- num)
ent (entget (ssname ss num))
val (cdr (assoc 51 ent))
nvl (+ val pi)
   )
   (entmod (subst (cons 51 nvl) (assoc 51 ent) ent))
  )
  (princ "\nNo valid objects selected.  ")
 )
 (princ)
)
(defun c:df () (c:dimflip) (princ))

ELOQUINTET

  • Guest
Re: Dimension flip lisp needed
« Reply #2 on: March 21, 2007, 09:52:16 AM »
i forgot to mention that this dimension is being created by a custom program we use to create our elevations. I just wanted to point this out for some that might say why don't you use the \X method so the text below is a part of the dimension. Maybe this could be incoporated into the program eventually but not now.

ELOQUINTET

  • Guest
Re: Dimension flip lisp needed
« Reply #3 on: March 21, 2007, 09:55:54 AM »
will this flips the dimension upside down not from right to left and didn't grab the text too. thanks for helping me though i think you get the idea

whdjr

  • Guest
Re: Dimension flip lisp needed
« Reply #4 on: March 21, 2007, 10:02:47 AM »
Ok, I see.  That's what I get for not reading everything instead of just skimming over. 

So you want to 'mirror' the dimension so the text is on the other side.  OK I got ya.

ELOQUINTET

  • Guest
Re: Dimension flip lisp needed
« Reply #5 on: March 21, 2007, 10:11:49 AM »
yeah basically you got it. the trick is i want the text below to move to the other side as well. it would also be great to have the option to select multiple dims.

whdjr

  • Guest
Re: Dimension flip lisp needed
« Reply #6 on: March 21, 2007, 10:19:06 AM »
How are you getting text below your dim line?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimension flip lisp needed
« Reply #7 on: March 21, 2007, 10:19:53 AM »
Here is the one I use, works when you are in a rotated UCS.
Code: [Select]
;;  CAB 10/04/2005
;;  Correct rotated dimension to reflect the current UCS
;;  Used when elevations are mirrored in a drawing
;;  Updates DXF code 51
(defun c:dimrot (/ d elst ang)
  (and
    (setq d (entsel))
    (setq elst (entget (car d)))
    (setq ang (- (* 2 pi)
                 (angle (trans '(0.0 0.0 0.0) 1 0)
                        (trans '(1.0 0.0 0.0) 1 0)
                 )
              )
    )
    ;;  prevent 2 * pi
    (if (equal ang (* 2 pi) 0.0001) (setq ang 0.0) t)
    (setq elst (subst (cons 51 ang) (assoc 51 elst) elst))
    (entmod elst)
  )
  (print ang)
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Re: Dimension flip lisp needed
« Reply #8 on: March 21, 2007, 10:31:06 AM »
will we have a vba/lisp routine that draws everything out for us and it places the text under the dimension. cab i'm not sure exactly what yours does but it didn't appear to do anything on my end. thanks for your help guys

whdjr

  • Guest
Re: Dimension flip lisp needed
« Reply #9 on: March 21, 2007, 10:32:14 AM »
This works but has no error checking.

Code: [Select]
(defun c:diml2r ( / ent p1 p2 np1 np2)
 (setq ent (entget (car (entsel)))
       p1  (assoc 13 ent)
       p2  (assoc 14 ent)
       np1 (cons 13 (cdr p2))
       np2 (cons 14 (cdr p1))
       ent (subst np1 p1 ent)
       ent (subst np2 p2 ent)
       )
 (entmod ent)
 )

ELOQUINTET

  • Guest
Re: Dimension flip lisp needed
« Reply #10 on: March 21, 2007, 11:00:31 AM »
will this works for flipping the dimension and is a good start but what about moving the text below with it and a multiple dimension option?

whdjr

  • Guest
Re: Dimension flip lisp needed
« Reply #11 on: March 21, 2007, 11:45:34 AM »
will this works for flipping the dimension and is a good start but what about moving the text below with it and a multiple dimension option?

Explain your "text below".  Is it part of the dimension text? how are you getting it below? a separate text entity?

ELOQUINTET

  • Guest
Re: Dimension flip lisp needed
« Reply #12 on: March 21, 2007, 12:33:47 PM »
i attached a drawing in the original post but maybe this one will explain what i need this for better. sometimes i have to join 2 elevations togehter and i need to flip the dimensions and text left or right so they are inside the shade. if you look at the drawing it will make sense, hopefully. thanks

Dimension flip with explaination
« Last Edit: March 21, 2007, 12:37:50 PM by Eloquintet »

whdjr

  • Guest
Re: Dimension flip lisp needed
« Reply #13 on: March 21, 2007, 01:24:15 PM »
Dan,

All my tool is doing is swapping the two endpoints thereby causing the dimension to mirror.  The text object is not part of the dimension so I have no reference to go by for moving it.  I could work on a multi-select method for the dimension but I'm at a loss for the text.

whdjr

  • Guest
Re: Dimension flip lisp needed
« Reply #14 on: March 21, 2007, 01:27:49 PM »
Now that I give a second thought, If you select the text and dimension and issue a mirror command based on the midpoint of the dimension it might just work; however I don't see a multi-select in that scenario.

What do you think?