Jump to content

Create multi folders and sub folders


Ben3B

Recommended Posts

Hello, It's time to classe all my devices and give it a common appearance

I would class all my device in the same way as they are in my warehouse software ...

So i what is the better way to create multi folders and sub folders in a few click ?

the tree must be like that :

 

 

─arborescence renteman 21-12-17

│ ├───Accessoires

│ │ ├───Cable

│ │ ├───Vidéo accessoires

│ │ └───Écran LED

│ ├───Audio

│ │ ├───Câbles

│ │ ├───Diffusion

│ │ │ ├───DAS Audio

│ │ │ ├───L-Acoustics

│ │ │ ├───LD Systems

│ │ │ ├───Sennheiser

│ │ │ └───Yamaha

│ │ ├───Liaison

│ │ │ ├───Ear monitor

│ │ │ ├───Intercom

│ │ │ └───Talkie

│ │ ├───Microphones

│ │ │ ├───Filaires

│ │ │ └───HF

│ │ ├───Pieds

│ │ │ ├───Enceintes

│ │ │ └───Microphones

│ │ └───Régie

│ │ ├───Consoles

│ │ └───DJ

│ ├───Digital

│ │ ├───Gestion des flux

│ │ ├───Intéractivité

│ │ ├───Player web

│ │ ├───Pré-production

│ │ ├───Stream Rsociaux

│ │ └───Webconférence

│ ├───Déco

│ │ ├───Fonds

│ │ └───Pendrillons

│ ├───Informatique

│ │ ├───Accessoires

│ │ ├───Cables

│ │ ├───PC

│ │ └───Réseau

│ ├───Logistique

│ │ ├───Passages de cables

│ │ ├───Securite

│ │ │ └───Plateforme

│ │ └───Tools

│ ├───Production

│ │ ├───Post-production

│ │ ├───Pré-production

│ │ └───Réalisation

│ ├───Structure

│ │ ├───Accessoires

│ │ ├───Embase

│ │ ├───Levage

│ │ │ ├───Palans

│ │ │ └───Pieds

│ │ ├───Monotubes

│ │ │ ├───Alus

│ │ │ └───Noirs

│ │ ├───Plateaux

│ │ │ ├───Accessoires

│ │ │ └───Praticables

│ │ └───Truss

│ │ ├───Alus

│ │ └───Noirs

│ ├───Vente

│ │ ├───Adhésifs

│ │ ├───Habillage

│ │ └───Machine fumée

│ ├───Vidéo

│ │ ├───Accessoires

│ │ ├───Captation

│ │ │ ├───Accessoires

│ │ │ ├───Caméras

│ │ │ ├───Objectifs

│ │ │ └───Pieds

│ │ ├───Câbles

│ │ ├───Diffusion

│ │ │ ├───Moniteurs

│ │ │ ├───Objectifs

│ │ │ ├───Pieds

│ │ │ ├───Toiles

│ │ │ └───Videoprojecteurs

│ │ └───Régie

│ │ ├───Accessoires

│ │ └───Consoles

│ ├───Éclairage

│ │ ├───Accessoires

│ │ ├───Ambiance

│ │ ├───Câbles

│ │ ├───Deco

│ │ ├───Directs

│ │ ├───Effets

│ │ ├───Gradateurs

│ │ ├───Machine à fumée

│ │ ├───Pieds

│ │ ├───Projecteurs robotisés

│ │ └───Régie

│ └───Éléctricité

│ ├───Armoires

│ └───Cable

│ ├───16AM

│ ├───16AT

│ ├───32AT

│ ├───63AT

│ └───Adaptateurs

#

Link to comment

The attached script will take a selection of two columns of an open worksheet and make classes using those names.  The first column should be the desired class name. The second column should be the class description. If the second column is blank then the description will be ignored. The script ignores classes that already exist, so it can not be used to update the description of existing classes.

 

To create subclasses you have to include the full top-level class name on each row followed by a dash and the sub class name.  Something like:

 

Top Level-Sub Level1

Top Level-Sub Level2

 

If you have class names that you want to look like they include a dash, make sure you don't use the dash character as it will create another level of subclass. You can use and em-dash which is just slightly longer. On the Mac you create this by typing Option -.

 

Vectorworks does not treat the higher level sections of hierarchical class names as actual classes. They by themselves can't be assigned to an object. As an example from your list above.

 

If you want classes Audio, Audio-Diffusion, and Audio-Diffusion-DAS Audio you would have to have three different lines in the worksheet. And you will get Audio and Audio-DIffusion displaying twice in the class list. Once as a selectable class and once as a header for the subclasses.

 

Ask again if you have more questions.

 

Procedure CreateClassesFromWSSel;

{January 27, 2022}
{Update to handle both Class Name and Description}
{December 7, 2016}
{© 2022, 2016, Pat Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}

{Creates classes from a list of class names in an open worksheet.}
{Select a single column range in a worksheet containing the names}
{of the desired classes. Run the script. Names in the selection that}
{are not currently classes in the file are created. The Active Class}
{is reset at the end of the script the what it was before running}
{the script.

{Lightly tested. Use at your own risk. Save before running the script.}
{Do not operate ocean going or interstellar vehicles while using}
{this script.}

Var	CurrentClass,NewClass, NewDescrip:String;
	R1,C1,R2,C2,CurrentRow,CurrentCol,ThisRow:Integer;
	SR1,SC1,SR2,SC2:Integer;
	WSHandle:Handle;
	B1:Boolean;
	
Begin;
	CurrentClass:=ActiveClass;   {Store the Active Class before the script}
	WSHandle:=GetTopVisibleWS;   {Get the top open worksheet}

	If WSHandle <> Nil then			{Make sure a WS is open}
		Begin
			{Get the selected cells in the worksheet}
			GetWSSelection(WSHandle,CurrentRow,CurrentCol,R1,C1,SR1,R2,C2,SR2);

			If C2-C1=1 then  {make sure two columns are selected}
				Begin
					For ThisRow := R1 to R2 do   {repeat for each row in the selection}
						Begin
							GetWSCellString(WSHandle,ThisRow,C1,NewClass);  {get the desired class name from the cell}
							GetWSCellString(WSHandle,ThisRow,C2,NewDescrip);  {get the desired class description from the cell}
							If ((GetObject(NewClass)=nil) AND (NewClass<>'')) THEN
								Begin
									NameClass(NewClass);    {Create the class and make it active}
									B1:=SetDescriptionText(GetObject(NewClass),NewDescrip); {add the description to the class}
								End;
						End;
				End
			Else
				AlrtDialog('Select only two columns of data.'); {Notify if wrong number of columns selected}

		End
	Else
		Begin
			{Notifiy if a worksheet is not open}
			AlrtDialog('Must have a Worksheet open and part of two columns containing the new Class names & Descriptions selected.');
		End;
	NameClass(CurrentClass);	{Restore the active class from before script}
End;

Run(CreateClassesFromWSSel);

 

 

  • Like 1
Link to comment
  • Vectorworks, Inc Employee

This is nice @Ben59 just be aware that we will be re-organising and renaming the classes that ConnectCAD assigns by default. This is mostly to do with giving you more control over the visibility and appearance of the internal parts of ConnectCAD objects.  From what I see it looks good.

 

@Pat Stanford Thanks for sharing that script! I really want to encourage everyone to take control of their Vectorworks workflow in this way. The journey begins with hacking around an existing script.

 

Conrad

Link to comment

thanks @Pat StanfordBut my mistake, i think i dont exprim my self in the correct way ... 😞

Classe isn't the good word , by class i mean : "tidy, to organise ,to classify.

I would have the same name folder in my ressource manager than in my windows explorer...

I know that I can create it one by one,but I'm looking a way to create all the symbole folders at once, and after each time I create a new device , i rrecord it in the good folder 

Thanks hope you understand me

image.thumb.png.479ff36d99a9889537bbf791afc73ab0.png

image.thumb.png.1b27c184521829f395b403b46924f534.png

Link to comment
47 minutes ago, Conrad Preen said:

This is nice @Ben59 just be aware that we will be re-organising and renaming the classes that ConnectCAD assigns by default. This is mostly to do with giving you more control over the visibility and appearance of the internal parts of ConnectCAD objects.  From what I see it looks good.

 

@Pat Stanford Thanks for sharing that script! I really want to encourage everyone to take control of their Vectorworks workflow in this way. The journey begins with hacking around an existing script.

 

Conrad

Thanks for your help, but I'm only one year old vectorworks user, so for now I'll try to "kiss" the vectorworks philosophy, and use the same default name 

Step by step 🙂 I think I understand the "matryoshka" conceptso For now I stay with the default class name, but I' m aware of the script possibility, I'm too young user for now to change all the class name 🙂 But if you have a script to creat multiple device folders and sub folders at once, I'll be happy 🙂

 

Attached are files I already have 🙂

 

arborescence renteman 21-12-17.rar arborescence rentman.txt

Edited by Ben59
Link to comment
  • 1 month later...
On 1/27/2022 at 11:26 PM, Pat Stanford said:

The attached script will take a selection of two columns of an open worksheet and make classes using those names.  The first column should be the desired class name. The second column should be the class description. If the second column is blank then the description will be ignored. The script ignores classes that already exist, so it can not be used to update the description of existing classes.

 

To create subclasses you have to include the full top-level class name on each row followed by a dash and the sub class name.  Something like:

 

Top Level-Sub Level1

Top Level-Sub Level2

 

If you have class names that you want to look like they include a dash, make sure you don't use the dash character as it will create another level of subclass. You can use and em-dash which is just slightly longer. On the Mac you create this by typing Option -.

 

Vectorworks does not treat the higher level sections of hierarchical class names as actual classes. They by themselves can't be assigned to an object. As an example from your list above.

 

If you want classes Audio, Audio-Diffusion, and Audio-Diffusion-DAS Audio you would have to have three different lines in the worksheet. And you will get Audio and Audio-DIffusion displaying twice in the class list. Once as a selectable class and once as a header for the subclasses.

 

Ask again if you have more questions.

 

Procedure CreateClassesFromWSSel;

{January 27, 2022}
{Update to handle both Class Name and Description}
{December 7, 2016}
{© 2022, 2016, Pat Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}

{Creates classes from a list of class names in an open worksheet.}
{Select a single column range in a worksheet containing the names}
{of the desired classes. Run the script. Names in the selection that}
{are not currently classes in the file are created. The Active Class}
{is reset at the end of the script the what it was before running}
{the script.

{Lightly tested. Use at your own risk. Save before running the script.}
{Do not operate ocean going or interstellar vehicles while using}
{this script.}

Var	CurrentClass,NewClass, NewDescrip:String;
	R1,C1,R2,C2,CurrentRow,CurrentCol,ThisRow:Integer;
	SR1,SC1,SR2,SC2:Integer;
	WSHandle:Handle;
	B1:Boolean;
	
Begin;
	CurrentClass:=ActiveClass;   {Store the Active Class before the script}
	WSHandle:=GetTopVisibleWS;   {Get the top open worksheet}

	If WSHandle <> Nil then			{Make sure a WS is open}
		Begin
			{Get the selected cells in the worksheet}
			GetWSSelection(WSHandle,CurrentRow,CurrentCol,R1,C1,SR1,R2,C2,SR2);

			If C2-C1=1 then  {make sure two columns are selected}
				Begin
					For ThisRow := R1 to R2 do   {repeat for each row in the selection}
						Begin
							GetWSCellString(WSHandle,ThisRow,C1,NewClass);  {get the desired class name from the cell}
							GetWSCellString(WSHandle,ThisRow,C2,NewDescrip);  {get the desired class description from the cell}
							If ((GetObject(NewClass)=nil) AND (NewClass<>'')) THEN
								Begin
									NameClass(NewClass);    {Create the class and make it active}
									B1:=SetDescriptionText(GetObject(NewClass),NewDescrip); {add the description to the class}
								End;
						End;
				End
			Else
				AlrtDialog('Select only two columns of data.'); {Notify if wrong number of columns selected}

		End
	Else
		Begin
			{Notifiy if a worksheet is not open}
			AlrtDialog('Must have a Worksheet open and part of two columns containing the new Class names & Descriptions selected.');
		End;
	NameClass(CurrentClass);	{Restore the active class from before script}
End;

Run(CreateClassesFromWSSel);

 

 

I "can't" use it , it doesn't work as expected...

I copy the text and paste it notepad++,, save it as .py .

here is the error message image.png.4ed6455ee16d391f78722a8a2775f3ca.png

 

But may be I'm on a wrong way, I want to create classe for device, all begin withCCD followed by the "code" from my personnal record ...

 

thanks

 

Link to comment
9 hours ago, Pat Stanford said:

My script is a Vectorscript, not a Python script. Paste it into the script editor and make sure the button at the top of the editor window is set to Vectorscript instead of Python.

 

 

Sorry my mistake, I'm new with script 🙂 
I'll let you know if it works as expected ASAP 😉 Sorry I will not have a look now because I've something quicker for me .
Thanks all and thanks @Nikolay Zhelyazkov😉
If I don't forget, I'll come back to investigate

 

Edited by Ben59
solution from other topic
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...