Ruby ? creating your own accumulating totals


Renerabbitt
 Share

Recommended Posts

This seems like a particular complex bit of code. How do we accumulate totals for custom object fields.
The problem as I see it is making sure we are not accumulating every time a publisher changes its reported value...so we have to script in a checksum..maybe through a rescue? or is this some sort of array..how would you approach this?

Link to comment
Share on other sites

I use, if available, a unique identifier and an array (could probably use a hash as well).

 

For instance I add up all window areas on an elevation uisng a label in the window, but if the window changes size, one needs to not just add the new area, but replace/remove the old area in the summation.

The unique identifier I use is the schedule number, and force the schedule to not duplicate.

 

so if your custom object field is from an object that is "seen" (windows are seen on elevation and plan (asssuming the label is showing), I suppose you could use the same methodology

 

Link to comment
Share on other sites

I use a timer for most things like this.  Periodically I clear the hash (don't like using arrays) and then allow all the macros to update the hash and sum the data.  Typically I set my timer to about 5 minutes so I'm not updating to often.  The macros just skip all processing until the timer has reached the update interval.

 

It's also possible to have a macro that's only displayed on demand to clear the hash.  That way you can display it only when you want to force an update.

  • Upvote 1
Link to comment
Share on other sites

I've tested and used quite a few different methods for this type of thing, but I hated having to manually refresh things or depend on timers, so I recently went back to the drawing board and developed an entirely new system...

 

Totals.thumb.gif.9e06aae853702612b6d9e0c21baf688f.gif

 

It remain constantly live, and allows using either a standalone total or a functioning schedule that can be reordered.  Its a rather complex system with its own limitations but I love how it works.  I don't have a lot of spare time these days but I can offer my services to help set something up or teach you how it works as time permits.  If you're interested, I think you have my email. 

Link to comment
Share on other sites

50 minutes ago, Alaskan_Son said:

I've tested and used quite a few different methods for this type of thing, but I hated having to manually refresh things or depend on timers, so I recently went back to the drawing board and developed an entirely new system...

 

Totals.thumb.gif.9e06aae853702612b6d9e0c21baf688f.gif

 

It remain constantly live, and allows using either a standalone total or a functioning schedule that can be reordered.  Its a rather complex system with its own limitations but I love how it works.  I don't have a lot of spare time these days but I can offer my services to help set something up or teach you how it works as time permits.  If you're interested, I think you have my email. 

What happen if you edit one of the existing walls?

Link to comment
Share on other sites

I showed that in the quick GIF clip above unless I’m misunderstanding the question.  I both added walls and edited existing walls.  Moving existing walls changed the automatically produced foundation walls which also updated accordingly.  

Link to comment
Share on other sites

interesting ...I think my macro in the label would give similar output, but I think if I remember correctly the label always has to be showing (even if it is teeny tiny)

 

does your total update if you delete the wall, in say,a 3d view,.without going back to the view with the total or a plan view?

 

that is always the limitation I have found ...unable to always trigger a refresh under all conditions...especially the removal.of an object as there is no "on_delete" event that I know of.

 

The CA schedules are oh so close to being able to do this type of thing

 

 

Link to comment
Share on other sites

rene, 

 

Joe looks to add things to a hash and then runs timers to add things up (presumably goes through the hash to add applicable fields)

I add things to an array via a label, and then have a macro which runs through the array to add them up.

 

The tricky part I have found is accounting for a removal of an object. I have a reset macro on the plan, which it looks like Joe has something similar.

 

So i have two macros below, one in the window label, and one in the pline(elevation area) label

 

image.thumb.png.6f44dc8b69d679fa2e3cd343abef10a2.png

 

then resize add a window:

image.thumb.png.123f55a067381d317621f7462f415572.png

 

Link to comment
Share on other sites

My problem with using Schedules for this is that I can't specify an area to be in more than one Schedule. 

Basically I have many closed Polylines all on floor level 1

  • I want all of them to be in Schedule A
  • some of them in Schedule B
  • some in Schedule C
  • etc.

I need to display totals for each Schedule as well as some calculated totals (added, and/or subtracted)

 

Schedules currently just don't have the flexibility I need.  

 

Link to comment
Share on other sites

2 minutes ago, Joe_Carrick said:

My problem with using Schedules for this is that I can't specify an area to be in more than one Schedule. 

Basically I have many closed Polylines all on floor level 1

  • I want all of them to be in Schedule A
  • some of them in Schedule B
  • some in Schedule C
  • etc.

I need to display totals for each Schedule as well as some calculated totals (added, and/or subtracted)

 

Schedules currently just don't have the flexibility I need.  

 

This was the major point of this thread for me, beside trying to learn about how to approach this. From studying Ruby and trying to figure out how it correlates to the nuances in Chief, I have yet to figure out anything that totals without being a huge workaround. I think we are due for a suggestion to Chief no?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share