Matteo New Posted April 26, 2017 Share Posted April 26, 2017 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 Quote Link to comment
michaelk Posted April 26, 2017 Share Posted April 26, 2017 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 Quote Link to comment
Matteo New Posted April 26, 2017 Author Share Posted April 26, 2017 I prefer "GetDescriptionText". This command should "Get" me the DescriptionText from the Object Class, right? Now I want to write it into a database field of the object (which I can access from a worksheet afterwards) right? Or am I completely wrong? Quote Link to comment
Pat Stanford Posted April 26, 2017 Share Posted April 26, 2017 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. 2 Quote Link to comment
Pat Stanford Posted April 26, 2017 Share Posted April 26, 2017 If this is something you are going to do often in multiple files, we can store the script in the User Folder so it can be shared between files instead of having to exist in every file. If this is a one-time or occasional thing, storing the script in the file is the best option. 1 Quote Link to comment
Matteo New Posted April 27, 2017 Author Share Posted April 27, 2017 Wow, that does work, indeed. I first got some errors, but, somehow I finally made it work. Thanks :-) Running scripts from worksheets could really be a powerful tool. Quote Link to comment
Matteo New Posted April 28, 2017 Author Share Posted April 28, 2017 excuse me, Pat, but, where in the user folder do you suggest me to put this file? userfolder/application support/Vectorworks/201x/Libraries/Defaults/ ??? Quote Link to comment
Pat Stanford Posted April 28, 2017 Share Posted April 28, 2017 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 Quote Link to comment
DavidF Posted February 6, 2024 Share Posted February 6, 2024 On 4/26/2017 at 4:45 PM, Pat Stanford said: 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. Hi, I'm probably doing something wrong. I have created runscript, but when I add =RunScript('ClassDescrip') into a cell, nothing happens. Could someone please show me with a screenshot how you did it? / Programming illiterate person Quote Link to comment
Pat Stanford Posted February 6, 2024 Share Posted February 6, 2024 Did you copy everything out of the code block in my post and paste it into a Vectorscript named 'ClassDescrip'? Are the script name and the name you are using in the RunScript call identical? No extra spaces even at the beginning or end? Did you create a worksheet database of Classes first to use the RunScript function in? If the above doesn't solve the problem, can you post the file so I can take a look? Quote Link to comment
Vectorworks, Inc Employee Hugues Posted February 6, 2024 Vectorworks, Inc Employee Share Posted February 6, 2024 I would like to add that as of VW2022, there is now a function that returns the class description of an object's class in a worksheet. =OBJECTDATA('class description') https://developer.vectorworks.net/index.php?title=Worksheet_Functions 3 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.