Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Automate addition of text objects in columns into a "Total" column

  1. #1
    Member
    Join Date
    2003-03
    Posts
    15
    Login to Give a bone
    0

    Question Automate addition of text objects in columns into a "Total" column

    I have a electrical riser diagram (which looks like a schedule) and I would like to automate the addition of the text to add up the columns into a "Total" column? I'm looking for a lisp or something that would add this text up and automatic update itself if changes occur... does anyone have any other ideas??

  2. #2
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Automate addition of text objects in columns into a "Total" column

    Your posted description is not complete enough to give us anything to work with. I doubt you will get many responses until you provide detailed information.

  3. #3
    Member
    Join Date
    2003-03
    Posts
    15
    Login to Give a bone
    0

    Default Re: Automate addition of text objects in columns into a "Total" column

    The riser diagram is like a spread sheet. You have text that are all number data that is added up at the bottom. These answers are then relocated to its sister column and add to that column. This answer is then divided by 120 to get the amps.

  4. #4
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Automate addition of text objects in columns into a "Total" column

    Why not just do the schedule in Excel and OLE the spreadsheet in? Or in 2005, you can paste the spreadsheet as AutoCAD Entities which brings it in as a Table object.

  5. #5
    Member
    Join Date
    2003-03
    Posts
    15
    Login to Give a bone
    0

    Default Re: Automate addition of text objects in columns into a "Total" column

    I using 3.3 ADT, also if I used excel how would I get the excel data located in the right spots with out re inputing this data.

  6. #6
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Automate addition of text objects in columns into a "Total" column

    See, that's what I stated in my first post: you aren't giving us enough information. What types of objects make up the schedule? ADT objects? Blocks? MText? What does this thing look like?

    We are an M/E/P firm, and we do our electrical panel schedules in Excel from day one, then just link them into the drawing. I've never seen an electrical riser diagram that looked like a schedule.

  7. #7
    Member
    Join Date
    2003-03
    Posts
    15
    Login to Give a bone
    0

    Default Re: Automate addition of text objects in columns into a "Total" column

    attached is a drawing
    Attached Files Attached Files

  8. #8
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Automate addition of text objects in columns into a "Total" column

    Load this routine in this drawing. Do not run the routine, I already have.

    Change a number on the chart.

    It should change the totals

    Peter Jamtgaard

    Code:
    (defun C:Riser3 (/ intCount entSelection lstEntity lstObjects objSelection ssSelections )
     (setq blnChangeText nil)
     (while (setq dprTotal (entsel "\nSelect text for total: "))
      (setq strGroup (strcase (substr (getstring "\nEnter Group Letter: ") 1 1)))
      (setq objTotal (vlax-ename->vla-object (car dprTotal)))
      (vlax-ldata-put objTotal "total" strGroup)
      (if (wcmatch (strcase (vla-get-objectname objTotal)) "*TEXT")
       (progn
        (setq ssSelections (ssget (list (cons 0 "*TEXT")))
              lstHandles   nil
        )
        (repeat (setq intCount (sslength ssSelections))
         (setq intCount     (1- intCount)
               entSelection (ssname ssSelections intCOunt)
               objSelection (vlax-ename->vla-object entSelection)
               lstObjects   (cons objSelection lstObjects)
         )
         (vlax-ldata-put objSelection "item" strGroup)   
        )
        (setObjectReactorRiser lstObjects)
        (setq lstObjects nil)
       )
      )
     )
     (princ)
    )
    (defun SetObjectReactorRiser (lstObjects)
     (if (not rxnRiser)   
      (setq rxnRiser        (vlr-object-reactor lstObjects "Riser" 
                                                           '((:vlr-Modified  . Riser2)))
            rxnComEndRiser  (vlr-editor-reactor nil '((:vlr-commandended . Riser3)))
      )
      (foreach objLayer lstObjects
       (vlr-owner-add rxnRiser objLayer)
      )
     )
    )
    
    ; Object Reactor
    (defun Riser2 (objOwner objReactor lstEntity)
     (if (not RerunRiser)
      (if (vlax-ldata-get objOwner "item")
       (setq blnChangedText 'T)
      )
     )
    )
    
    ; Command Ended Reactor
    (defun Riser3 (CALL CALLBACK / lstGroups)
     (if blnChangedText
      (foreach strGroup (getGroupLetters)
       (setq RiserRerun 'T)
       (setTotal strGroup) 
       (setq RiserRerun nil)
      )
     )
     (setq blnChangeText nil)
    )
    
    (defun getGroupLetters (/ lstGroupLetters strGroupLetter)
     (vlax-for objLayout (vla-get-layouts
                          (vla-get-activedocument
                           (vlax-get-acad-object)
                          )
                         )
      (vlax-for objBlock (vla-get-block objLayout)
       (if (wcmatch (strcase (vla-get-objectname objBlock)) "*TEXT")
        (if (setq strGroupLetter (vlax-ldata-get objBlock "total"))
         (if (not (member strGroupLetter lstGroupsLetters))
          (setq lstGroupLetters (cons strGroupLetter lstGroupLetters))
         )
        )
       )
      )
     )
     (if lstGroupLetters 
      (acad_strlsort lstGroupLetters)
     )
    )
    
    (defun setTotal (strGroup / dblTotal lstObjects objTotal )
     (setq dblTotal 0)
     (vlax-for objLayout (vla-get-layouts
                          (vla-get-activedocument
                           (vlax-get-acad-object)
                          )
                         )
      (vlax-for objBlock (vla-get-block objLayout)
       (if (wcmatch (strcase (vla-get-objectname objBlock)) "*TEXT")
        (if (= strGroup (vlax-ldata-get objBlock "item"))     
         (setq lstObjects (cons objBlock lstObjects))
         (if (= strGroup (vlax-ldata-get objBlock "total"))
          (setq objTotal objBlock)
         )
        )
       )
      )
     )
     (if (and lstObjects objTotal)
      (progn
       (foreach objText lstObjects
        (setq dblTotal (+ dblTotal (atof (vla-get-textstring objText))))
       )
       (vla-put-textstring objTotal (itoa (fix dblTotal)))
      )
     )
    )
     
    
    (defun StartRiser (/ lstObjects)
     (vlax-for objLayout (vla-get-layouts
                          (vla-get-activedocument
                           (vlax-get-acad-object)
                          )
                         )
      (vlax-for objBlock (vla-get-block objLayout)
       (if (wcmatch (strcase (vla-get-objectname objBlock)) "*TEXT")
        (if (setq strGroup (vlax-ldata-get objBlock "item"))
         (progn
          (setq lstObjects (cons objBlock lstObjects))      
         )
        )
       )
      )
     )
     (setObjectReactorRiser lstObjects)
    )
    (startriser)
    Attached Files Attached Files

  9. #9
    Member
    Join Date
    2003-03
    Posts
    15
    Login to Give a bone
    0

    Default Re: Automate addition of text objects in columns into a "Total" column

    Peter; I tried to load the drawing but get a compatible message, could you save it as a ACAD2000 drawing. Thanks in advance

  10. #10
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    0

    Default Re: Automate addition of text objects in columns into a "Total" column

    I just ran across this thread and was wondering if I could get some information.







    Thanks,
    Chirs
    Last edited by framedNlv; 2007-02-07 at 07:38 PM.

Page 1 of 2 12 LastLast

Similar Threads

  1. change "grand total" text
    By t1.shep in forum Revit Architecture - General
    Replies: 3
    Last Post: 2011-07-13, 04:10 PM
  2. 2012: Automate reset "override graphics in view" ?
    By FWSchreck in forum Revit Architecture - General
    Replies: 2
    Last Post: 2011-07-12, 04:22 PM
  3. Automate "Insert From File Views" ussing API
    By Pepen in forum Revit - API
    Replies: 4
    Last Post: 2009-12-22, 07:06 PM
  4. Replies: 0
    Last Post: 2009-08-18, 02:16 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
  •