Results 1 to 4 of 4

Thread: Need Help, very urgently. Need 0.9 value as a multiplication factor for final summation of numbers

  1. #1
    Login to Give a bone
    0

    Default Need Help, very urgently. Need 0.9 value as a multiplication factor for final summation of numbers

    The following code has code for summation of selected numbers and I need a help that the final result should be multiplied by a value of 0.9 and then result should place as text on screen. Advanced thanks.
    (defun C:ADCC (/ 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 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
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: Need Help, very urgently. Need 0.9 value as a multiplication factor for final summation of numbers

    Code:
    (defun C:ADCC (/ 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 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 "" "_non" ip "_non" 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)

  3. #3
    Login to Give a bone
    0

    Default Re: Need Help, very urgently. Need 0.9 value as a multiplication factor for final summation of numbers

    Thank you so much Sir, for your spot reply with exact result.

  4. #4
    Login to Give a bone
    0

    Default Re: Need Help, very urgently. Need 0.9 value as a multiplication factor for final summation of numbers

    Dear Sir,

    Could you please a favour for me. If multiplication factor is not a fixed value like 0.9 value, The program should ask for multiplication value then there shall be a provision to take any variable factor as input from user. Advanced Thank you Sir.

    Regards,
    T.Brahmanandam.

Similar Threads

  1. Accurate 45 deg buttweld fittings needed urgently!
    By pauljordan in forum AMEP General
    Replies: 5
    Last Post: 2009-06-10, 03:04 PM
  2. Summation
    By wfrst2008 in forum Revit Structure - General
    Replies: 3
    Last Post: 2007-09-13, 08:24 PM
  3. Multiplication of Fields in Table cells
    By Nishchay Bhuta in forum VBA/COM Interop
    Replies: 0
    Last Post: 2007-03-29, 10:25 AM
  4. Summation of Mass Properties in the BOM
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 0
    Last Post: 2006-09-19, 09:41 PM
  5. ISO Dimensioning - Urgently need help
    By Borg in forum AutoLISP
    Replies: 7
    Last Post: 2006-08-25, 03:33 AM

Posting Permissions

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