On Apr 24, 11:34 pm, strawberry <zac.ca...@[EMAIL PROTECTED]
> wrote:
> On Apr 24, 3:27 pm, strawberry <zac.ca...@[EMAIL PROTECTED]
> wrote:
>
>
>
> > On 24 Apr, 14:45, strawberry <zac.ca...@[EMAIL PROTECTED]
> wrote:
>
> > > On 23 Apr, 22:15, "R. Hamm" <rallo...@[EMAIL PROTECTED]
> wrote:
>
> > > > anyone know where I can find a lsp program where I can select
existing
> > > > text in the drawing,
> > > > eg.
> > > > 12'-2 1/2"
> > > > 3 1/2"
> > > > 13' 4 3/8"
> > > > and it adds it all up for me?
> > > > I searched with no luck yet.
> > > > Thanks in advance!
> > > > Ramey
>
> > > Hmm, are these text objects or something else, e.g. dims?
>
> > Anyway, I don't have a complete solution, however, this routine from
> > Cadalyst should get you started:
>
> > ; ----- ADDNUM.LSP -----
> > ; CADalyst Oct. 1991, p. 84
> > ; TIP #703
>
> > ; Adds numbers by pick.
>
> > (defun C:ADDNUM (/ ENT CT ANX SNUM SLEN E EE X)
> > (prompt "\nPick numbers to add: (CANNOT HAVE COMMAS) ")
> > (setq ENT (ssget)) ; pick text
> > (setq CT 0 ; initialize counts
> > ANX 0)
> > (setq SNUM (ssname ENT CT)) ; get first piece of text
> > (setq SLEN (sslength ENT)) ; get number of pieces
> > (while (<= (1+ CT) SLEN) ; loop through selection set
> > (setq SNUM (ssname ENT CT) ; get next number's ENAME
> > E (entget SNUM) ; get entity data
> > EE (cdr (assoc 1 E)) ; get text value
> > X (atof EE)) ; convert string to real
> > (setq ANX (+ ANX X) ; add number to base
> > CT (1+ CT)) ; increment counter
> > )
> > (princ "\nTotal = ")(princ (rtos ANX 2 4)) ; print in decimal form.
> > (princ)
> > )
>
> > and the distof function can convert architectural fractions to real
> > numbers:
>
> > eg:
> > (distof "1'-5 1/2\"" 4)
> > 17.5
>
> > Put them together, stir it around a bit and hey presto!?! Anyway, let
> > us know how you get on.
>
> > Oh, and this function from Bill Kramer's AutoCADet's Guide to Visual
> > Lisp converts distance by testing all unit types (apparently)
>
> > (DEFUN CONVERTDISTANCE (S / LU RES TMP)
> > (SETQ LU 1)
> > (REPEAT 5 ;Five types to test
> > (SETQ TMP (DISTOF S LU)
> > LU (1+ LU))
> > (IF TMP (SETQ RES TMP)))
> > RES)
>
> I tried this earlier but it didn't seem to work. I tried it again just
> now and it worked perfectly, so go figure!?!
>
> ; ----- ADDNUMX.LSP -----
> ; CADalyst Oct. 1991, p. 84 with a tiny adaptation from strawberry
> ; TIP #703
>
> ; Adds numbers by pick.
>
> (defun C:ADDNUMX (/ ENT CT ANX SNUM SLEN E EE X)
> (prompt "\nPick numbers to add: (CANNOT HAVE COMMAS) ")
> (setq ENT (ssget)) ; pick text
> (setq CT 0 ; initialize counts
> ANX 0)
> (setq SNUM (ssname ENT CT)) ; get first piece of text
> (setq SLEN (sslength ENT)) ; get number of pieces
> (while (<= (1+ CT) SLEN) ; loop through selection set
> (setq SNUM (ssname ENT CT) ; get next number's ENAME
> E (entget SNUM) ; get entity data
> EE (cdr (assoc 1 E)) ; get text value
> X (distof EE 4)) ; convert string to real
> (setq ANX (+ ANX X) ; add number to base
> CT (1+ CT)) ; increment counter
> )
> (princ "\nTotal = ")(princ (rtos ANX 2 4)) ; print in decimal form.
> (princ)
> )
So, I guess this is a more thorough solution:
; ----- ADDNUMX.LSP -----
; CADalyst Oct. 1991, p. 84 with a tiny adaptation from strawberry
; TIP #703
;A 'distance conversion' function (from Bill Kramer)
(DEFUN CONVERTDISTANCE (S / LU RES TMP)
(SETQ LU 1)
(REPEAT 5 ;Five types to test
(SETQ TMP (DISTOF S LU)
LU (1+ LU))
(IF TMP (SETQ RES TMP)))
RES)
; Adds numbers by pick.
(defun C:ADDNUMX (/ ENT CT ANX SNUM SLEN E EE X)
(prompt "\nPick numbers to add: (CANNOT HAVE COMMAS) ")
(setq ENT (ssget)) ; pick text
(setq CT 0 ; initialize counts
ANX 0)
(setq SNUM (ssname ENT CT)) ; get first piece of text
(setq SLEN (sslength ENT)) ; get number of pieces
(while (<= (1+ CT) SLEN) ; loop through selection set
(setq SNUM (ssname ENT CT) ; get next number's ENAME
E (entget SNUM) ; get entity data
EE (cdr (assoc 1 E)) ; get text value
X (CONVERTDISTANCE (EE))) ; convert string to real
(setq ANX (+ ANX X) ; add number to base
CT (1+ CT)) ; increment counter
)
(princ "\nTotal = ")(princ (rtos ANX 2 4)) ; print in decimal form.
(princ)
)


|