Jump to content

Recommended Posts

Posted

Hi there,

 

I was wondering if it is possible to make a lisp to do the following:

 

ddedit a dimension to make it end in either 3", 6" 9" or 0", but always rounding down.

 

So a 10'-10" would be 10'-9" and so on..

 

Thanks for the help!

Posted

Welcome to the Forum .:)

 

Check this out ....

 

(defun c:Test (/ Three Six Nine ss sideA sideB dis p pt)
; Tharwat 14. 06. 2011
 (setq Three (* 25.4 3.) Six   (* 25.4 6.) Nine  (* 25.4 9.))
 (if
   (and
     (setq ss (car (entsel "\n Select a Dimension :")))
     (eq (cdr (assoc 0 (setq e (entget ss)))) "DIMENSION")
   )
    (progn
      (setq sideA (cdr (assoc 13 e)))
      (setq sideB (cdr (assoc 14 e)))
      (setq dis (distance sideA sideB))
      (if (eq
            (car sideA)
            (car sideB)
          )
        (setq p sideB)
        (setq p sideA)
      )

      (cond (
             (and (> dis 0.) (< dis Six))
             (setq pt (polar p (angle sideA sideB) Three))
            )
            (
             (and (> dis Six) (< dis Nine))
             (setq pt (polar p (angle sideA sideB) Six))
            )
            (
             (> dis Nine)
             (setq pt (polar p (angle sideA sideB) Nine))
            )
      )
      (entupd
        (cdr (assoc -1 (entmod (subst (cons 14 pt) (assoc 14 e) e)))
        )
      )
    )
    (princ)
 )
 (princ)
)

 

Tharwat

Posted

If I understand your goal correctly, this should work:

 

(defun c:test ( / dm en ft in )
 (if
   (and
     (setq en (car (entsel "\nSelect Dimension: ")))
     (eq "DIMENSION" (cdr (assoc 0 (entget en))))
   )
   (progn
     (setq en (entget en)
           dm (cdr (assoc 42 en))
           ft (fix (/ dm 12.))
           in (rem dm 12.)
     )
     (setq in
       (cond
         ( (< in 3) 0)
         ( (and (<= 3 in) (< in 6)) 3)
         ( (and (<= 6 in) (< in 9)) 6)
         ( 9)
       )
     )
     (entmod
       (subst
         (cons 1 (rtos (+ (* ft 12.) in) (getvar 'DIMLUNIT) (getvar 'DIMDEC)))
         (assoc 1 en)
         en
       )
     )
   )
 )
 (princ)
)

Although, since the above uses the Dimension Measurement (DXF 42) rather than the Dimension String, it will not take into account Dimension Style Prefixes/Suffixes/Alt Units/Tolerances etc. that are displayed.

 

@Tharwat, From the reference to 'ddedit', I think the OP wants to use the Dimension Override, not alter the position of the Dimension Endpoints. Also, what if the dimension measurement is greater than 1'? Did you try on the OP's example of 10'-10"?

Guest kruuger
Posted
Hi there,

 

I was wondering if it is possible to make a lisp to do the following:

 

ddedit a dimension to make it end in either 3", 6" 9" or 0", but always rounding down.

 

So a 10'-10" would be 10'-9" and so on..

 

Thanks for the help!

if you want to override dimensions just go to your dimstyle and set roundoff to 3. lisp is not necessary.

kruuger

Posted
if you want to override dimensions just go to your dimstyle and set roundoff to 3. lisp is not necessary.

kruuger

 

Good call Kruuger - I missed the wood for the trees on this one :oops:

Posted
if you want to override dimensions just go to your dimstyle and set roundoff to 3. lisp is not necessary.

kruuger

 

Good point kruuger , I also did not get the point of the OP with their little words about the needs from the routine .

 

Thanks. :)

Posted

haha good call, i thought i tried that and it didn't work, i guess it does now :D

Posted

hi just remember why the rounding in dimstyle wont work in my case, because it will round UP, where as i only want it to round down.

 

Will try the lisp created by you guys, thanks!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...