Dire need of a lisp routine - Help!!

Discussion in 'AutoCAD' started by mattstu, Sep 22, 2004.

  1. mattstu

    mattstu Guest

    Ladies and gentlemen,

    I have a problem, I have been given a survey that has an arbitary datum of +100.00. In fact the' true' datum is +122.56 AOD. Opposed to actyually commisioning a re-survey is there a lisp routine out there somewhere that can 'add' a given value to multiple numerical text strings (levels)? this would be a great great help if anyone has come across and solved this problem before and could give me som guidance.
    TIA
    kind regards
    Matt
     
    mattstu, Sep 22, 2004
    #1
  2. mattstu

    Jasehuss Guest

    This may help if I understand you correctly, a collegue had a similar problem.

    The routine itself was a quick and dirty and has no error checking at all and will fall over if non numerical text is selected it doesn't function with MTEXT entities.

    Regards
    J

    ;;;
    ;;;
    ;;;ADD ZEROS TO FORMAT TEXT
    ;;;
    ;;;
    (defun bhl:zeros (tx / val)
    (setq val (atof tx))
    (if (>= val 0)
    (progn
    (if (< (atof tx) 10)
    (progn
    (setq len (strlen tx))
    (if (= len 1)
    (setq tx (strcat tx ".00"))
    )
    (if (= len 3)
    (setq tx (strcat tx "0"))
    )
    )
    )
    (if (>= (atof tx) 10)
    (progn
    (setq len (strlen tx))
    (if (= len 2)
    (setq tx (strcat tx ".00"))
    )
    (if (= len 4)
    (setq tx (strcat tx "0"))
    )
    )
    )
    (if (>= (atof tx) 100)
    (progn
    (setq len (strlen tx))
    (if (= len 3)
    (setq tx (strcat tx ".00"))
    )
    (if (= len 5)
    (setq tx (strcat tx "0"))
    )
    )
    )
    )
    )

    (if (< val 0)
    (progn
    (if (> (atof tx) -10)
    (progn
    (setq len (strlen tx))
    (if (= len 2)
    (setq tx (strcat tx ".00"))
    )
    (if (= len 4)
    (setq tx (strcat tx "0"))
    )
    )
    )
    (if (<= (atof tx) -10)
    (progn
    (setq len (strlen tx))
    (if (= len 3)
    (setq tx (strcat tx ".00"))
    )
    (if (= len 5)
    (setq tx (strcat tx "0"))
    )
    )
    )
    (if (<= (atof tx) -100)
    (progn
    (setq len (strlen tx))
    (if (= len 4)
    (setq tx (strcat tx ".00"))
    )
    (if (= len 6)
    (setq tx (strcat tx "0"))
    )
    )
    )
    )
    )


    (setq tx tx)
    )
    (defun c:addtotext (/ sset val num count ent entdet txtval newval)
    (setq sset (ssget))
    (setq val (getdist "\nValue to add to text: "))
    (if (= val nil)(setq val 0))
    (setq num (sslength sset))
    (setq count 0)
    (while (< count num)
    (setq ent (ssname sset count))
    (setq count (+ count 1))
    (setq entdet (entget ent))
    (setq txtval (atof (cdr (assoc 1 entdet))))
    (setq newval (rtos (+ txtval val) 2 2))
    (setq newval (bhl:zeros newval))
    (command "_change" ent "" "" "" "" "" "" newval)
    )
    )
     
    Jasehuss, Sep 22, 2004
    #2
  3. mattstu

    Douglas Barr Guest

    Here's a quick'n'dirty one for you.

    (defun c:addit ()
    (princ "\nSelect text entities to add to:")
    (setq texts (ssget))
    (princ "\nType number to add to all selected numbers:")
    (setq adder (getreal))
    (princ "\nType precision of numbers:")
    (setq precis (getint))
    (setq n 0)
    (while (setq text1 (ssname texts n))
    (setq entity (entget text1))
    (setq oldtext (assoc 1 entity))
    (setq oldnumber (atof (cdr oldtext)))
    (setq newnumber (rtos (+ adder oldnumber) 2 precis))
    (setq newtext (cons 1 newnumber))
    (setq entity (subst newtext oldtext entity))
    (entmod entity)
    (setq n (1+ n))
    )
    (princ)
    )

    No guarantees, no bells'n'whistles. Seems to work.
    -doug


    +100.00. In fact the' true' datum is +122.56 AOD. Opposed to actyually
    commisioning a re-survey is there a lisp routine out there somewhere that
    can 'add' a given value to multiple numerical text strings (levels)? this
    would be a great great help if anyone has come across and solved this
    problem before and could give me som guidance.
     
    Douglas Barr, Sep 22, 2004
    #3
  4. mattstu

    mattstu Guest

    J,
    It seems to run initially but there appears to be some conflict in actually modifying the text string.
    Example as follows;_

    Specify new text insertion point <no change>:
    Enter new text style <romans>:
    Specify new rotation angle <90d0'0.00">:
    Enter new text <106.89>:
    Command: 129.45 Unknown command "129.45". Press F1 for help.
     
    mattstu, Sep 22, 2004
    #4
  5. mattstu

    mattstu Guest

    Works like a dream Doug - Thank you kindly.
    Cheers
    Matt
     
    mattstu, Sep 22, 2004
    #5
  6. You are using fixed-height text styles. Yuck.

    Take one of the double-quote pairs out of the change command,

    --
    R. Robert Bell


    J,
    It seems to run initially but there appears to be some conflict in actually
    modifying the text string.
    Example as follows;_

    Specify new text insertion point <no change>:
    Enter new text style <romans>:
    Specify new rotation angle <90d0'0.00">:
    Enter new text <106.89>:
    Command: 129.45 Unknown command "129.45". Press F1 for help.
     
    R. Robert Bell, Sep 22, 2004
    #6
  7. mattstu

    Jasehuss Guest

    Thanks doug,

    you just made me learn a new thing, I noted you only had the rtos to format your precision.

    I tried this first and 90.00 returned 90

    I have now searched this group and found that problem due to DIMZIN, If i'd looked here about a year ago, for that I probably could have saved me some coding to format my zeros!

    It's true, you learn something new every day.
    J
     
    Jasehuss, Sep 22, 2004
    #7
  8. mattstu

    Douglas Barr Guest

    Simple is best sometimes! Glad it worked for you.
     
    Douglas Barr, Sep 22, 2004
    #8
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.