ACADuser Posted March 7, 2020 Share Posted March 7, 2020 Well, I finally conquered my issue with room number that needs to start with 100 and not 101. Using a Note in each room and a Room schedule, the following macro, my first real Marco BTW, will display room numbers per floor starting at 100, 200 etc. # Macro by ACADuser # Return Room Schedule Note Number plus 99 for Romm Numbers starting at 100 on floor 1 # returns 200 on floor 2 etc. referenced ? obj=referenced : obj = owner begin room_num = obj.schedule_number.to_i room_number = (room_num + 99 * floor_number).to_s $Name = room_number rescue "" end Link to comment Share on other sites More sharing options...
Doug_N Posted March 7, 2020 Share Posted March 7, 2020 That looks like a pretty slick macro. How do you use it? Is it a custom field in the room schedule? Link to comment Share on other sites More sharing options...
ACADuser Posted March 7, 2020 Author Share Posted March 7, 2020 Well, I spoke too soon. It updates in the NOTE but not in the schedule. It now displays 99 in the schedule. Yes, I had a custom field I thought I could use in the schedule. Back to the drawing board. Link to comment Share on other sites More sharing options...
Alaskan_Son Posted March 8, 2020 Share Posted March 8, 2020 Alan, I think you'll find that you're better off not trying to even use a Room Finish Schedule. Just use a completely customized Note Schedule that includes all your desired room attributes as custom fields and their related columns. Also, I believe you'll find that your macro will result in undesirable room numbering on any floor other than floor 1. On floor zero, all results will be zero, and on floor 5, your room numbers will increase by 5 (500, 505, 510, 520, etc.). There are countless solutions using Ruby, but I would recommend something like... schedule_number.to_i + (floor_number*100) ---->if you have less than 100 rooms or floor_number.to_s + (schedule_number.to_i-1).to_s.rjust(2, "0") or ((schedule_number.to_f-1)*0.1).round(1).to_s.sub(".", "") or floor_number.to_s + '%02d' % (schedule_number.to_i-1) or ........ Link to comment Share on other sites More sharing options...
ACADuser Posted March 8, 2020 Author Share Posted March 8, 2020 Michael Thanks for that info. I had not thought through all the possibilities. I only have 82 rooms in this building & only one floor. But will use one of your algorithms. I am using a NOTE Schedule with a custom field but currently, the schedule displays 99 for all the room numbers. I thought I had it working at one point. Link to comment Share on other sites More sharing options...
ACADuser Posted March 8, 2020 Author Share Posted March 8, 2020 Attached is my test plan. I can not get your code to work in the schedule. It works in the NOTE. # Macro by ACADuser # Return Room Schedule Note Number pluss 99 for Romm Numbers starting at 100 on floor 1 # returns 200 on floor 2 etc. referenced ? obj=referenced : obj = owner begin room_num = obj.schedule_number rm_num = (room_num.to_i + (floor_number*100)) $Name = rm_num.to_s rescue "X" end Rm Numbers.zip Link to comment Share on other sites More sharing options...
wjmdes Posted March 8, 2020 Share Posted March 8, 2020 (I am glad to see I am not the only one working today) Link to comment Share on other sites More sharing options...
ACADuser Posted March 8, 2020 Author Share Posted March 8, 2020 As I try variations of the code I get 0 or 99 or 100 in the schedule. The Note in the room displays the correct result. The correct room code string appears in the Result Box in the Macro Edit dialog. There must be something I'm getting wrong in the ruby code. Link to comment Share on other sites More sharing options...
ACADuser Posted March 8, 2020 Author Share Posted March 8, 2020 1 minute ago, wjmdes said: (I am glad to see I am not the only one working today) I was working yesterday but this is playtime for me. Although this code-breaking is very frustrating because I know nothing about Ruby. Off to the dog park for some real playtime with my best friend. Later Link to comment Share on other sites More sharing options...
Alaskan_Son Posted March 8, 2020 Share Posted March 8, 2020 Not at my computer to open your plan, but I can see from the code you posted that you’re just opening the door to a bunch of problems with a handful of unnecessary code. Specifically though, your defining a global variable for no reason. That’s what’s likely causing the same number in the schedule. With a few very unique exceptions and for all intents and purposes, a global variable can only ever have one value in any given view. Link to comment Share on other sites More sharing options...
ACADuser Posted March 8, 2020 Author Share Posted March 8, 2020 That's how I learn, from my mistakes. Updated code but still no joy in the schedule. # Macro by ACADuser # Return Room Schedule Note Number plus 99 for Room Numbers starting at 100 on floor 1 # returns 200 on floor 2 etc. begin obj = owner room_num = obj.schedule_number rm_num = (room_num.to_i + (floor_number*100)) rm_num.to_s rescue "X" end Link to comment Share on other sites More sharing options...
Alaskan_Son Posted March 8, 2020 Share Posted March 8, 2020 I stepped into the office real quick Alan. Your problem is that you’re not using the 2D symbol. Macros using schedule_number don’t work consistently in schedules. You either have to use the callout label or you have to use a different macro to generate the numbers inside your schedule. Link to comment Share on other sites More sharing options...
ACADuser Posted March 9, 2020 Author Share Posted March 9, 2020 I'm not understanding this behavior. This works, it updates the schedule begin room_num = owner.schedule_number rescue "X" end But this does not work, it shows 99 in the schedule field begin room_num = schedule_number.to_i + (floor_number*100) -1 rescue "X" end Link to comment Share on other sites More sharing options...
ACADuser Posted March 9, 2020 Author Share Posted March 9, 2020 It appears that strings are OK but as soon as you turn the room number into an interger it breaks. schedule_number.to_i Link to comment Share on other sites More sharing options...
Alaskan_Son Posted March 9, 2020 Share Posted March 9, 2020 1 hour ago, ACADuser said: It appears that strings are OK but as soon as you turn the room number into an interger it breaks. schedule_number.to_i Alan, The schedule_number is already a string to start with. As long as you don't try modifying it, it will work just fine. It's modification of any kind that breaks it. As I stated above... "Macros using schedule_number don’t work consistently in schedules..." I should have said macros attempting to modify schedule_number don't work. It has something to do with the way the schedule_number is generated by it's own schedule and the order in which those macro executions take place. At any rate, you have to either use the 2D Symbol column or another custom solution. I personally usually just use the 2D Symbol. Link to comment Share on other sites More sharing options...
Joe_Carrick Posted March 9, 2020 Share Posted March 9, 2020 I use a couple of custom macros in a "Note" (rectangular with room_number in the top and room_label in the bottom) The Note (stored in the library) is placed in each room. The room data is picked up from the room the Note is placed in - all done with macros in Custom Fields within the Note. I also substitute a "Note Schedule" with custom fields instead of a "Room Finish Schedule". This provides a much greater amount of Schedule Detail than can be provided with a conventional Room Finish Schedule. Link to comment Share on other sites More sharing options...
ACADuser Posted March 9, 2020 Author Share Posted March 9, 2020 Joe, Are you able to start the room number with 100 and not 101? I did use a Note Schedule. Link to comment Share on other sites More sharing options...
Alaskan_Son Posted March 9, 2020 Share Posted March 9, 2020 Alan, Is there some reason you're opposed to using the 2D Symbol column? Link to comment Share on other sites More sharing options...
Joe_Carrick Posted March 9, 2020 Share Posted March 9, 2020 5 minutes ago, ACADuser said: Joe, Are you able to start the room number with 100 and not 101? I did use a Note Schedule. Yes, that's possible. However, I don't do that. One thing that I do is have a separate "Note Schedule" for each Floor. That way each Floor starts numbering at 101, 201, 301, etc. I could set it to start at 100, 200, 300, etc. Link to comment Share on other sites More sharing options...
ACADuser Posted March 9, 2020 Author Share Posted March 9, 2020 Micheal No reason except I have not figured out how to do it & display the room number in the room. I'm messing around with it now. Link to comment Share on other sites More sharing options...
Alaskan_Son Posted March 9, 2020 Share Posted March 9, 2020 8 minutes ago, ACADuser said: Micheal No reason except I have not figured out how to do it & display the room number in the room. I'm messing around with it now. All you have to do is open the Note Schedule in your previously attached plan and add the 2D Symbol column. Link to comment Share on other sites More sharing options...
ACADuser Posted March 9, 2020 Author Share Posted March 9, 2020 I get it, you just have to live with the rectangle around the room number. A bit clunky but I can live with that for now. Thanks so much for the education. And Joe, I appreciate your input too. 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