ComputerMaster86 Posted March 11, 2016 Share Posted March 11, 2016 I am working with polyline boxes in Chief Architect X8 and their labels. I have noticed how you can add labels like %visible_length%, which gives the length of the line of the whole box. My question has to do with using %visible_length% in a math formula. Is their a way to type a math formula in the box under "Specify Label" in the "Polyline Specification" dialogue box that displays the answer of the math formula as the label for the polyline. My idea is to right a math formula that takes %visible_length% and subtracts 72" and then divides that value by 2? I guess my general question is can you even add math formulas to these labels like you type a math formula in MS Excel and the answer of the formula is displayed in the cell? Link to comment Share on other sites More sharing options...
Joe_Carrick Posted March 11, 2016 Share Posted March 11, 2016 You can use a custom macro to do that. Create a user text macro named MyCalcFormula as follows: result = (owner.visible_length-72)/2 Then in the Polyline Label insert %MyCalcFormula% Link to comment Share on other sites More sharing options...
ComputerMaster86 Posted March 11, 2016 Author Share Posted March 11, 2016 OK, Thank You! I will try that. Link to comment Share on other sites More sharing options...
ComputerMaster86 Posted March 12, 2016 Author Share Posted March 12, 2016 Man! Ruby is great! I think I may have made my work a little easier, when doing 2D steel layouts for my boss. I normally draw these up in a program called TurboCAD, which is along lines of AutoCAD. I recently started experimenting with CA. You got me hooked on learning ruby. Now if I can write some Ruby code to generate a list of all the polyline labels. That would literally be like "mind blown!" Link to comment Share on other sites More sharing options...
Greg_NY61 Posted March 12, 2016 Share Posted March 12, 2016 Joe, how do you add this to that script so you can round the last number to 2 digits. I know this have to be added to the script but how do you add that? "round (2)" Thanks! Link to comment Share on other sites More sharing options...
Joe_Carrick Posted March 12, 2016 Share Posted March 12, 2016 Joe, how do you add this to that script so you can round the last number to 2 digits. I know this have to be added to the script but how do you add that? "round (2)" Thanks! result = (owner.visible_length-72)/2 result = result.round(2) or result = ((owner.visible_length-72)/2).round(2) To use any "Ruby Method" just use a "." before it. That tells Ruby that the following is a modifier. Link to comment Share on other sites More sharing options...
Greg_NY61 Posted March 12, 2016 Share Posted March 12, 2016 Thank you Joe!!! Link to comment Share on other sites More sharing options...
Greg_NY61 Posted March 12, 2016 Share Posted March 12, 2016 Joe, one more question please. If I use pLines and I connect lets say 3 or 4 together, instead of getting total SQFT area, how do I code a macro to get the total length of all pLines? Link to comment Share on other sites More sharing options...
Joe_Carrick Posted March 12, 2016 Share Posted March 12, 2016 Joe, one more question please. If I use pLines and I connect lets say 3 or 4 together, instead of getting total SQFT area, how do I code a macro to get the total length of all pLines? That get's much more complicated. You need a way to accumulate and store the values for each Polyline. This can be done using Ruby Global Variables. I have a macro package called "Hash Areas" that I sell for $25 that does this for the areas. I consists of several macros, one to collect the data and others to perform calculations and display results. I spent a lot of time figuring how to do it and create the macros. The functionality is well worth the price and by studying the macros you can learn a lot This same system can easily be modified to use for "Total Length" instead of "Areas" Link to comment Share on other sites More sharing options...
ComputerMaster86 Posted March 15, 2016 Author Share Posted March 15, 2016 I am just beginning to learn ruby. I have in the past messed around with JavaScript code but, never was no expert. Ruby seems to be quite similar although with different syntax. 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