BrownTiger Posted November 3, 2018 Share Posted November 3, 2018 Sometimes it is pretty cool to see total sq of a group of objects, total # of porches, or group together roof planes, or do something with a group. Since not everyone is a software developer, have time to research Ruby... Here is a simple way to do this: We want to use array of arrays [or to be exact hashmap of hashmaps] to store the data that will be displayed later. I use a single global: $tree. The hashmap $tree["rooms"] will be storing rooms and whatever properties you feel are needed. == To aggregate Rooms for example == 1) First create a macro called labelRoom to be placed into room label [defaults->Floors and Rooms->Room Label] and lets name it labelRoom referenced ? obj = referenced : obj = owner if $tree.nil? $tree = Hash.new { |hash, key| hash[key] = {} } end #id="r" + obj.to_s.gsub('#<NVPublisher:0x000','').gsub('>','') <-- X10 id="r" + obj.object_id.to_s items = Hash.new() items['room_name']=obj.name items['floor_number']=obj.floor_number items['internal_area']=obj.internal_area $tree['rooms'][id]=items "" 2) Create enumeration macro Macro: showSqft result="" $tree["rooms"].keys.each do |key| result += "Room: " + $tree["rooms"][key]['room_name'] + "[" + $tree["rooms"][key]['floor_number'].to_s + "]" + " \t" + $tree["rooms"][key]["internal_area"].round(0).to_s + " sq ft\n" end result 3) Place this macro into a TextEdit Done ================================================================================ Other times you may want to aggregate nameless objects like roof planes, here is how you can do this. Macro: labelRoofPlane referenced ? obj = referenced : obj = owner if $tree.nil? $tree = Hash.new { |hash, key| hash[key] = {} } end #id="p" + obj.to_s.gsub('#<NVPublisher:0x000','').gsub('>','') <--X10 id="p" + obj.object_id.to_s items = Hash.new() items['roof_plane']=id items['pitch']=obj.automatic_label items['area']=obj.surface_area $tree['roofplanes'][id]=items s =obj.automatic_label s Macro showRoofArea result="" sqft=0 $tree["roofplanes"].keys.each_with_index do |key,index| s= index.to_s result += "Plane: " + s +"\t" + $tree["roofplanes"][key]['pitch'] + " \t" + $tree["roofplanes"][key]["area"].round(0).to_s + " sq ft\n" sqft +=$tree["roofplanes"][key]["area"].round(0) end result += "Total: " + sqft.to_s + "sq ft\n" result === Bug fixed in a room name macro (Big Thanks to Alaskan_Son) 1 1 Link to comment Share on other sites More sharing options...
Greg_NY61 Posted November 3, 2018 Share Posted November 3, 2018 Thank you for sharing and taking the time... much appreciated! Link to comment Share on other sites More sharing options...
Kbird1 Posted November 3, 2018 Share Posted November 3, 2018 Thanks BT , very interesting . appreciate you Posting this Tip. Perhaps you should Post it and any further Tips in the Tips Forum , people may miss it here in the Symbols Forum. Link to comment Share on other sites More sharing options...
ComputerMaster86 Posted May 10, 2019 Share Posted May 10, 2019 Thanks to the original poster for posting this. I am interested in learning ruby but, I sure have a lot to learn. As I was trying to use this ruby code in my plan, I could not get the info in the text edit box to populate for more than one roof plane. It only shows info for roof plane zero. I must be doing something wrong or overlooking something. Link to comment Share on other sites More sharing options...
BrownTiger Posted May 28, 2019 Author Share Posted May 28, 2019 Sorry, did not see your post. The code was provided for X10. In x11 new property was offered... obj.object_id. You need to change this line id="p" + obj.to_s.gsub('#<NVPublisher:0x000','').gsub('>','') INTO: id ="p" + obj.object_id.to_s See below Macro: labelRoofPlane referenced ? obj = referenced : obj = owner if $tree.nil? $tree = Hash.new { |hash, key| hash[key] = {} } end id ="p" + obj.object_id.to_s items = Hash.new() items['roof_plane']=id items['pitch']=obj.automatic_label items['area']=obj.surface_area $tree['roofplanes'][id]=items s =obj.automatic_label s Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now