David Poiron Posted November 9, 2022 Share Posted November 9, 2022 I've been trying to add the word "note:" to a field in a slab "data tag" (in a graphic legend) before the field content and have been unsuccessful What I want to do is check if field is blank, and if it is not, add the word "note: " before the field in the data tag. I've been using <Value if True>@<The Condition>:<Value if False> format (I wish a normal If statement worked in data tags). Here is my code: Note:#IfcSlab#.#Pset_ManufacturerTypeInformation#.#Manufacturer#@(#IfcSlab#.#Pset_ManufacturerTypeInformation#.#Manufacturer#<>''):'' I cannot get the "Note:" part to append to the field information only if it is not blank. I've tried using concat and a number of other methods but nothing seems to work. Is this possible? I wish data tags had proper quoted strings and operands instead floating text where it is unclear what it is doing or how it interacts with field data. I would also like to see some user defined fields in data tags in graphic legend to allow for a user defined field, like in regular data tags. I know a user can add an annotation but it isn't the same work flow. Quote Link to comment
Vectorworks, Inc Employee Nikolay Zhelyazkov Posted November 10, 2022 Vectorworks, Inc Employee Share Posted November 10, 2022 Hello @David Poiron, I managed to get this working by adding a separate if statement for the Note placement, like this: 'Note:'@(#IfcSlab#.#Pset_ManufacturerTypeInformation#.#Manufacturer#<>''):''#IfcSlab#.#Pset_ManufacturerTypeInformation#.#Manufacturer#@(#IfcSlab#.#Pset_ManufacturerTypeInformation#.#Manufacturer#<>''):'' Best Regards, Nikolay Zhelyazkov 2 Quote Link to comment
David Poiron Posted November 10, 2022 Author Share Posted November 10, 2022 Thanks Nikolay - this, as convoluted as it is, works! Much appreciated. Quote Link to comment
Pat Stanford Posted November 10, 2022 Share Posted November 10, 2022 I think Nikolay provides these great answers just to give me the ability to pontificate. 😉 David, you seem to already know about the Ternary If statement in data tags. 'Use This' @ (if the statement here is true) : 'Else Use This' So the stuff before the @ displays if the statement between the @ and the : is true, otherwise the stuff after the : displays. In this case the stuff after the colon is an empty string (two single quotes next to each other '') so there is nothing there at all. So the overall statement has two if statements, one around the Note text and one around the field value. In VW2023 (and maybe 2022??) you can also now do this with the #WS_IF function but for this case displaying IFC data you would also need to use the WS_IFC functions and I think it would be even more convoluted and harder to read. Hope this helps someone else figure out what this is actually doing. 4 Quote Link to comment
Pat Stanford Posted November 10, 2022 Share Posted November 10, 2022 One other quick note about the @ : notation. I think it depends on spacing. Don't put any spaces before or after the @ and : or it will not work properly. Quote Link to comment
markdd Posted February 3, 2023 Share Posted February 3, 2023 In a Data Tag, is there a way to use an IF statement for a range of numbers. So: 'Use This' if the value is between 0 and 10 otherwise 'use this' Thanks Mark Quote Link to comment
Pat Stanford Posted February 3, 2023 Share Posted February 3, 2023 Sure. I recommend the Worksheet IF as it is easier to read. Something like: #WS_IF(AND('Your'.'Field'>0, 'Your'.'Field'<=10),'Number in Range', 'Out of Range')# Tell me where you range of numbers are coming from and I can try to give you an exact answer. Not that this is assuming the the values are actually numbers and not text. You might need to wrap the record.field in a Value() command to get them as numbers. 2 Quote Link to comment
markdd Posted February 3, 2023 Share Posted February 3, 2023 Hi Pat What I am attempting to do is display a note on a Lighting Device when it has a Pan value of between 45 and -45°. Based on your answer above, this is what I have entered into the Tag Field definition: #WS_IF(AND('Lighting Device'.'Pan'>-45, 'Lighting Device'.'Pan'<=45),'Number in Range', 'Out of Range')# Currently I get no error in the tag which is a plus, but also no text either! Thanks Quote Link to comment
Pat Stanford Posted February 3, 2023 Share Posted February 3, 2023 The next to last line in this screen shot should be what you need. I have also included it in the code block below so you should be able to copy/paste it into your Data Tag. I put the entire screen shot in to give you some idea of how I tested/debugged this. I had a hard time getting the quotes and parentheses and periods/commas right on this to make it work. I think I need new glasses or a screen with lower resolution so the text is bigger. 😉 I also lied to you. 🤦♂️😞 There are no worksheet functions called AND or OR. You specify an Logic AND with an ampersand character &. You specify a logic OR with a vertical bar character |. HTH. #WS_IF((VALUE('Lighting Device'.'Pan')>=-45) & (VALUE('Lighting Device'.'Pan')<=45), 'In Range', 'Out of Range')# 1 Quote Link to comment
markdd Posted February 3, 2023 Share Posted February 3, 2023 Pat, this is great! Thanks. Works perfectly. Can you recommmend a resource other than your good self which would help a non-maths, non-coder person like myself to learn this kind of stuff with particular regard to Vectorworks. For instance, what is the Worksheet/Data Tag language based on? Many thanks again. Mark Quote Link to comment
Pat Stanford Posted February 3, 2023 Share Posted February 3, 2023 The worksheet functions used to be in the Vectorworks Help, but the number of functions was greatly expanded in VW2023 and now there is just a link to the function documentation on the developer site in the help. Seach "Worksheet Functions" in the help for the link. Or use the one below: https://developer.vectorworks.net/index.php?title=Worksheet_Functions I have not found (or at least can't re-find, I thought I had one once) a reference to the available Dynamic Text (# #) syntax used in Data Tags and Graphic Legends. I guess they think that the pull down menus in the Dynamic Text builder are sufficient. And as I have shown, Dynamic Text can now use the Worksheet functions by using the #WS_ # wrapper. You can not mix and match between the two styles indiscriminately. Everything INSIDE the @WS_ # block must be strictly Worksheet format. It is sometimes easier to actually work this out in a worksheet and copy/past into the Dynamic Text wrapper after it is working. Saves the Edit Tag Layout and Edit Dynamic Text button clicks as you are working through iterations. You can mix and match between the Dynamic Text and Worksheet functions in a single tag as the returned text will just be the pieces that each # # block returns contatentated together. Asking if you get stuck is probably the better part of valor, but I do like to see people wanting to learn about this stuff. HTH 2 Quote Link to comment
markdd Posted February 3, 2023 Share Posted February 3, 2023 Thanks once again. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.