Simpleobject Plugin - Convertto

I am updating cog, and am trying to use polyop operations, instead of meshop operations.

Since I cannot use polyop operations on the plugin's mesh, I am trying to convert the starting object (a cylinder) to a edit_poly, which then will be changed, then set as the mesh, and then deleted.

But, if I use the

converttopoly cog1
if Inset==true then
...

it comes up with the error message "Couldn't find a previously defined paramblock in cog"
no matter where I put the converttopoly, or how I do it, it comes up with that error.
Why is it doing this, and how could I fix it?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
brttd's picture

Any help?

Does anyone know how to fix this problem?
No matter where I place the "converttopoly cog1" it doesnt work, the error still comes up.
I cant find a way to change the cylinder to a poly which doesnt create a error, and without changing it I cannot do the poloyp operations.

Anubis's picture

i made simplified sample for you

this is work fine for me:

plugin simpleObject Cog name:"Cog"
classID:#(0x67edb1ad, 0x8497272)
category:"Standard Primitives"
(
	on buildmesh do
	(
		local c = Cylinder()
		convertTo c Editable_Poly
		setMesh mesh c.mesh
		delete c
	)
)

But all this is a kind of pseudo-technique. The main idea in geometry plugins is to get mesh from TriMeshGeometry (using createInstance function) and NOT from scene nodes, and using only mesh ops of course, ie something like:

( --plugin body start here
	local c
	on buildmesh do
	(
		if c == undefined do c = createInstance Cylinder
		--// modify it here...
		mesh = c.mesh
	)
) -- plugin body end

my recent MAXScripts RSS (archive here)

brttd's picture

That works, but only if you

That works, but only if you dont do anything after the Setmesh, apart from deleing the cylinder, and since I am trying to use polyop operations on the cylinder, it doesnt work.

I used meshop operations in previous versions of my plugin, and I was trying to use polyop operations, which I thought would be easier to use, aswell as being able to do more/do things differently.
Unless anyone knows how to use poly operations in plugins, I will continue using meshop.

Anubis's picture

and one more tip - use copy(mesh)

First of all, I not suggest you to do whatever after setMesh, at least I avoid this.

Also, as you get the mesh from scene node, that w'd be deleted, in this case is better to get copy of that mesh, i.e.:
setMesh mesh (copy c.mesh)
This way there will not be a reference to deleted node and that will make the whole plugin a lot more stable.

Cheers!

my recent MAXScripts RSS (archive here)

brttd's picture

Ok, thanks for the help.

Ok, thanks for the help.

Anubis's picture

am just trying to save your time

The scripted plugins exists from many years, and if there was a good and safe way to use poly ops then there would be a lot of examples out there how to do that.

Also to create scene object and delete it... ever it works at all it's an illegal approach. So just go with the mesh ops.

my recent MAXScripts RSS (archive here)

Anubis's picture

i take a look, quickly...

on what you done in your ECylinder and...
you start with Cog=cylinder() in your buildMesh()...
well, shortly, try to do your poly ops before setMesh

my recent MAXScripts RSS (archive here)

brttd's picture

I am doing that, I am trying

I am doing that, I am trying to convert the cylinder to a edit_poly, but it doesnt like it, and comes up with the stated error message.
the setmesh part has been moved back, and is only after all the poly operations.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.