Quick conversion tools

Discussion in 'AutoCAD' started by Matthew Kuehl, Nov 9, 2004.

  1. Hi. I'm looking to convert a bunch of spot elevations from english to metric (batch multiply by 3.28). Does anyone have a command that might do this
    Thanks,
    Matthew Kuehl
     
    Matthew Kuehl, Nov 9, 2004
    #1
  2. I should point out that it is simple Dtext that I want to modify. For example, I need to change an elevation from 119.20 to 390.98, but I need to do that a thousand times.
    Thanks,
    Matthew Kuehl
     
    Matthew Kuehl, Nov 9, 2004
    #2
  3. Matthew Kuehl

    ECCAD Guest

    This seems to work.
    (defun C:ELEV2MET ()
    (setq ss nil)
    (prompt "\n ")
    (prompt "\nSelect Elevations to change:")
    (setq ss (ssget))
    (if ss
    (progn
    (setq c 0)
    (repeat (sslength ss)
    (setq ename (ssname ss c)); entities selected
    (setq ent (entget ename)); entity list
    (if (= "TEXT" (cdr (assoc 0 ent))); if text
    (progn
    (setq ostr (cdr (assoc 1 ent))); old string
    (if (and (/= ostr nil)(/= ostr "")); must have a value
    (progn
    (setq nstr (rtos (* 3.28 (atof ostr)))); new string value
    (entmod (setq ent (subst (cons 1 nstr)(assoc 1 ent) ent))); replace it
    (entupd ename); update entity
    ); end progn
    ); end if
    ); end progn
    ); end if
    (setq c (+ c 1)); next
    ); end repeat
    ); end progn
    ); end if
    ); end function
    (princ)

    Bob
    www.bobscadshop.com
     
    ECCAD, Nov 9, 2004
    #3
  4. Thanks: I modified it to convert from english to metric, rather than vice-versa.
    (defun C:ELEV2MET ()
    (setq ss nil)
    (prompt "\n ")
    (prompt "\nSelect Elevations to change:")
    (setq ss (ssget))
    (if ss
    (progn
    (setq c 0)
    (repeat (sslength ss)
    (setq ename (ssname ss c)); entities selected
    (setq ent (entget ename)); entity list
    (if (= "TEXT" (cdr (assoc 0 ent))); if text
    (progn
    (setq ostr (cdr (assoc 1 ent))); old string
    (if (and (/= ostr nil)(/= ostr "")); must have a value
    (progn
    (setq nstr (rtos (* 0.3048 (atof ostr)))); new string value
    (entmod (setq ent (subst (cons 1 nstr)(assoc 1 ent) ent))); replace it
    (entupd ename); update entity
    ); end progn
    ); end if
    ); end progn
    ); end if
    (setq c (+ c 1)); next
    ); end repeat
    ); end progn
    ); end if
    ); end function
    (princ)

    Matthew Kuehl
     
    Matthew Kuehl, Nov 10, 2004
    #4
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.