Using Python + MaxPlus, How to Select All Scene Objects?

Using Python + MaxPlus, How to Select All Scene Objects?

theeastcoastwest
Participant Participant
5,046 Views
4 Replies
Message 1 of 5

Using Python + MaxPlus, How to Select All Scene Objects?

theeastcoastwest
Participant
Participant

Title pretty much sums it up.

 

I'm familiarizing myself with the 3DS Max Python API, using MaxPlus, and have been hitting some roadblocks when it comes to selections.

 

Is it possible to select all scene objects through this API?

 

I believe the equivalent in MaxScript would be select $*

0 Likes
Accepted solutions (1)
5,047 Views
4 Replies
Replies (4)
Message 2 of 5

Swordslayer
Advisor
Advisor
Accepted solution

Any reason to limit yourself to MaxPlus? With pymxs, it would be:

 

rt= pymxs.runtime
rt.select(rt.objects)

With MaxPlus... Probably recursively collecting children of the root node (you can get it with MaxPlus.Core.GetRootNode) and using MaxPlus.SelectionManager to select the result.

0 Likes
Message 3 of 5

theeastcoastwest
Participant
Participant

Unfortunately, I'm taking this as a self-imposed limitation so I can cling to my favorite Python IDE (PyCharm) by using the MaxPlus connector here: GITHUB/ycdivfx/YCDIVFX_MaxPlus

 

I'm assuming a similar approach could be taken for the pymxs but adaptation is beyond my ability.

 

I could have sworn I tried it earlier, but as you suggested, the following exposes all scene objects:

 

MaxPlus.Core.GetRootNode().Children

Thanks for the help

 

0 Likes
Message 4 of 5

malcomarmstrong
Advocate
Advocate

This is where I feel that Autodesk has not been very thorough with the implementation. Why should there have to be a recursive function written to do the same thing as rt.select.(rt.objects)?

 

Being able to select all scene nodes is a common practice, yet I now have to write a function just to do a simple action. I just do not get why there are a lot of gaps in this implementation. Also, if you are using Max 2016, you do not have access to pymxs, so the pymxs solution will not work in those cases.

 

Is there no simple base functionality that will allow a user to just get all the required nodes as simply as: "select objects" in Maxscript or is it going to be the case that coders have to create the code that Autodesk seem to have overlooked?

 

Thats a slightly rhetorical question, but it just seems that using the Max Python is a cumbersome and at times, frustrating experience.

 

 

 

 

0 Likes
Message 5 of 5

malcomarmstrong
Advocate
Advocate

MaxPlus.Core.GetRootNode().Children will only get you the direct children of the rootnode, not anything parented to the object (or further down the chain)

 

So, as Swordslayer has said, you will need a recursive function to traverse through any hirarchies to get the objects. Perhaps a filter selection as well to get classes or objects by some property.

 

Its a bit of a ballache, but is a good lunchtime challenge(ish)

 

If I get time, I will see what I can put together. It wont be a massive bit of code by any means, I would just rather that Autodesk had considered it when writing the implementation

 

Or, just use pymxs. I do at home, but am using 2016 at work, so I have to use MaxPlus.

0 Likes