Jump to content

vs.SetParent(), Ressource Folders, 2024


Recommended Posts

Hello,

 

i want to put one ressource folder into another ressource folder of the same ressource type.

 

In VW 2023 i just can use

vs.SetParent(folder_1, folder_2)

 

In VW 2024 however VW crashes if i do the same thing. Putting objects into ressource folders works fine in VW 2024, it seems like its just folders that crash VW.

Is this a known issue, or am i missing something.

 

I am aware that there is most likely a workarround to this by moving all the contents of the folders to a temporary folder and than creating the folders with nested vs.BeginFolderN and than putting the contents back into the folders, since there is no problem with that, but i would realy like to avoid that.

 

Regards,

Letti

Edited by Letti R
Link to comment

Hello @Letti R,

   Yes, it is definitely a bug in VW 2024. I just filed a bug report for this, VB-203576, and cited this Forum post. If/when I hear anything I'll post back.


   For the moment you will need to shuffle resources between the old folders and the newly created nested folders. However, you don't need to shuffle things around initially as much as you describe above. Instead, create your new nested folder structure with dummy names, then move everything from your old folders straight into the new folders with SetParent(), which does work with moving resources between folders. When everything is moved, delete the two old folders and rename the dummy folders with the old folders' names.


   There is a caveat, there is always a caveat, if either of old folders contain nested folders you will have to create the finished folder hierarchy before you start shuffling anything, then very carefully move everything from its starting position to its final position, which can get tricky. I hope your two starting folders are flat (only contain resources.)

 

Best wishes,

Raymond

  • Like 1
Link to comment

Hello,

 

Thank you for confirming and reporting the bug @MullinRJ.

 

Unfortunately i am dealing with nested folder structures of variable sizes and depths, so i think i am going to just wait for the fix.

 

Just out of curiosity, what ist the normal way of accessing the first "folder" (it is not of type folder, which ist 92 i guess) of the ressource manager? I just cant figure out how it is supposed to be done.

 

Regards,

Letti

Link to comment

Hi @Letti R,

   Of course your folders are nested. Why would life be easy?

 

   The way to get the first folder is to look at everything in the Symbol Library and skip the symbols. Here are two Pascal routines that will return a handle to the First SymFolder. Hopefully you can convert them to Python easily. If not, write back and I can help.

 

	function FSymFolder :Handle;
	{ Get a handle to the First Symbol Folder in the Symbol Library. }
	{ 19 Apr 2024 - Raymond Mullin }
	Const
		SymFolderType = 92;
	Var
		SymHnd :Handle;
	Begin
		SymHnd := FSymDef;		{ Symbol or Folder }
		if (SymHnd <> nil) then
			while (GetTypeN(SymHnd) <> SymFolderType) do
				SymHnd := NextObj(SymHnd);
		FSymFolder := SymHnd;
	End;		{ FSymFolder }

 

The same routine using ForEachObjectInList().

	function FSymFolder :Handle;
	{ Return a handle to the First Symbol Folder in the Symbol Library if one exists, otherwise return NIL. }
	{ 19 Apr 2024 - Raymond Mullin }
	Const
		SymFolderType = 92;
	Var
		FldrHnd :Handle;
		
		function isFolder(H :Handle) :Boolean;
		Begin
			if (GetTypeN(H) = SymFolderType) then
				FldrHnd := H;
			isFolder := FldrHnd <> nil;		{ return True to stop }
		End;		{ isFolder }
		
	Begin	{ FSymFolder }
		FldrHnd := nil;		{ Folder handle }
		ForEachObjectInList(isFolder, 0, 0, FSymDef);		{ All objects, Shallow }
		FSymFolder := FldrHnd;
	End;		{ FSymFolder }

 

   Finding the Next Symbol Folder is similar to finding the first, but you start looking using a handle to the next object after the first Symbol Folder.

 

Raymond

 

  • Like 1
Link to comment

For my own benefit, I converted the first example above to Python. This may not be the most elegant function, but it works. If anyone wants to improve on it, please post an example. Thanks.

 

def FSymFolder():
	# Return a handle to the First Symbol Folder, if one exists, otherwise return Nil.
	# 20 Apr 2024 - Raymond Mullin

	SymFolderType = 92
	Nil = vs.Handle(0)
	SymHnd = vs.FSymDef()	# Symbol or Folder
	if (SymHnd != Nil):
		while (vs.GetTypeN(SymHnd) != SymFolderType):
			SymHnd = vs.NextObj(SymHnd)
	return SymHnd

 

Raymond

  • Like 1
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...