• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Valued Mentor
    alanjt_
    Posts: 337
    Registered: ‎08-25-2008

    Re: need lisp that will sum selected text values

    01-30-2012 01:50 PM in reply to: pbejse
    Please use plain text.
    Active Contributor
    Posts: 34
    Registered: ‎08-15-2008

    Re: need lisp that will sum selected text values

    02-02-2012 01:49 AM in reply to: alanjt_
    Please use plain text.
    Member
    rsteel
    Posts: 4
    Registered: ‎12-01-2011

    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
    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,160
    Registered: ‎09-13-2004

    Re: need lisp that will sum selected text values

    01-15-2013 02:22 PM in reply to: rsteel

    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
    Please use plain text.
    Distinguished Mentor
    braudpat
    Posts: 593
    Registered: ‎12-15-2006

    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")
    	)
          )
        )
      )
    )
     

     

     

    Please use plain text.