[Closed] Basic Scripted Geometry Problem
Hi Guys,
I’ve got a crash problem when I am writing a scripted geometry plugin that extends the editable_mesh class. The plugin is extreme basic with one parameter (for now). I am trying to create an instance of the plugin in the scene and then assign a mesh to it (from another object in the scene). Everytime I do this it works, and then the scene crashes after a while, or if I try and save, due to some unknown instability.
My plugin is very basic, it extends the editble_mesh class, and replaces the ui completely.
In my maxscript listener I might then try something like this:
--Create instance of plugin (called SuperMesh)
PluginObj = SuperMesh()
--Create a basic box for the mesh object
Meshobj = Box()
convertTo Meshobj TriMeshGeometry
--Now assign Meshobj mesh to the instance of the plugin. Then update plugin mesh
PluginObj.editable_mesh.mesh = Meshobj.mesh
update PluginObj.editable_mesh.mesh
This will now crash, even though I feel that I have updated the mesh in the plugin to avoid the instability. Interestingly if I just take two standard meshes and assign one mesh over to the other and update in exactly the same way then there is no crash. For example:
--Create a basic box for first mesh object
Meshobj1 = Box()
convertTo Meshobj1 TriMeshGeometry
--Create a basic sphere for second mesh object
Meshobj2 = sphere()
convertTo Meshobj2 TriMeshGeometry
--Now assign Meshobj mesh to the instance of the plugin. Then update plugin mesh
Meshobj1.mesh = Meshobj2.mesh
update Meshobj1.mesh
This runs fine, and saves fine, with no stability issues at all.
Am I trying to assign meshes to my plugins in completely the wrong way? If someone could help/explain this stability issue then I would be immensely grateful. Since I have big plans for these plugins, but am rather badly falling at the first hurdle
Thanks for your time everyone
Everzen
I don’t understand why your new scripted plug-in would have a “editable_mesh” property.
I think it should…
PluginObj.mesh = Meshobj.mesh
update PluginObj.mesh
Which is what would happen if you had extended a Box or Sphere object. The editable_mesh class doesn’t have a editable_mesh property?
Does any of this make sense?
Can you please post your SuperMesh source code.
Thanks for looking at this Mustan9 I am new to scripted plugins and they are making my head hurt. Since I have just started the pluggin it is super basic. Here it is:
plugin Geometry SuperMesh
name:"SuperMesh"
classID:#(0x77c1dea5, 0x48e2b6d5)
category:"Scripted Primitives"
extends:editable_mesh
replaceui:true
(
parameters main rollout:params
(
height type:#worldUnits ui:height default:0
)
rollout params "Random Parameter"
(
spinner height "Height" type:#worldunits range:[-1000,1000,0]
)
)
If you create an instance of this in your scene then naturally there is no geometry, which is what I wanted, cause I then wanted to assign a trimesh (from another object, say a collasped box), to be the geometry for this plugin. If there is a better/proper way of doing this then please say
So from there if you look at the properties of the plugin instance
PluginObj = Supermesh()
showproperties PluginObj
Then it returns
$SuperMesh:SuperMesh01 @ [0.000000,0.000000,0.000000]
.height : worldUnits
.Editable_Mesh
I was then trying to assign a mesh to the editable_mesh property. I tried this way cause if you put in:
PluginObj.editable_mesh.mesh
Then it returns “Trimesh”. So I tried assigning things to this as in: (RefMesh is an arbitary collasped editable mesh)
PluginObj.editable_mesh.mesh = $RefMesh.mesh
But that resulted in the previously mentioned instability and scene crashing.
I guess all I am trying to do is create a geometry plugin that I can then assign a trimesh to, so the plugin takes on the mesh of which ever object I reference. I can then use some custom parameters that I will later add to do manipulations…
I may well be going about this in completely the wrong way (I clearly am since I am taking out max when I save ). So if there is a completely different direction I shoud be heading in, then please shove me that way.
Thanks for your time!
EverZen
Yea, that is the wrong property.
$.editable_mesh is used for vertex animation and you can not assign it a new mesh via MaxScript. 3D Studio Max shouldn’t be crashing, but should throw an assignment error.
The correct error message would be
“– Runtime error: Cannot directly set animatable property: Editable Mesh”
The correct property is.
$.mesh
For some reason, MaxScript doesn’t like that property to be changed on your new plugin. I can’t figure out why.
The work around for this is to use the “setMesh” function. This appears to work correctly.
setMesh PluginObj.mesh TriMesh()
Works without throwing an error.
On another note, I think your plug-in is designed incorrectly. I found a better example in the MaxScript manual. It’s titled “How To … Create Scripted Geometry Plug-in” and doesn’t extend any classes. This script has a “on buildmesh” event that is called, and you could build the geometry in this method. If you wanted a box, sphere, etc. etc. This should be more stable, and might make for a better design.
I’m not sure if your suppose to extend “editable_mesh”. I thought this class was reserved and you could only extend classes that have a creation tool. But, it’s letting you do it so maybe it’s ok.