BLUR Python....syntax confusion

Just entering the 3ds Max world, and thought I’d try a little scripting.

Figured I use the new BLUR Python tools since Python is more widely accepted.

Trying to get Maxscript across, but not understanding the syntax.
How does the following Maxscript translate to python?
maxOps.cloneNodes $ cloneType:#instance newNodes:&nnl
 I thought it might be something like:
mxs.maxOps.cloneNodes ("object2bclonedName") (cloneType = instance, newNodes = &nnl)

But no.


Comment viewing options

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

lets try something...

Hi Steve,

Lets say 1st that am not play with Python and what i know about is from that i read incidentally online, as we have DotNet in Max i not see a reason to start with Python, but never mind, maybe can help a bit anyhow?...

From what i know, i think that you cannot convert this to py-code, but i have some thought in mind. :)

Note that Py3dsMax come with zero help documentation. That's poor page is all the help blur-dev offer about. Far away from enough to can say its ready for public. According to this docs there only 2 hard for implementation holes and they show how to deal in this cases.

One of those is for your case - coverting Max's Name value type. Your second parameter (cloneType) need Name value and if you install their script in your Startup scripts, should do something like:


But what about the third parameter (newNodes)? It's need by reference variable. The ByRef/ByVal in many languages is crabbed in Python. Here is an interesting topic about, in case not get what i mean.

So, as i see, this is not implemented in that extension (Py3dsMax). I cannot say if is easy or not for Blur to implemente that. I only can see how much complicate the coding this lack of control is in Python about ref's/val's.

But if you open those script will catch an idea how-to solve this.

I use only logic while helping on this, so first that come to my mind is to use Max Execute function where to pass the maxOps.cloneNodes as string expression (follow Mxs-syntax) like:

# using max execute("mxs_syntax_expression")
mxs.execute("maxOps.cloneNodes $ cloneType:#instance newNodes:&newObjs")

But don't ever sure how you can get back the result from the newly created variable newObjs (which is the array of all new clones). Is this will work...

# get global var (newObjs) back in py
nodes = mxs.globalVars.get newObjs

...or mabe this...

nodes = mxs.execute("newObjs")

But skip that, Execute is awkward solution, right? What's next then?

Read that and see how they deal with functions that needs ByRef params. Lets say those function:

function getLayerNodes layer = (
	local output = #()
	layer.nodes &output

So, they wrap that function to can "move" that ByRef param to become a return result from the function, and this way "patch" the function. In other words, you need to make your own custom function wrapper like:

fn cloneObjs nodes type = (
	type = type as Name
	local output = #()
	maxOps.cloneNodes nodes cloneType:type newNodes:&output

And there a lot of Max script functions like this one you should re-pack unfortunately to fill that hole in Py3dsMax.

Ok, to end this... i presume you save this function to .ms file and put that file in your Startup scripts folder, then in Python should work this one:

newObjs = mxs.cloneObjs(selection, "instance")

Ok, let me know if this help at all ;-) but not expect more help thouch, am not a py-coder, all this is just my logical efforts :)


my recent MAXScripts RSS (archive here)

Comment viewing options

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