Jump to content
scaron

script access, get existing growfx object

Recommended Posts

hello

 

i am not very experienced 3dsmax programmer. i was wondering if growfx comes with its own 'get' or 'getall' method for accessing existing growfx objects? in the docs i see how to construct a new one and programmatically build a tree up, what i need to do is run a script on an existing one, which will enable and disable certain mesh modifiers and then export the meshes to obj for use in another application.

 

thanks

steven

Share this post


Link to post
Share on other sites

i have another question about inspecting the paths and mesh builders on the paths by modifier type. right now i know the names of each path and modifier but i need to get them by type. ie. for all paths get their mesh builder modifiers and if the modifier is not leaves mesh, disable it.

 

here is my current code, it has hard coded property names...

for item in selection do(
	if classOf(item) == GrowFX do(
		gfx = item;
		gfx.trunk.Meta_mesh_01.Enabled = false;
		gfx.branches_1.Meta_mesh_01.Enabled = false;
		gfx.branches_2.Meta_mesh_01.Enabled = false;
		gfx.branches_3.Cylinder_mesh_01.Enabled = false;
		gfx.leaves.Leaves_mesh_01.Enabled = true;
		
		-- force update
		gfx.Update()
	)
)

Share this post


Link to post
Share on other sites

Hi Steven,

 

Yes, some MaxScript functions are not yet available in GrowFX, because few people use it. However, we can add the necessary functions and properties...  If you have any more wishes regarding the MaxScript functionality, please let us know, we'll add it.

 

Thanks!

Share this post


Link to post
Share on other sites

i have another question about inspecting the paths and mesh builders on the paths by modifier type. right now i know the names of each path and modifier but i need to get them by type. ie. for all paths get their mesh builder modifiers and if the modifier is not leaves mesh, disable it.

 

You can check the component type as follows:

if classOf(gfx.trunk.Meta_mesh_01) == GrowFX_sMESH_Meta do ( ...

 

Here's a list of types for the Mesh builders:

GrowFX_sMESH_Cyl 

GrowFX_sMESH_Meta 

GrowFX_sMESH_Leafs 

GrowFX_sMESH_IG 

GrowFX_sMESH_STDLeafs

 

Cheers!

Share this post


Link to post
Share on other sites

thanks eduard

 

is this the proper way to get lists of properties/modifiers?

 

for item in selection do(
	if classOf(item) == GrowFX do(
		gfx = item;
		props = getPropNames(gfx);
		for prop in props do(
			p = getProperty gfx prop;
			if classOf(p) == GrowFX_sPath do(
			    pathProps = getPropNames(p);
				for pathProp in pathProps do(
					m = getProperty p pathProp;
					if classOf(m) == GrowFX_sMESH_Meta do(
						m.Enabled = false;
					)
				)
			)
			
			-- force update
			gfx.Update();
		)
	)
)

Share this post


Link to post
Share on other sites

Hi Steven,

 

Yesterday, we added the following functions:

 
getPath <path_index_integer>

Returns the indexed path, index are 1-based.
 

getDistributor <path_index_integer> <distributor_index_integer>

Returns the indexed distributor for the specified path, indexes are 1-based.
 

getModifier <path_index_integer> <modifier_index_integer>

Returns the indexed modifier for the specified path, indexes are 1-based.
 

getMeshBuilder <path_index_integer> <mesh_index_integer>

Returns the indexed mesh builder for the specified path, indexes are 1-based.
 

getAfterMeshModifier <path_index_integer> <aftermeshmodifier_index_integer>

Returns the indexed after mesh modifier for the specified path, indexes are 1-based.

 

I hope this is the best way to get a components list... What do you think about this?

 

Thanks!

Share this post


Link to post
Share on other sites

i guess we would need an indexing function? like, getNumPaths? or getPathCount? etc etc

 

or it could be getPaths and it returns an array of path objects?

Share this post


Link to post
Share on other sites

i guess we would need an indexing function? like, getNumPaths? or getPathCount? etc etc

or it could be getPaths and it returns an array of path objects?

Yes you are right! We'll add these functions...
Regarding the arrays, yes we wanted to implement this, but I don't understand how to do it in the Max SDK, because I've not found an example...
 
Thanks!

Share this post


Link to post
Share on other sites

Ok, we've added the following functions:

 

getNumPaths()

Returns the number of paths.
 

getNumDistributors <path_index_integer>

Returns the number of distributors for the specified path, index are 1-based.
 

getNumModifiers <path_index_integer>

Returns the number of modifiers for the specified path, index are 1-based.
 

getNumMeshBuilders <path_index_integer>

Returns the number of mesh builders for the specified path, index are 1-based.
 

getNumAfterMeshModifiers <path_index_integer>

Returns the number of after mesh modifiers for the specified path, index are 1-based. 

 

Now you can try this code:

gfx = $

for i = 1 to gfx.getNumPaths() do (
	path = gfx.getPath i;
	format "%\n" (classOf(path));

	format "   Distributors:\n"
	for j = 1 to (gfx.getNumDistributors i) do (
		distr = gfx.getDistributor i j;
		format "      %\n" (classOf(distr))
	)
	format "   Modifiers:\n"
	for j = 1 to (gfx.getNumModifiers i) do (
		dir = gfx.getModifier i j;
		format "      %\n" (classOf(dir))
	)
	format "   MeshBuilders:\n"
	for j = 1 to (gfx.getNumMeshBuilders i) do (
		mb = gfx.getMeshBuilder i j;
		format "      %\n" (classOf(mb))
	)
	format "   AfterMeshModifiers:\n"
	for j = 1 to (gfx.getNumAfterMeshModifiers i) do (
		amm = gfx.getAfterMeshModifier i j;
		format "      %\n" (classOf(amm))
	)
)

Please contact me by email, and I'll send you an update...

 

Thanks!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...