Bruce Kieffer Posted February 25 Share Posted February 25 (edited) Is there a formula I can use to make the title of a worksheet appear in a data tag. I know about #N# where I can add a name in the OIP, but I want Vectorworks to pick up the worksheet title given in the RM. This one: Edited February 25 by Bruce Kieffer Quote Link to comment
Pat Stanford Posted February 25 Share Posted February 25 Copy the single line below and paste it into a blank Vectorscript named WSNameToTag WSScript_SetResStr(GetName(GetWSFromImage(WSScript_GetObject))); Once you have the script created, edit your tag to include the following line: #WS_RUNSCRIPT('WSNameToTag')# All of the punctuation is critical. Just copy and paste and it should work. The script will have to be included in every file that you want to use the Data Tag in. HTH 1 Quote Link to comment
Bruce Kieffer Posted February 25 Author Share Posted February 25 Thanks @Pat Stanford I was hoping for a simpler solution in the provided data tag formula options. I'll give your method a try, but I may just use the "name" part in the OIP. Quote Link to comment
Tom W. Posted February 25 Share Posted February 25 16 minutes ago, Pat Stanford said: Copy the single line below and paste it into a blank Vectorscript named WSNameToTag WSScript_SetResStr(GetName(GetWSFromImage(WSScript_GetObject))); Once you have the script created, edit your tag to include the following line: #WS_RUNSCRIPT('WSNameToTag')# All of the punctuation is critical. Just copy and paste and it should work. The script will have to be included in every file that you want to use the Data Tag in. HTH @Pat Stanford that is really cool but I am confused: is it still the case as per the thread below that you can't return the name of a worksheet in a spreadsheet cell, even though you can do it with a Data Tag + a database...? Quote Link to comment
Pat Stanford Posted February 25 Share Posted February 25 Yes. The worksheet has no way of knowing what its name is. In this case, since you can't Data Tag a worksheet, but only a Worksheet Image, I use that to our advantage. I can get a handle to the worksheet from the worksheet image and then get the name of that worksheet. The Data Tag just happens to be able to use the WSScript_GetObject and WSScript_SetRetStr functions to do the I/O and find out the tagged object. 1 Quote Link to comment
Tom W. Posted February 25 Share Posted February 25 OK thanks + it works in a database for the same reason it works with a data tag: because the function knows what the object is? Quote Link to comment
Pat Stanford Posted February 25 Share Posted February 25 A Database SubRow (unless it is SUMmarized) and a Data Tag both return a reference to a single specific object. In this case of the Data Tag, that reference is to a Worksheet Image. Once you have the handle to the Image you can get the Handle and then the name of the parent Worksheet object. In a Database subrow, since the objects returned (except for the special case below) are not Worksheet Images, there is no way for a script to know what environment it is running from. So a worksheet script can't say "I'm running inside of Worksheet XYZ" (actually it could, but it does not do that now). So since you can't get the handle to the worksheet, you can't get the name of the worksheet either. The special case would be a worksheet which had a database row with a criteria of Object Type is Worksheet Image. In that case you could probably get the Worksheet name for each image. And maybe you could do some trickery in the criteria to only return a single Worksheet Image that happened to be an image of the worksheet producing the image and be able to get the worksheet name. But as I was once told: Quote "What you are trying to do sounds fancy, and as such it sounds like it won't work.” Vlado Stanev, VW SDK List Dec. 4, 2015 If you want to play be my guest. Create a worksheet with a database row returning Worksheet Images and see what it would take to get the criteria set to only show a single image. You could then use a =RunScript('WSNameToTag') script from above to return the actual worksheet name from the resource manager. I think the effort to define the criteria would be much harder than just typing in the name. But maybe if you only had one worksheet on each layer and could use just a layer criteria it might work, Good Luck. Quote Link to comment
Tom W. Posted February 26 Share Posted February 26 8 hours ago, Pat Stanford said: If you want to play be my guest. Create a worksheet with a database row returning Worksheet Images and see what it would take to get the criteria set to only show a single image. You could then use a =RunScript('WSNameToTag') script from above to return the actual worksheet name from the resource manager. Thanks yes I did this already + that's why I asked the question: you CAN return the name of a Worksheet resource using your formula in a database header cell but you CAN'T do the same in a spreadsheet cell, correct? It's an academic question. I always assumed (probably naively) that anything you did in a database you could also do in a spreadsheet cell, you just needed to include the relevant criteria, but I was wrong to think this as there is no way to include criteria in the RUNSCRIPT function right? The question in the other thread was 'Is there a function I can put in a worksheet to display the worksheet name?' + the answer was no. But technically the answer was, 'Yes you can in a database but not in a spreadsheet cell' right? I'm not saying it's a practical approach, it is more that I am confused that you can do one thing in a database but can't do the same in a spreadsheet. But like I say this was probably naivety on my part + there are hundreds of other examples of the same. Quote Link to comment
Pat Stanford Posted February 26 Share Posted February 26 There are a number of WS Functions that you can't pass criteria to in Spreadsheet cells. RunScript and standard Record.Field are the two most obvious and ones that could be made more useful by having a way to pass criteria. And I think the ObjectData - 'Universal Value' kind of supports criteria for Record.Field but as we said in the other thread, it is currently hindered by not handling compound criteria. Maybe Someday. 1 Quote Link to comment
Bruce Kieffer Posted February 29 Author Share Posted February 29 (edited) OK, so like I considered earlier, I set up a data tag to grab the text from the name field in the OIP. It's a bit of work, but easy enough. I copy the title of the worksheet, type into the OIP Name field "WS: " and then paste the worksheet title text. Then I associate the data tag to the worksheet. Edited February 29 by Bruce Kieffer 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.