Ben Wingrove Posted June 12, 2019 Share Posted June 12, 2019 Is there any way to use layer tags as a worksheet criteria? We have a main inventory on our front page that auto counts symbols of all different types with different records attached. When we duplicate a layer to try a different symbol layout or show a second position on worksheets our worksheet then adds all these duplicate fixtures. Rather than going in to the worksheet and setting each criteria to ignore the new layers (there are a lot) it would be nice to say to ignore all layers with a certain tag, lets say an "Ignore" tag. Is this possible or failing that does anyone have any cunning ways of accomplishing the same result. Thanks Ben 2 Quote Link to comment
Pat Stanford Posted June 12, 2019 Share Posted June 12, 2019 I don't believe there is a way in VW2019 and before to use tags in criteria. Would it be better to use a positive entry for layers that you DO want in the worksheet rather than a negative entry for layers you DON'T want? That way you would only need to edit the criteria if you added a layer that you wanted to keep. Quote Link to comment
Tim Harland Posted November 4, 2021 Share Posted November 4, 2021 Thsi would be very helpful - we have a project divided into phases where I would like to be able to filter a worksheet (listing all the titleblock data) by the tags I have added to the sheet layers. I preseume it still isn't possible in VW 2021 or 2022? Quote Link to comment
ashot Posted June 25, 2024 Share Posted June 25, 2024 (edited) @Pat Stanford on somewhat related topic: do you know how to search and filter SL in Navigation palette using Layer Tags for Sheet Layers What is the use of Tags if I can not use them in search field on Navigation palette? Edited June 25, 2024 by ashot Quote Link to comment
Vectorworks, Inc Employee Hugues Posted June 25, 2024 Vectorworks, Inc Employee Share Posted June 25, 2024 40 minutes ago, ashot said: @Pat Stanford on somewhat related topic: do you know how to search and filter SL in Navigation palette using Layer Tags for Sheet Layers What is the use of Tags if I can not use them in search field on Navigation palette? While you cannot search for tags directly in the search field on the Navigation palette, you can setup layer filters based on tags. Quote Link to comment
ashot Posted June 25, 2024 Share Posted June 25, 2024 (edited) Thank you Hugues, I know that setting up new filter tied to tag is a way to sort the list. However for every Tag I need to create Matching Filter, I can not use several Tags in the same Filter. I was hoping to avoid a duplicate of my work, if I could just use Tags to search. Example: Many (500) Sheet Layers with Details have Tags: Drilling, Nothing, Rebars, etc. I can assign several Tags to each Layer. However instead of searching by one Tag name, I have to create matching Filter for each and every Tag to do the same. It wold be useful to have Tags behave like a keyword in search, and with comma separation I would get more results. The Filters on the other Hand are very useful to include all other parameters for Layers. But they are limited by choosing only one Tag at a time. see screenshot of sample layres Edited June 25, 2024 by ashot Quote Link to comment
Tom W. Posted June 26, 2024 Share Posted June 26, 2024 I asked some time ago to be able to apply more than one filter at once. I think this would help in your case. Quote Link to comment
ashot Posted June 27, 2024 Share Posted June 27, 2024 @Pat Stanford 5 years later after the original post is there any news on this: Is there any way to use layer tags as a worksheet criteria? Quote Link to comment
Pat Stanford Posted June 27, 2024 Share Posted June 27, 2024 Here is a simple version that will give you a database of all the layers associated with a single tag. Save the script with a name of 'Layer_DB_By_Tag' Create a database row with dummy criteria and then right click on the header and choose Edit Database Formula. Replace the formula with {=DatabaseByScript('Layer_DB_By_Tag', 'Your Tag Name Here')} =DatabaseByScript('Layer_DB_By_Tag', 'Your Tag Name Here') Using your tag name instead. You can use the above formula in as many different database rows with different tag names as will fit in your worksheet. The script is currently set to handle layers with up to 20 tags. It does not care if there are more than 20 different tags as long as no layer has more than that. If you need more, edit the script and change the three locations where it says 20 and increase to what you need. Procedure Layer_DB_By_Tag; {©2024 Pat Stanford - pat@coviana.com} {licensed under the Boost Software License 1.0} {https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt} {TL/DR Use as you want, attribution for source, No warranty} {takes a single parameter which is the name of Tag associated to a Layer} {returns a database of all the layers that have that tag.} {use with a worksheet DatabaseByScript database formula.} {=DatabaseByScript('Layer_DB_By_Tag', 'Your Tag Name Here')} VAR H1: Handle; S1: String; B1: Boolean; A1: Array[1..20] of string; N1: Integer; BEGIN S1:=WSScript_GetPrmStr(0); H1:=FLayer; While H1<> Nil DO Begin For N1:=1 to 20 Do A1[N1]:=''; B1:=GetObjectTags(H1,A1); For N1:=1 to 20 DO BEGIN If A1[N1]=S1 then WSScript_AddHandle(H1); End; H1:=NextLayer(H1); End; End; Run(Layer_DB_By_Tag); Quote Link to comment
ashot Posted June 27, 2024 Share Posted June 27, 2024 @Pat Stanford Thank you for help and good script. Later on I will attach a sample file to describe my dilemma. but for now I was looking something trivial (if exists at all) say in any search database in one column I can type =Layer() and get the name of all found layers so, my question: is there any similar command like: =LayerTags() to get the tags listed in the next column Quote Link to comment
Pat Stanford Posted June 27, 2024 Share Posted June 27, 2024 No there is no built in function to return Layer Tags. It is possible with a different worksheet script. Are your layers going to have multiple tags? If so, do you want them all returned in a single cell? Or to be able to separate them out to multiple columns? If a single column what would you like to use as a separator character between the tags? Quote Link to comment
ashot Posted June 27, 2024 Share Posted June 27, 2024 I know it is too much to ask: Yes, Layers have dozen tags first column - single cell, separated by comma + next columns - each tag separated in multiple columns Note: I can achieve this with multiple Data Tag on every sheet layer with assigned Keyword Records and bring to database with OR statement and then I can Select Item from database - that is the exact behavior I need but creating records and duplicating the same info in order to match Layer Tags, makes no sense to me I really hope to achieve the same just with Layer Tags - that is my goal Quote Link to comment
Pat Stanford Posted June 28, 2024 Share Posted June 28, 2024 Ok. Try these. I am not at all certain how well these are going to work on your 500 layer file. You are going to be running 6000+ scripts every time you recalculate the worksheet. It may be very slow. Two scripts. All_Layer_Tags and Specific_Layer_Tag. All_Layer Tags returns a single comma delimited list of all the tags associated with a layer Specific_Layer_Tag returns the single tag in the tag list position specified by a passed integer. Run them in a worksheet with the following formulas. =RunScript('All_Layer_Tags') =RunScript('Specific_Layer_Tag',1) Where you change the 1 to whatever positon you want to see the tag from. And here are the scripts. Rename as necessary and change the MaxTags constant to however large of number you need for the maximum number of tags. Procedure All_Layer_Tags; {©2024 Pat Stanford - pat@coviana.com} {licensed under the Boost Software License 1.0} {https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt} {TL/DR Use as you want, attribution for source, No warranty} CONST MaxTags=20; VAR H1 :Handle; S1 :String; A1 :Array[1..MaxTags] of string; B1,B2 :Boolean; N1 :Integer; BEGIN H1:=WSScript_GetObject; B1:=GetObjectTags(H1, A1); S1:=''; B2:=False; For N1 := 1 to MaxTags DO BEGIN If A1[N1]<>'' then BEGIN If B2 Then S1:=Concat(S1,', ',A1[N1]) Else S1:=A1[N1]; B2:=True; End; End; WSScript_SetResStr(S1); End; Run(All_Layer_Tags); Procedure Specific_Layer_Tag; {©2024 Pat Stanford - pat@coviana.com} {licensed under the Boost Software License 1.0} {https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt} {TL/DR Use as you want, attribution for source, No warranty} CONST MaxTags=20; VAR H1 :Handle; A1 :Array[1..MaxTags] of string; B1 :Boolean; N1 :Integer; BEGIN H1:=WSScript_GetObject; N1:=WSScript_GetPrmInt(0); B1:=GetObjectTags(H1, A1); WSScript_SetResStr(A1[N1]); End; Run(Specific_Layer_Tag); Quote Link to comment
ashot Posted June 28, 2024 Share Posted June 28, 2024 Thank you so much. Attached is Test5 .vwx file, please check the Worksheet "WS to runscript" I can't figure out how to get it work. Test 5.vwx Quote Link to comment
Pat Stanford Posted June 28, 2024 Share Posted June 28, 2024 The last scripts I posted are not for the database, but rather for the database header row columns. I have add three more scripts for use with DatabaseByScript. DB_Of_Design_Layers, DB_Of_Sheet_Layers, DB_Of_All_Layers. Pick the one you want and make a database row using that script name and the DatabaseByScript command. This will give you a database that has a single subrow for every Layer. =DatabaseByScript('DB_Of_Design_Layers') The other scripts are run using a RunScript formula in the database header row. The All_Layer_Tags script returns all of the tags in a single cell. =RunScript('All_Layer_Tags') The Specific_Layer_Tag script returns the 1st, 2nd, ... (as specified by the final integer) tag associated with a layer. These are not necessarily in any given order. =RunScript('Specific_Layer_Tags',1) If the worksheet gets too slow using multiple versions on the Specific_Layer_Tag script, another possibility would be to use an IF function to extract the data from the All_Layer_Tags column. Something like: =IF(FIND('epoxy', B5)<>-1, 'epoxy', '') Where B5 is the database header row for the column listing all of the Tags attached to the Layer. This will show epoxy in the column for only those layers that have a Tag of epoxy. But you will have to be careful, as if you have a tag of "epoxy" and a tag of "epoxy anchor" (or anything else that has "epoxy" as a sub-string) it will be returned also. Using this IF function would allow you to have a single column that would show "epoxy" for only those layers that have the "epoxy" tag. And by changing the strings you can set up single columns for any tag you want. Here is my edited version of your test file. Test 5-pat.vwx Quote Link to comment
ashot Posted June 28, 2024 Share Posted June 28, 2024 (edited) Very helpful, million thanks. I would like to repay you, please let me know how. Edited June 28, 2024 by ashot Quote Link to comment
Pat Stanford Posted June 28, 2024 Share Posted June 28, 2024 And actually you could edit the Find formula to replace the explicit "epoxy" settings with a cell value so you only have to type the Tag name once. So if you put the IF formula in the database header row cell B5, you could type the Tag name into cell B4 and edit the IF to be something like: =IF(FIND(B4, B5)<>-1, B4, '') Quote Link to comment
ashot Posted June 28, 2024 Share Posted June 28, 2024 I wonder why is it minus -1 (in <>-1) ? Quote Link to comment
Pat Stanford Posted June 28, 2024 Share Posted June 28, 2024 -1 is what the FIND function returns when the substring is not found. The function says to FIND the substring in the text. If is it found (any returned result other than -1) then return the substring (or you could enter any test you wanted if you only wanted an X in that column for instance), otherwise if the substring is not found, return an empty string (two single quotes). 1 Quote Link to comment
ashot Posted June 28, 2024 Share Posted June 28, 2024 2 minutes ago, Pat Stanford said: -1 is what the FIND function returns when the substring is not found. good to know Quote Link to comment
RSawall Posted October 5, 2024 Share Posted October 5, 2024 Hi thanks for sharing the scripts. I'm pretty new in scripting in VWx and wanted to manipulate the script. I want to read the tags from textures. My list is filtered by objects (extrusions, ...) So I added the lines to get the texture of the object and from these I want to read the tags. Unfortunately it doesn't work. I get confused one time we use vs and one time python in the forum. Procedure Specific_Object_Tag; CONST MaxTags=20; VAR H1 :Handle; tr :INTEGER; A1 :Array[1..MaxTags] of string; B1 :Boolean; N1 :Integer; text_name:string; BEGIN H1:=WSScript_GetObject; N1:=WSScript_GetPrmInt(0); tr:=GetTextureRefN(H1, 0, 0, 0); text_name:=Index2Name(tr); GetObjectTags(text_name, A1); WSScript_SetResStr(A1[N1]); End; Run(Specific_Object_Tag); thanks for any help! Quote Link to comment
Pat Stanford Posted October 5, 2024 Share Posted October 5, 2024 GetObjectTags requires. a Handle (think library book id [Dewey Decimal System]) not a name (think book title). And a couple of other small errors. Procedure Specific_Object_Tag; CONST MaxTags=20; VAR H1,H2 :Handle; tr :INTEGER; A1 :Array[1..MaxTags] of string; B1 :Boolean; N1 :Integer; text_name:string; BEGIN H1:=WSScript_GetObject; N1:=WSScript_GetPrmInt(0); tr:=GetTextureRefN(H1, 0, 0, FALSE); text_name:=Index2Name(tr); H2:=GetObject(text_name); B1:=GetObjectTags(H2, A1); WSScript_SetResStr(A1[N1]); End; Run(Specific_Object_Tag); I think this version will do what you want. 1 Quote Link to comment
RSawall Posted October 6, 2024 Share Posted October 6, 2024 Thanks Pat thats working now. I found the little mistakes as well but I didn't know how to get the string to be the second handle. You will probably hear soon from me again 🙂 1 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.