Author Topic: Add text strings that have ft. & inches  (Read 3052 times)

0 Members and 1 Guest are viewing this topic.

BillB

  • Guest
Add text strings that have ft. & inches
« on: June 07, 2005, 01:06:57 PM »
O.k.,,I have looked and searched and looked some more,,but I can not find a lisp that would do the following. I have several (alot) of sheets that have text called out in lineal feet of material in feet-inches, would like to be able to add these all up (text) and come up with a total sum. Have come up with a couple of lisps but they can't handle the inch or fractions of an inch. was wondering if this could be done.

I alway appreciate your help,,,many thanks

BillB

whdjr

  • Guest
Add text strings that have ft. & inches
« Reply #1 on: June 07, 2005, 01:28:46 PM »
How is your text displayed?
Is it text? mtext? attribute?
Can you give a screen shot?

BillB

  • Guest
Add text strings that have ft. & inches
« Reply #2 on: June 07, 2005, 01:36:55 PM »
Ahhh,,,sorry,,duh,,,will be dtext and it looks like for example  18'-4",,,no spaces. oh, I run Acad 2002 w/XP Pro

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Add text strings that have ft. & inches
« Reply #3 on: June 07, 2005, 01:51:39 PM »
Code: [Select]

(defun c:addvals ( / index repval ss2add total)
  (setq ss2add (ssget)
        index  0
        repval (sslength ss2add)
total 0
  )
  (repeat repval
    (setq total (+ total (distof (cdr (assoc 1 (entget (ssname ss2add index)))))))
    (setq index (1+ index))
  )
  (alert (strcat "Total is: " (rtos total)))
)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

BillB

  • Guest
Add text strings that have ft. & inches
« Reply #4 on: June 07, 2005, 02:25:17 PM »
Hey,,,thanks Keith,,,works good except if I pick around 15 text strings I get this
"; error: bad argument type: numberp: nil "
Not sure why

BillB

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Add text strings that have ft. & inches
« Reply #5 on: June 07, 2005, 02:46:19 PM »
Chances are you have selected a bit of text that is either not entirely an architectural length, is mtext, or has some other formatting code such as underlining etc.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Add text strings that have ft. & inches
« Reply #6 on: June 07, 2005, 03:42:08 PM »
Yea, just add some error checking & it will overlook most items.
Code: [Select]
(defun c:addvals (/ ss ename total num msg)
  (setq ss    (ssget '((0 . "TEXT")))
        i     -1
        total 0
  )
  (if ss
       (while (setq ename (ssname ss (setq i (1+ i))))
         (if (setq num (distof (cdr (assoc 1 (entget ename)))))
           (setq total (+ total num))
         )
       )
  )
  (cond
    ((null ss)
     (setq msg "    Nothing Selected"))
    ((zerop total)
     (setq msg "      Zero Total"))
    (t
     (setq msg (strcat "   Total is: " (rtos total))))
  )
  (alert msg)
  (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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Add text strings that have ft. & inches
« Reply #7 on: June 07, 2005, 03:56:37 PM »
Nice addition CAB ... this program was actually part of a larger routine that I wrote many years ago. In the larger program I had error checking and the data being passed was known. The addition of error checking here will solve most of the problems.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Add text strings that have ft. & inches
« Reply #8 on: June 07, 2005, 04:18:43 PM »
Thanks Keith, I fingered as much.
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.

BillB

  • Guest
Add text strings that have ft. & inches
« Reply #9 on: June 08, 2005, 01:57:54 PM »
Hey guys,,,thanks,,seems to work great
except when you have more then one
string that have the same values,,,it
won't count it,,any ideas?

BillB

BillB

  • Guest
Add text strings that have ft. & inches
« Reply #10 on: June 08, 2005, 02:01:31 PM »
Oops,,,sorry guys,,,my fault,,,does work,,was a problem with my text,,,had on at 85'-0" and one at 85'-0',,note the dual feet on last one,,,again sorry,,,great job, will come in real handy.

Thanks again

BillB

ELOQUINTET

  • Guest
Add text strings that have ft. & inches
« Reply #11 on: June 08, 2005, 03:00:09 PM »
anyway to get this to work with dimension text by any chance  :?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Add text strings that have ft. & inches
« Reply #12 on: June 08, 2005, 03:06:21 PM »
Dan I think there is one arouund here somewhere ... I'll see what I can find..
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie