Jump to content

read out the class description in a worksheet


Recommended Posts

Hi,

I want to set up a class-list for the office. I already have a script which creates a rectangle for every class of a new file, created from the office-template-document, so I am able to create a worksheet which contains every class-name in the document. When I want to add or delete classes I simply delete all rectangles and run the script again and I update the worksheet.

However we want to use the class descriptions for every class, too.

 

Is there a way to read out the class description and write it in the worksheet?

1) by reading it out directly in a worksheet (sth like =Classdescription)

2) within the script, for example by adding it to a record-format field for every object and reading out this record format from the worksheet afterwards.

3) any other idea?

 

thanks and best regards

Matteo

Link to comment

It sounds possible.

 

The function to set the description for a class or layer is:

 

boolResult := SetDescriptionText (classHandle,tempDescriptionText);  (pretty sure this will work).

 

I think you could pull that from a record and make it work.

 

You could also use a worksheet.  Here's a simple one from last year that creates classes from selected cells in a worksheet.  I bet you could modify it to just get the names from column A and the descriptions from column B.

hth

 

Link to comment

Yes, it is possible. I am liking the RunScript WS function more and more. Still needs some work, but it offers great potential.

 

Create a new Vectorscript named ClassDescrip and paste the following code into it.

 

Procedure ClassDescription;
{© 2017 Patrick Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}
{A Vectorworks 2017 worksheet script to return the Class Description}
{of each object in a worksheet database.}
{Run using the RunScript function in the worksheet}

var	S1:String;

Begin
	GetDescriptionText(GetObject(GetClass(WSScript_GetObject)),S1);
	WSScript_SetResStr(S1);
End;

Run(ClassDescription);

 

Now add a column to your worksheet of classes. In the database header row add a formula of:

 

=RunScript('ClassDescrip')

 

Answer the dialog box to allow the script to run and you should have the class descriptions you are looking for. 

 

Remember that the description can have multiple lines and you will probably need to manually adjust the Row Heights to make it look good.

  • Like 2
Link to comment

Copy the script to a text editor (I personally like BBEdit, but anything that will save a plain text file will do. TextEdit will work fine on Mac). 

 

Save it using a name of ClassDescription.txt to:

 

/Users/Your User Name/Library/Application Support/VectorWorks/2017/Libraries/Defaults/Reports_Schedules

 

Then set the formula to add the code (120) for the location you have the saved the txt file.

 

=RUNSCRIPT(120, 'ClassDescription')

 

 

Before you enter and test the RunScript, save the file and any other open files you have. I have had a couple of crashes that I think are related to typos pointing to nonexistent files. I have submitted a bug report.

 

HTH

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