GlennShaw Posted January 19 Share Posted January 19 I am not looking for anyone to write a macro for me, I just need a nudge in the right direction. I am new to CA and very new to Ruby and want to work this out for myself. It's how I learn best. So please bear with me if I use the wrong terminology in asking my question. I have tried searching the forums and either I am searching with the wrong words or its just not there. I am trying to write a macro that will evaluate if a layer is on of off. If it is on, it will add text to a Text Box and if it is off it doesn't do anything. When I select the object and use owner.names, it gives me a list of options but layer display is not one of them. And since it is a custom-made object, it lacks a lot of the NVP options that CA objects have imbedded in them. My question is: what, if anything, do I type in/add to my macro to get it to see/evaluate the layer display status of being "on" or "off" since that is not a default option? Can that even be done or am I wasting my time? Thank you Darrell Link to comment Share on other sites More sharing options...
Renerabbitt Posted January 19 Share Posted January 19 31 minutes ago, GlennShaw said: I am not looking for anyone to write a macro for me, I just need a nudge in the right direction. I am new to CA and very new to Ruby and want to work this out for myself. It's how I learn best. So please bear with me if I use the wrong terminology in asking my question. I have tried searching the forums and either I am searching with the wrong words or its just not there. I am trying to write a macro that will evaluate if a layer is on of off. If it is on, it will add text to a Text Box and if it is off it doesn't do anything. When I select the object and use owner.names, it gives me a list of options but layer display is not one of them. And since it is a custom-made object, it lacks a lot of the NVP options that CA objects have imbedded in them. My question is: what, if anything, do I type in/add to my macro to get it to see/evaluate the layer display status of being "on" or "off" since that is not a default option? Can that even be done or am I wasting my time? Thank you Darrell would question what your desired end result is, why would this be useful? Maybe there is a different method we could point you to Link to comment Share on other sites More sharing options...
GlennShaw Posted January 21 Author Share Posted January 21 On 1/19/2024 at 4:00 PM, Renerabbitt said: would question what your desired end result is, why would this be useful? Maybe there is a different method we could point you to The layer is an option that can be selected by the buyer. The object needs to be turned on and then listed in a list of connections. Not in a table. But the entry in the list is constantly being missed. I know that text can be added to a list and turned on and off by an if/else command. But in this case, the trigger for that text to appear is if the layer is on or off. In AutoCAD its very simple Lisp routine, but in CA/Ruby, at least to me, it's not so simple or obvious. I would find it very hard to believe that with all the layer settings that can be evaluated with Ruby, the status of a layer being on or off is not part of that evaluation. To me that should be basic 101: If layer is "on" do "X" else do "Y" Link to comment Share on other sites More sharing options...
GeneDavis Posted January 21 Share Posted January 21 Who is the buyer? Link to comment Share on other sites More sharing options...
Chopsaw Posted January 21 Share Posted January 21 On 1/19/2024 at 4:28 PM, GlennShaw said: My question is: what, if anything, do I type in/add to my macro to get it to see/evaluate the layer display status of being "on" or "off" since that is not a default option? Can that even be done or am I wasting my time? I think I get what you are after and the AutoCAD logic you are using, however Chief does a lot of things differently and you may need to take a different approach for now. You will likely need a much simpler macro that simply reports when the object layer is on and does not report when the object layer is off, so each buyer option has a reporting macro embedded and the ones that are on and selected by the buyer are reporting and the others are not. Again there are a lot of things to consider with respect to what objects you are using and how you want the information collected and reported so you may have to at least post a dumbed down but specific example that represents what you are doing if we are not understanding what you are trying to accomplish. Link to comment Share on other sites More sharing options...
GlennShaw Posted January 21 Author Share Posted January 21 2 hours ago, GeneDavis said: Who is the buyer? Buyer is irrelevant. It's an option on all of our home plans that a buyer can choose. Link to comment Share on other sites More sharing options...
GlennShaw Posted January 21 Author Share Posted January 21 1 hour ago, Chopsaw said: I think I get what you are after and the AutoCAD logic you are using, however Chief does a lot of things differently and you may need to take a different approach for now. You will likely need a much simpler macro that simply reports when the object layer is on and does not report when the object layer is off, so each buyer option has a reporting macro embedded and the ones that are on and selected by the buyer are reporting and the others are not. Again there are a lot of things to consider with respect to what objects you are using and how you want the information collected and reported so you may have to at least post a dumbed down but specific example that represents what you are doing if we are not understanding what you are trying to accomplish. In this case it is a gas fireplace that is not standard in the home but an option. We have a text box that lists out the gas connections on the plumbing plan. And as I explained, when this option layer is turned on in the drawing, we have to add it to the list, but it gets missed often. I can see how to add it to the list through a macro and if it was based on any other object property it would most likely be easier to figure out, but in this case, the presence of the text would be based on if the layer is on or off. Surely CA/Ruby has the ability to evaluate the on or off status of a layer? Link to comment Share on other sites More sharing options...
MarkMc Posted January 22 Share Posted January 22 I'd have a talk with @Joe_Carrick who's written some macros based on layer sets to alter labels. There are a few other people around that do custom macros. Would need something that set "include_in_schedule" to false for the object based on the layer set (I don't know how to do off hand, I tried but limited ability here.) Then use a custom schedule to make the list, only including labels and no borders for your list. Instead of turning off a layer the client needs to change the layer set to one with that layer off. (better practice IMO) A second simpler method would be to add the text for option as a separate text box at the end of your list and set it on the same layer as the object. Turn off the object the text goes away. Not elegant but... Link to comment Share on other sites More sharing options...
Chopsaw Posted January 22 Share Posted January 22 1 hour ago, GlennShaw said: I can see how to add it to the list through a macro and if it was based on any other object property it would most likely be easier to figure out, but in this case, the presence of the text would be based on if the layer is on or off. Surely CA/Ruby has the ability to evaluate the on or off status of a layer? Ok so the Gas Fire place is a Symbol and the macro that reports is in the label , or are us using Symbol Object Information ? If you use the label I am pretty sure that it will not report if it is turned off so for better or worse, there will be a way to do it even if it is not the AutoCAD way. Are you reporting to a Chief Schedule or just a text box ? Or a referenced macro in a text box? Symbols have an option to report to a schedule that is just a check box if you are using Object Information Fields. Link to comment Share on other sites More sharing options...
MarkMc Posted January 22 Share Posted January 22 Had a quick play with one of Joe's macros. It takes some time to update the macro and I think the macro folks have a trick for that?? Screen shots of a schedule (I left border on) that changes with changed layer sets. Link to comment Share on other sites More sharing options...
SHCanada2 Posted January 22 Share Posted January 22 I think I would go another direction, similar to what rene does for details. He essentially sets all the variables graphically in a CAD detail. You could then use that in text boxes or report on them as you see fit. It has the advantage of keeping everything in one place, and avoiding yet more layers Link to comment Share on other sites More sharing options...
Renerabbitt Posted January 22 Share Posted January 22 17 hours ago, MarkMc said: Had a quick play with one of Joe's macros. It takes some time to update the macro and I think the macro folks have a trick for that?? Screen shots of a schedule (I left border on) that changes with changed layer sets. Nice work Mark, I mean it. only problem I see with this is that whatever the element it is, it would need to be something that reports to schedule. I think instead maybe they could do this on the layout said using linking features. Need to think about it for a sec Link to comment Share on other sites More sharing options...
MarkMc Posted January 22 Share Posted January 22 14 minutes ago, Renerabbitt said: it would need to be something that reports to schedule. I don't know of a symbol type that can't report to a schedule. Here is a solid converted to a geometric shape with schedule. Link to comment Share on other sites More sharing options...
Joe_Carrick Posted January 22 Share Posted January 22 Assuming that you simply want a TEXT BOX to either display something or not: Put that TEXT on a specific Layer In each LAYER SET that you want it not to be displayed, turn the LAYER DISPLAY to OFF. That can even be done for LABELS. There really isn't any need for a macro. Link to comment Share on other sites More sharing options...
Renerabbitt Posted January 22 Share Posted January 22 30 minutes ago, MarkMc said: I don't know of a symbol type that can't report to a schedule. Here is a solid converted to a geometric shape with schedule. The OP was talking about a text box and kindve implying a plumbing line diagram or something of the sort such as a CAD block Link to comment Share on other sites More sharing options...
Renerabbitt Posted January 22 Share Posted January 22 21 minutes ago, Joe_Carrick said: Assuming that you simply want a TEXT BOX to either display something or not: Put that TEXT on a specific Layer In each LAYER SET that you want it not to be displayed, turn the LAYER DISPLAY to OFF. That can even be done for LABELS. There really isn't any need for a macro. He wants an IFTTT setup where if a text box is toggled to display, an ordered list will populate that this particular text box is set to display Link to comment Share on other sites More sharing options...
Joe_Carrick Posted January 22 Share Posted January 22 CA's Ruby is not the same as ACAD's List in that it doesn't provide for any modifications to the Model or Layer Sets. However, if Chief was to make an attribute (Name:Value Pair) for all objects %layer_displayed% (Y/N) then a Ruby Macro could be used as desired. I'm not aware that attribute has ever been requested. OTOH, it's my understanding that X16 will have many more attributes available. Whether that is one of them is anyone's guess. Link to comment Share on other sites More sharing options...
MarkMc Posted January 22 Share Posted January 22 3 hours ago, Renerabbitt said: The OP was talking about a text box and kindve implying a plumbing line diagram or something of the sort such as a CAD block I get that. Turning off a layer of an object that is in a block does not turn it off. I just was looking at the options- my favorite is pretty much what Joe suggested- adding a separate text box on the same layer as the object. If the choice is "I can be right" (program should do this so complain) or "I can get what I want" (work around) I'll get what I want...somehow. Link to comment Share on other sites More sharing options...
GlennShaw Posted January 23 Author Share Posted January 23 21 hours ago, Renerabbitt said: He wants an IFTTT setup where if a text box is toggled to display, an ordered list will populate that this particular text box is set to display No box being toggle by anyone. It is a layer I turn off or on. When I turn the layer on, I have to add the text to a list in a Text Box. I know I can write a macro that will add text to an existing text box. I am wanting to know if there is a macro attribute/command/trigger that will evaluate if a layer is on or off. And if it is on, it adds the text to the text box. From what I understand and have learned about Ruby, the macro should be this: if #evaluates that the layer is on puts "(1) FIREPLACE" else "" Link to comment Share on other sites More sharing options...
Joe_Carrick Posted January 23 Share Posted January 23 2 hours ago, GlennShaw said: if #evaluates that the layer is on puts "(1) FIREPLACE" else "" Not available at this time. See my previous post. 1 Link to comment Share on other sites More sharing options...
Renerabbitt Posted January 23 Share Posted January 23 5 hours ago, GlennShaw said: No box being toggle by anyone. It is a layer I turn off or on. When I turn the layer on, I have to add the text to a list in a Text Box. I know I can write a macro that will add text to an existing text box. I am wanting to know if there is a macro attribute/command/trigger that will evaluate if a layer is on or off. And if it is on, it adds the text to the text box. From what I understand and have learned about Ruby, the macro should be this: if #evaluates that the layer is on puts "(1) FIREPLACE" else "" Just do this with a symbol and a custom schedule and redraw your symbol's cad block to represent the graphic you need. Not a matter of displaying or not displaying a layer, but rather placing a symbol. Tie it to a Custom Placed Library Object in your toolbar and that'd be lighting fast. Link to comment Share on other sites More sharing options...
SHCanada2 Posted January 24 Share Posted January 24 12 hours ago, GlennShaw said: No box being toggle by anyone. It is a layer I turn off or on. I assume though that you also want to make sure the symbol for the gas is on the plan. i.e. if you turn the layer on, you do not just want (1) Fireplace to show up in the text box, but you also want to make sure the symbol is at least on the plan. Otherwise people will turn on the layer and forget to position the gas outlet. How is that ensured in Autocadd? Or is this only a problem on existing plans where all of the gas outlets are already on the plan and you are just toggling the layer to toggle the option for the customer? Link to comment Share on other sites More sharing options...
MarkMc Posted January 24 Share Posted January 24 22 hours ago, GlennShaw said: layer I turn off or on. By now I think you get that is not available. My last shot at this. Screen shots and plan attached for clarity. The only downside is that after changing the layer set You need to click on the schedule to get the macro to refresh. Someone may know another way to force it to refresh. Gas schedule.zip Link to comment Share on other sites More sharing options...
Renerabbitt Posted January 24 Share Posted January 24 3 hours ago, MarkMc said: By now I think you get that is not available. My last shot at this. Screen shots and plan attached for clarity. The only downside is that after changing the layer set You need to click on the schedule to get the macro to refresh. Someone may know another way to force it to refresh. Gas schedule.zip 880.34 kB · 0 downloads I really think a replace from library approach would work better in this case. One symbol reports included and has a blank cad block and the layer is always turned on and the symbol has no geometry just a big bounding box, then a custom placed library object that you hover over and click and then its placed correctly and reports everything under the sun from the OIP 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