lavorhaynie Posted October 9, 2019 Share Posted October 9, 2019 Anyone out there offer Ruby services for $? I need a fairly simple macro created. I need a label for my layout files that will display the path of the layout file (%file%), truncating the first nn characters. i.e. d:\Users\username\DesignWork\CAX11\Builders\Builder_1\Standard_Plans\Plan_1 with nn=43 would display as: Builder_1\Standard_Plans\Plan_1 -or- Can this be done in X11 without writing a macro? Thanks much! Link to comment Share on other sites More sharing options...
Kbird1 Posted October 12, 2019 Share Posted October 12, 2019 @Alaskan_Son (Michael) and @Joe_Carrick both do Marcos for $$...... try message either of them to see if it's possible.... M. Link to comment Share on other sites More sharing options...
Joe_Carrick Posted October 13, 2019 Share Posted October 13, 2019 On 10/9/2019 at 2:58 PM, lavorhaynie said: Can this be done in X11 without writing a macro? No, but it's fairly simple to do. There are 2 Ruby Attributes of a Layout Box that can be used: referenced_full_filename - same as %file% referenced _filename - just the name of the file that was sent to layout. It would actually be better to know what set of letters you want to eliminate rather than a specific number of characters. For example: d:\Users\username\DesignWork\CAX11\Builders\ where you provide the actual username. Link to comment Share on other sites More sharing options...
Joe_Carrick Posted October 13, 2019 Share Posted October 13, 2019 Try this as a custom macro placed in the Layout Box Label: nlen = referenced_full_filename.length-1 referenced_full_filename[43,nlen].gsub(".plan","") 1 Link to comment Share on other sites More sharing options...
Joe_Carrick Posted October 13, 2019 Share Posted October 13, 2019 Note: %file% displays the name of the Layout File, not the Plan file the Layout Box came from. IAE. It's not possible to manipulate the Chief standard Global and Object macros from within a user macro because the underlying data is basically not directly available. Link to comment Share on other sites More sharing options...
Chopsaw Posted October 13, 2019 Share Posted October 13, 2019 10 hours ago, Joe_Carrick said: It would actually be better to know what set of letters you want to eliminate rather than a specific number of characters. How would that look Joe if you just wanted to hide the directory and /Users/Username/ and maybe a file or two ? Or are you wanting the exact characters ? Link to comment Share on other sites More sharing options...
lavorhaynie Posted October 14, 2019 Author Share Posted October 14, 2019 @Alaskan_Son contacted me and wrote a macro that pulls the path string I need. Did a great job at a very reasonable price. Thank you @Alaskan_Son! Joe, I set up your suggestion and found that it works well too. I do have a question for you, or anyone that might know the answer... how do you get the Ruby Attributes of a Layout Box that can be used? Actual path (filename not included): C:\Users\zbook17g3\OneDrive\_Business\DesignsByLaVor\_WorkX11\_Builders\CH - Compass\Clients\Working\Hancock - Hardin Your suggestion from above: CH - Compass/Clients/Working/Hancock - Hardin/Hardin I would like to have: CH - Compass/Clients/Working/Hancock - Hardin Thanks! Link to comment Share on other sites More sharing options...
Joe_Carrick Posted October 14, 2019 Share Posted October 14, 2019 I have a macro that will show (in the Ruby Console) all the attributes for any selected object. Here's the list for a typical Layout Box: automatic_label ------------ "Graph Schedule Section/Elevation" ------------------------------------------------------------------------------------ String box_scale ------------------ "1/4 in = 1 ft" ------------------------------------------------------------------------------------------------------- String drawing_group -------------- 1 --------------------------------------------------------------------------------------------------------------------- Integer floor_number --------------- 1 --------------------------------------------------------------------------------------------------------------------- Integer height --------------------- 5.390048486681028 ----------------------------------------------------------------------------------------------------- Float layer ---------------------- arch-d_layout_box_borders --------------------------------------------------------------------------------------------- Symbol layer_line_color ----------- 255 ------------------------------------------------------------------------------------------------------------------- Integer layer_line_style ----------- 0 --------------------------------------------------------------------------------------------------------------------- Integer layer_line_weight ---------- 1 --------------------------------------------------------------------------------------------------------------------- Integer layer_set ------------------ "Arch-D Print" -------------------------------------------------------------------------------------------------------- String layer_text_style ----------- "HIDDEN" -------------------------------------------------------------------------------------------------------------- String line_style ----------------- solid ----------------------------------------------------------------------------------------------------------------- Symbol line_weight ---------------- 1 --------------------------------------------------------------------------------------------------------------------- Integer object_type ---------------- layout_box ------------------------------------------------------------------------------------------------------------ Symbol referenced_filename -------- "Jason Bales Residence - Phase 1" ------------------------------------------------------------------------------------- String referenced_full_filename --- "D:/Dropbox/Chief Architect Projects/X11/Jason Bales Residence - Phase 1/Plan/Jason Bales Residence - Phase 1.plan" --- String referenced_layer_set ------- "All On Set" ---------------------------------------------------------------------------------------------------------- String width ---------------------- 3.6485143922610597 ---------------------------------------------------------------------------------------------------- Float Link to comment Share on other sites More sharing options...
Joe_Carrick Posted October 14, 2019 Share Posted October 14, 2019 41 minutes ago, lavorhaynie said: would like to have: CH - Compass/Clients/Working/Hancock - Hardin nstart = 43 nlast = referenced_full_filename.length-1 result = referenced_full_filename[nstart,nlast] result = result.gsub(".plan","") result = result.gsub("/Hardin","") explanation: line 3 sets the result to the characters starting at the 43rd character and ending at the last character line 4 strips all instances of ".plan" from the result line 5 strips all instances of "/Hardin" from the result Link to comment Share on other sites More sharing options...
Joe_Carrick Posted October 14, 2019 Share Posted October 14, 2019 3 hours ago, Chopsaw said: Or are you wanting the exact characters ? The actual characters would be required - or the number of "/" characters - or maybe if you just want to eliminate everything after the last "/". There are several possibilities. The macro can become more complex - actually just longer - depending on what rules you want to follow. Ruby is mostly about manipulating data and performing calculations. This case is basic manipulation of a text string - which is very much just an array of characters. Link to comment Share on other sites More sharing options...
Chopsaw Posted October 14, 2019 Share Posted October 14, 2019 5 minutes ago, Joe_Carrick said: The actual characters would be required - or the number of "/" characters - or maybe if you just want to eliminate everything after the last "/". There are several possibilities. The macro can become more complex - actually just longer - depending on what rules you want to follow. I was just looking at the macro you just wrote for LaVor and realized that it will only work for one particular file. Is there a way to take his example of : C:\Users\zbook17g3\OneDrive\_Business\DesignsByLaVor\_WorkX11\_Builders\CH - Compass\Clients\Working\Hancock - Hardin\Hardin.plan Then write a macro that effectively eliminates everything before the 8th instance of "\" and after the 12th instance. Producing the result of : CH - Compass\Clients\Working\Hancock - Hardin Then this would work for every project unless there was a change in the structure of the file path and then the macro could easily be rewritten or copied and edited ? Link to comment Share on other sites More sharing options...
Alaskan_Son Posted October 14, 2019 Share Posted October 14, 2019 2 minutes ago, Chopsaw said: I was just looking at the macro you just wrote for LaVor and realized that it will only work for one particular file. Is there a way to take his example of : C:\Users\zbook17g3\OneDrive\_Business\DesignsByLaVor\_WorkX11\_Builders\CH - Compass\Clients\Working\Hancock - Hardin\Hardin.plan Then write a macro that effectively eliminates everything before the 8th instance of "\" and after the 12th instance. Producing the result of : CH - Compass\Clients\Working\Hancock - Hardin Then this would work for every project unless there was a change in the structure of the file path and then the macro could easily be rewritten or copied and edited ? Yes. That’s essentially the method I utilized. In a nutshell, my method for this particular use case was to first convert the file path to a string, then to break that string up into an array of values to represent drive, directory, subdirectories, and file, and then to display only the first 3 of the last 4 values in the array. Link to comment Share on other sites More sharing options...
Chopsaw Posted October 14, 2019 Share Posted October 14, 2019 2 minutes ago, Alaskan_Son said: Yes. That’s essentially the method I utilized. In a nutshell, my method for this particular use case was to first convert the file path to a string, then to break that string up into an array of values to represent drive, directory, subdirectories, and file, and then to display only the first 3 of the last 4 values in the array. Ok that sounds much more logical. Thank You. I guess what you are saying is that useful macro's cost money. Link to comment Share on other sites More sharing options...
Alaskan_Son Posted October 14, 2019 Share Posted October 14, 2019 Just now, Chopsaw said: Ok that sounds much more logical. Thank You. I guess what you are saying is that useful macro's cost money. ...or at the least, valuable time and expertise. The first of which you can of course spend freely...in order to arrive at the second if you should so choose to do so. Or, if your time is valuable enough to you, yes, you can just pay one of us (with money) to set something up for you or perhaps to coach you so you can start writing your own. Link to comment Share on other sites More sharing options...
Joe_Carrick Posted October 14, 2019 Share Posted October 14, 2019 9 hours ago, Chopsaw said: Is there a way to take his example of : C:\Users\zbook17g3\OneDrive\_Business\DesignsByLaVor\_WorkX11\_Builders\CH - Compass\Clients\Working\Hancock - Hardin\Hardin.plan Then write a macro that effectively eliminates everything before the 8th instance of "\" and after the 12th instance. Producing the result of : CH - Compass\Clients\Working\Hancock - Hardin Sure, but a better method would be to use: result = referenced_full_filename.rpartition("_Builders/") result = result[2].rpartition("/") result = result[0] This way you only have to know that you want to eliminate everything up-to and including "_Builders/" and everything after the last "/". Note that I'm using the "/" instead of the "\" because that's what Chief uses in the referenced_full_filename attribute. 1 Link to comment Share on other sites More sharing options...
Chopsaw Posted October 14, 2019 Share Posted October 14, 2019 3 hours ago, Joe_Carrick said: Sure, but a better method would be to use: result = referenced_full_filename.rpartition("_Builders/") result = result[2].rpartition("/") result = result[0] This way you only have to know that you want to eliminate everything up-to and including "_Builders/" and everything after the last "/". Note that I'm using the "/" instead of the "\" because that's what Chief uses in the referenced_full_filename attribute. Thanks Joe, I will give that a try. Link to comment Share on other sites More sharing options...
Joe_Carrick Posted October 14, 2019 Share Posted October 14, 2019 19 minutes ago, Chopsaw said: Thanks Joe, I will give that a try. It might work as just a one line macro. I'm not sure because sometimes Ruby doesn't like too many methods on a single line. IAE you can try it: result = referenced_full_filename.rpartition("_Builders/")[2].rpartition("/")[0] Link to comment Share on other sites More sharing options...
Chopsaw Posted October 14, 2019 Share Posted October 14, 2019 18 minutes ago, Joe_Carrick said: It might work as just a one line macro. I'm not sure because sometimes Ruby doesn't like too many methods on a single line. IAE you can try it: result = referenced_full_filename.rpartition("_Builders/")[2].rpartition("/")[0] Yes that works ok with Chief. Thanks Link to comment Share on other sites More sharing options...
lavorhaynie Posted October 14, 2019 Author Share Posted October 14, 2019 I am not very familiar with Ruby... trying to learn as I have time. What precedes "result = referenced_full_filename.rpartition("_Builders/")[2].rpartition("/")[0] " and what follows it to get it to work in CA? Thanks! Link to comment Share on other sites More sharing options...
Joe_Carrick Posted October 14, 2019 Share Posted October 14, 2019 Nothing. The macro just has to be assigned to the Label of a Layout Box. Of course you need to create the macro - name it builder_plan_name 1 Link to comment Share on other sites More sharing options...
Chopsaw Posted October 14, 2019 Share Posted October 14, 2019 3 minutes ago, Joe_Carrick said: Nothing. The macro just has to be assigned to the Label of a Layout Box. Of course you need to create the macro - name it builder_plan_name Also needs to be an Evaluated Owner Object macro I believe. Link to comment Share on other sites More sharing options...
lavorhaynie Posted October 14, 2019 Author Share Posted October 14, 2019 Is there a way to use it as a, and I am not sure of the terms to use, reference label? Such that it is in a text box with an arrow pointing to the layout box. This so I do not have to turn on the Layout Box Labels layer. Link to comment Share on other sites More sharing options...
Chopsaw Posted October 14, 2019 Share Posted October 14, 2019 5 minutes ago, lavorhaynie said: Is there a way to use it as a, and I am not sure of the terms to use, reference label? Such that it is in a text box with an arrow pointing to the layout box. This so I do not have to turn on the Layout Box Labels layer. Yes Link to comment Share on other sites More sharing options...
Doug_N Posted October 15, 2019 Share Posted October 15, 2019 Does anyone know why rounding in Ruby acts like this? 3.4000....4 certainly shouldn't round to 4.08 Link to comment Share on other sites More sharing options...
Alaskan_Son Posted October 15, 2019 Share Posted October 15, 2019 3 minutes ago, Doug_N said: Does anyone know why rounding in Ruby acts like this? 3.4000....4 certainly shouldn't round to 4.08 I’ll answer your question with a question. What is it that you are telling Ruby to round in that last example? 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