Jump to content

worksheet show only last part of class name


Recommended Posts

Evening,

 

I am setting up some worksheet and was wondering if there is a way to :

  1. (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

 

image.thumb.png.b1ed4dafb7f1a3a6c5087480617b2e1f.png

 

Thanks,

 

Greg

Link to comment

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

  • Like 2
Link to comment

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!

 

 

Link to comment

@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 🙂 

  • Like 1
Link to comment

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.

Link to comment
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 🙂.

  • Like 1
Link to comment

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.

  • Like 2
Link to comment
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

 

Link to comment

@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 🙂 

  • Like 1
Link to comment

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);

 

 

  • Laugh 2
Link to comment
  • 1 month later...

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!

 

 

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...