Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Mentor
alanjt_
Posts: 469
Registered: ‎08-25-2008
Message 11 of 15 (577 Views)

Re: need lisp that will sum selected text values

01-30-2012 01:50 PM in reply to: pbejse
Active Contributor
leipogs23
Posts: 34
Registered: ‎08-15-2008
Message 12 of 15 (558 Views)

Re: need lisp that will sum selected text values

02-02-2012 01:49 AM in reply to: alanjt_
Member
Rusty.Steel
Posts: 4
Registered: ‎12-01-2011
Message 13 of 15 (449 Views)

Re: need lisp that will sum selected text values

01-15-2013 01:50 PM in reply to: *Michael Pape & Associates

Tim,

 

Works great, but where in the lsp could I change the rounding precision of the final number. The numbers I am selecting are all rounded to the second decimal place (which I want), BUT the sum number the lsp is givinf me is rounded to the fisrt decimal place (which I would like to change to the second). Thanks 

Thanks,

Rusty Steel
Cobb Engineering Company
*Expert Elite*
Kent1Cooper
Posts: 5,242
Registered: ‎09-13-2004
Message 14 of 15 (442 Views)

Re: need lisp that will sum selected text values

01-15-2013 02:22 PM in reply to: Rusty.Steel

rsteel wrote:

.... where in the lsp could I change the rounding precision of the final number. ... the sum number the lsp is givinf me is rounded to the fisrt decimal place (which I would like to change to the second). ....


[In case Tim's not still checking in after 8-1/2 years....]

 

Change the last number in the (rtos) functions such as (rtos nu5 2 1) from a 1 to a 2 -- that's the number of decimal places [see (rtos) in the AutoLISP Reference].

Kent Cooper
*Expert Elite*
braudpat
Posts: 1,837
Registered: ‎12-15-2006
Message 15 of 15 (411 Views)

Re: need lisp that will sum selected text values

01-18-2013 08:52 AM in reply to: Kent1Cooper

 

Hello

 

An other solution which can read Text & MText entities ...

This routine (TOTTXT) comes froma French forum but I don't remender the Author : SORRY !

 

Bye, Patrice

 

;; Routine TOTTXT.LSP
;; Fonctionne en principe sur les TEXT & MTEXT de type numerique
;; Version 1.1 avec Creation d un texte du Total

(defun c:tottxt (/ doc sel tot pt)
  (vl-load-com)
  (setq	tot 0
	doc (vla-get-activedocument (vlax-get-acad-object))
  )
  (princ "\nSélectionnez les textes")
  (if (ssget (list (cons 0 "TEXT,MTEXT")))
    (progn
      (vlax-map-collection
	(setq sel (vla-get-activeselectionset doc))
	'(lambda (x)
	   (setq tot (+ (atof (vla-get-textstring x)) tot))
	 )
      )
      (vla-delete sel)
      (if (setq pt (getpoint "\nPositionnez le résultat: "))
	(vla-addText
	  (vla-get-ModelSpace doc)
	  (rtos tot)
	  (vlax-3d-point pt)
	  (getvar "TEXTSIZE")
	)
      )
    )
  )
)
 

 

 

Bye, Pat

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community