Notifications
Clear all

[Closed] store TriMesh in scripted plugin?

I have a scripted simpleObject plugin that generates some of its geometry from the TriMeshes of picked scene objects. This works fine, the problem is I dont need or want the picked objects in the scene after they have been picked so I need to store their TriMeshes somewhere but as far as I can see there isnt an appropriate paramblock type to store it in. I’ve tried storing in a local variable but it only works until the scene is reloaded. Any suggestions ?

2 Replies

try putting the mesh variable in a custom attribute on a global track node, something like:


	myCustomAttribute = attributes theAttribute
	attribID:#(0x114821c8, 0x101c7f8a) -- use genClassID to get an unique ID
	(
		parameters main 
		(
			myTriMesh type:#maxObject
		)
	)

	theTriMeshVariable = myObject.mesh
	
	newTrackViewNode "myContainer"
	custAttributes.add trackviewnodes[#myContainer] myCustomAttribute
	trackviewNodes[#myContainer].theAttribute.myTriMesh = theTriMeshVariable
	

the trackviewnode will be saved and loaded with the scenes.
Check the “how to make it better” topic in maxscript help for further information about custom attributes and persistent global variables

cheers,

M

storing TriMeshes on a global track using custom attributes is kind of redundant since I need this for a scripted plugin which already has its own param block. That being said I wasn’t aware that you could store TriMeshes using the #maxobject type so thanks for that.

For those that are interested, after some testing I have learned that you cannot store just any old TriMesh value on a #maxobject type parameter. It needs to be specifically the .mesh property of a scene node but after you delete the node and even save and reload the scene the reference to the mesh is still there which is exactly what I was after.