Results 1 to 3 of 3

Thread: Multification factor of 0.9 for final sum

  1. #1
    Login to Give a bone
    0

    Default Multification factor of 0.9 for final sum

    Please update the below code with 0.9 multiplication factor for both prefix and suffix alphabets.

    Code:
    (defun C:9FS (/ cpent elist en ip newtxt pt ss sum sumtxt txt)(princ "\n\t\t>>>  Select text to get summ >>>")(if;;select texts/mtexts on screen :(setq ss (ssget '((0 . "*TEXT"))));; if selected then :(progn  ;; store the first text entity for using 'em further :(setq cpent (ssname ss 0))  ;; set initial sum to zero :  (setq sum 0.)  ;; loop trough selected texts/mtexts :  (while    ;; get the first text in selection :    (setq en (ssname ss 0))    ;; get entity list of them :    (setq elist (entget en))    ;; get the textstring by key 1 from entity list :    (setq txt (cdr (assoc 1 elist)))    ;; create output string :    (setq sumtxt	   ;; concatenate strings :	   (strcat	     ;; convert digits to string :	     (rtos	       ;; add to summ the digital value of text :	       (setq sum (+ (atof (vl-list->string (vl-remove-if-not '(lambda (x) (member x '(46 48 49 50 51 52 53 54 55 56 57))) (vl-string->list txt)))) sum))	       ;; 2 is for metric units (3 for engineering) :	       2	       ;; set precision by current :	       (getvar "dimdec")))	  )    ;; delete entity from selection set :    (ssdel en ss)    )  ;; display message in the command line:  (princ (strcat "\nSumm=" sumtxt))  (setq pt (getpoint "\nSpecify the new text location: "))  ;; get the insertion point of stored entity :  (setq ip (cdr (assoc 10 (entget cpent))))  ;; copy text entity to the new destination point :  (command "_copy" cpent "" ip pt)  ;; get the last created entity :  (setq newtxt (entlast))  ;; get entity list of them :  (setq elist (entget newtxt))  ;; modify entity list with new text string :  (entmod (subst (cons 1 sumtxt)(assoc 1 elist) elist))  ;; update changes :  (entupd newtxt)  ))(princ)  )(princ "\nStart command with STX...")(princ)

  2. #2
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Multification factor of 0.9 for final sum

    Please rearrange your lisp , and upload a sample dwg where to apply it

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Multification factor of 0.9 for final sum

    Something like this?

    Code:
    (defun C:9FS (/ cpent elist en ip newtxt pt ss sum sumtxt txt)
      (princ "\n\t\t>>>  Select text to get summ >>>")
      (if
        ;;select texts/mtexts on screen :
        (setq ss (ssget '((0 . "*TEXT"))))
         ;; if selected then :
         (progn
           ;; store the first text entity for using 'em further :
           (setq cpent (ssname ss 0))
           ;; set initial sum to zero :
           (setq sum 0.)
           ;; loop trough selected texts/mtexts :
           (while
             ;; get the first text in selection :
             (setq en (ssname ss 0))
              ;; get entity list of them :
              (setq elist (entget en))
              ;; get the textstring by key 1 from entity list :
              (setq txt (cdr (assoc 1 elist)))
              ;; create output string :
              (setq sumtxt
                     ;; concatenate strings :
                     (strcat
                       ;; convert digits to string :
                       (rtos
                         ;; add to summ the digital value of text :
                         (setq sum
                                (* 0.9
                                   (+
                                     (atof
                                       (vl-list->string
                                         (vl-remove-if-not
                                           '(lambda (x)
                                              (member x
                                                      '(46 48 49 50 51 52 53 54 55 56 57)
                                              )
                                            )
                                           (vl-string->list txt)
                                         )
                                       )
                                     )
                                     sum
                                   )
                                )
                         )
                         ;; 2 is for metric units (3 for engineering) :
                         2
                         ;; set precision by current :
                         (getvar "dimdec")
                       )
                     )
              )
              ;; delete entity from selection set :
              (ssdel en ss)
           )
           ;; display message in the command line:
           (princ (strcat "\nSumm=" sumtxt))
           (setq pt (getpoint "\nSpecify the new text location: "))
           ;; get the insertion point of stored entity :
           (setq ip (cdr (assoc 10 (entget cpent))))
           ;; copy text entity to the new destination point :
           (command "_copy" cpent "" ip pt)
           ;; get the last created entity :
           (setq newtxt (entlast))
           ;; get entity list of them :
           (setq elist (entget newtxt))
           ;; modify entity list with new text string :
           (entmod (subst (cons 1 sumtxt) (assoc 1 elist) elist))
           ;; update changes :
           (entupd newtxt)
         )
      )
      (princ)
    )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. Replies: 3
    Last Post: 2018-09-19, 04:32 AM
  2. Prelim to final
    By Kroke in forum Revit - Gallery
    Replies: 5
    Last Post: 2005-11-18, 02:09 PM
  3. Final Project
    By mnisbett in forum Revit - Gallery
    Replies: 4
    Last Post: 2004-12-02, 04:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •