Jump to content
Developer Wiki and Function Reference Links ×

Custom Node - List Resources

Recommended Posts

Still tinkering. This time I have cobbled together a custom node to run VS:BuildResourceList2.


It seems to work fine, except the SUBFOLDER option. The search doesn't appear to ever be limited to the subfolder. I want to limit the list to a very specific folder in the document resource library. Is this behaving correctly?


#Modified by RB April 2023
class Params(metaclass = Marionette.OrderedClass):
	this = Marionette.Node( "List Resources" )
	this.SetDescription( 'Builds a list of resources based on the OIP input' )

	#Input Ports

	#OIP Controls
	ObjectTypeIn = Marionette.OIPControl( 'Object Type', Marionette.WidgetType.Int, 0)
	ObjectTypeIn.SetDescription('Integer that corresponds with Vectorworks Object Type')
	FolderIndexIn = Marionette.OIPControl( 'Folder Index', Marionette.WidgetType.Int, 0)
	FolderIndexIn.SetDescription('Integer that corresponds with the folder name constants')
	SubfolderIn = Marionette.OIPControl( 'Subfolder', Marionette.WidgetType.Text, 'Textures')
	SubfolderIn.SetDescription('Limit the list to the contents of this subfolder')
	DefContentIn = Marionette.OIPControl( 'Default Content', Marionette.WidgetType.Bool, False )
	DefContentIn.SetDescription('Tick to enable default content') 

	#Output Ports
	list = Marionette.PortOut('List')
	list.SetDescription( "List of the specified resources" )


def RunNode(self):

	ResType = self.Params.ObjectTypeIn.value; # The resource type: https://developer.vectorworks.net/index.php/VS:Function_Reference_Appendix_D
	FolderIndex = self.Params.FolderIndexIn.value; # The index of the folder path: https://developer.vectorworks.net/index.php/VS:BuildResourceList2
	SubFolder = self.Params.SubfolderIn.value; # A subfolder of the folder path to which the list is limited
	DefContent =self.Params.DefContentIn.value; # Toggle display of default content
	resList = []
	# Populate the resource list
	resListID, numItems = vs.BuildResourceList2(ResType, FolderIndex, SubFolder, DefContent)
	for i in range(1, numItems + 1):
		resList.append(vs.GetNameFromResourceList(resListID, i))

	self.Params.list.value = resList


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.

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