Gregovitch Posted March 29, 2022 Share Posted March 29, 2022 Evening, I am setting up some worksheet and was wondering if there is a way to : (yellow highlights) filter my class name showing in my worksheet to only show the last part of the class name (purple highlights) filter my symbols name in my worksheet to only show the last part of the name Thanks, Greg Quote Link to comment
michaelk Posted March 30, 2022 Share Posted March 30, 2022 This is the answer to what you want to do. In the few years between the beginning of Worksheet Scripts and the beginning of the Data Manager, this would have been the solution. And it's fun to do. 🙂 But also, I feel like I should tell you there is a MUCH better way to do this. In the attached file column C has what you want. It uses a little script of just a few lines to strip everything up to and including the last dash out of the name of -- in this case the class name and symbol name. But the same idea could easily be used for any text with a dash. As long as the file contains the scripts in the Last Dash script palette in the resource manager this will do what you are asking. But it would be much easier to use the data manager to attach a database record to all the objects you want to have data reported on. Setting that up may take more time than you may want to spend right now, but it's way more flexible and powerful. Last Dash.vwx 2 Quote Link to comment
Gregovitch Posted March 30, 2022 Author Share Posted March 30, 2022 Thanks Michael the script works great! I am not sure to understand why attaching a database record is better. Does it not make a lot of the information redundant and adds another layer of coordination? I guess there must be another world of how to use the record format I have not understood yet! Time to get a refresher tutorial! Thanks for the great help! Quote Link to comment
michaelk Posted March 30, 2022 Share Posted March 30, 2022 @The Hamma is the master at this. But I'll get the idea started. Imagine a remodel project. Every door can have a pulldown in the Data Tab of the OIP that has the choice NEW or EXISTING. Halfway through the project you realize that some doors are going to be existing and relocated. You can add a new category. That data can easily be reported in a worksheet independently of what class it's in or what kind of door it is. AND you can use data visualization to color code the doors in the design layer while you're working or in a SLVP for the contractor. That data can be added to the data tag id on the plan or elevation. Imagine if every wall had a pulldown with choices for NEW, EXISTING, and DEMO. Data Vis can change the color and fill of the wall depending on that data. No need to change wall styles or have separate classes for wall functions. Change the pulldown in the OIP for a wall and the graphics and the data take care of themselves. Any data you want to keep track of: Like floor treatment or paint color (it could be ANYTHING) can be attached to ANY object, scheduled in a worksheet and graphically displayed in a data tag. But it's still really fun to write little scripts to strip out all the dashes 🙂 1 Quote Link to comment
Gregovitch Posted March 30, 2022 Author Share Posted March 30, 2022 (edited) I get it! So in the sake of my example, I could add further details to my parkades: -what use -if it is accessible - if it is visitor Makes more sense thanks! Will try it out! Edited March 30, 2022 by Gregovitch Quote Link to comment
The Hamma Posted March 30, 2022 Share Posted March 30, 2022 56 minutes ago, michaelk said: @The Hamma is the master at this. Not the master but getting better all the time. Here are my scripts and workflow Quote Link to comment
Gregovitch Posted March 30, 2022 Author Share Posted March 30, 2022 (edited) Thanks, I tried to create a script to get the last name after a - of a layer, but it doesn't seem to work. What I am doing wrong? Edited March 30, 2022 by Gregovitch Quote Link to comment
michaelk Posted March 30, 2022 Share Posted March 30, 2022 For reasons unknown … GetClass(h) returns a string value that is the name of the class… BUT GetLayer(h) returns a handle variable that is a temporary designation of an object in Vectorworks. So try this: s1 := GetName(GetLayer(h)); NOT TESTED. Save first. Be prepared to force quit. But I think it will work. Quote Link to comment
michaelk Posted March 30, 2022 Share Posted March 30, 2022 PS. Welcome to the Vector Script party! 2 Quote Link to comment
michaelk Posted March 30, 2022 Share Posted March 30, 2022 3 hours ago, Gregovitch said: I get it! So in the sake of my example, I could add further details to my parkades: -what use -if it is accessible - if it is visitor Makes more sense thanks! Will try it out! If you let yourself think about it too much your brain will explode. … Universal data like what phase of the project this object belongs to down to specific data like sub panel, circuit, and phase of electrical equipment. Data that used to have to be hard coded into parametric objects records or added manually to symbols or attached manually as record formats can now be part of the atmosphere of the drawing. For me it's slowly changing the way I organize drawings. For David it's not so slow at all 🙂. 1 Quote Link to comment
Pat Stanford Posted March 30, 2022 Share Posted March 30, 2022 Or, if you know that all of your class names are nested 4 deep a simple Substring formula? =SUBSTRING(A3, '-', 4) Replace A3 with the Database Header Cell Reference for the column containing your full class name. You could then set the column width of the full name to zero to hide it from displaying. 2 Quote Link to comment
michaelk Posted March 30, 2022 Share Posted March 30, 2022 🤪 I never remember that =SUBSTRING exists. And it deprives me of the joy of writing little scripts. Quote Link to comment
michaelk Posted March 31, 2022 Share Posted March 31, 2022 You could also put the name you want to use in the class and layer descriptions and use =OBJECTDATA('CLASS DESCRIPTION' and =OBJECTDATA('LAYER DESCRIPTION') But, again. Not as fun. 1 Quote Link to comment
Tom W. Posted March 31, 2022 Share Posted March 31, 2022 10 hours ago, michaelk said: Data that used to have to be hard coded into parametric objects records or added manually to symbols or attached manually as record formats can now be part of the atmosphere of the drawing. Michael could you expand a little on this? You're talking about Data Manager right? I have made a couple of aborted attempts at looking at the Data Manager but came away each time with a sore head. A practical example of what you're talking about would help tons if you were able to... Thanks Quote Link to comment
Gregovitch Posted March 31, 2022 Author Share Posted March 31, 2022 19 hours ago, michaelk said: So try this: s1 := GetName(GetLayer(h)); Did not work sadly (And even sadder the program did not crushed, no lightshow). Script sounds fun, count me in! Quote Link to comment
michaelk Posted March 31, 2022 Share Posted March 31, 2022 @Gregovitch Try this: Quote PROCEDURE Test; CONST Delim = '-'; VAR h ,h2 : HANDLE; s1,s2 : STRING; i1, i2 : INTEGER; BEGIN h := WSScript_GetObject; h2 := GetLayer(h); s1 := GetLName(h2); i1 := POS(Delim,s1); While i1 <>0 DO BEGIN i1 := POS(Delim,s1); Delete(s1,1,i1); END; WSScript_SetResStr(s1); END; RUN(Test); Turns out GetName(h) will get the name of most things. GetLName(h) will get the name of a Layer. All part of the fun at this party 🙂 1 Quote Link to comment
Pat Stanford Posted April 1, 2022 Share Posted April 1, 2022 Background. Do not read while driving. May cause drowsiness. 😉 Under the hood the different objects in VW are kept in an object list that (I think) is indexed by Object Name (as well as other things). That is why two objects in VW can't have the same name. It can only be in the Name List once. But Layers have a separate List. So you can have a Layer named Door and a Class named Door. Or you can have a Layer named Door and a Door object in the drawing, but you can't have a Class named Door and a Door Object they have a name conflict. My guess is that when VS (MiniPascal at the time) was written, it was just easier to have two different functions. They probably should have been combined into one a long time ago, but they have not been. So here is the Ring of Names (One name getter to rule them all) Just extract the Function definition out and paste it into your script and then use it in place of GetName and GetLName as you see fit. And yes, I really don't want to be doing what I am supposed to be doing today. 😉😂 Procedure Test; Function GetKName(TheHandle:Handle):STRING; Begin If GetTypeN(TheHandle)=31 THEN GetKName:=GetLName(TheHandle) ELSE GetKName:=GetName(TheHandle); End; BEGIN AlrtDialog(GetKName(FLayer)); {show the name of the first Layer} AlrtDialog(GetKName(FSActLayer)); {Show the name of the first selected object on the active Layer} ENd; Run(Test); 2 Quote Link to comment
Gregovitch Posted May 9, 2022 Author Share Posted May 9, 2022 I have actually found another way to solve my problems and it maddens me because it is so easy and perfect... Instead of asking to show me the last dash of the class with a script (or layer) I ask the worksheet to show me the class (or layer) description. It also allows me to be super flexible on the text. Thanks for the hand, I did learn a lot of all of this! Have a good day gents! Quote Link to comment
Pat Stanford Posted May 9, 2022 Share Posted May 9, 2022 If you don't need the description for anything else, that is a great way to go. 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.