Python - Using core interfaces (and named selection sets)

Python - Using core interfaces (and named selection sets)

federico.ciuffolini
Participant Participant
1,275 Views
2 Replies
Message 1 of 3

Python - Using core interfaces (and named selection sets)

federico.ciuffolini
Participant
Participant

Hi guys, 
my end goal is to have access to the Named selection sets system using python.

I couldn't find anything in the documentation, but I noticed that inside MaxPlus.InterfaceIds there is a IidNamedSelectionSetManager interface. Am I on the right path? How can I access this interface?

The only evidence i was able to Reverse engineer is that if you do something like:

interface = MaxPlus.Core.GetCOREInterface(MaxPlus.InterfaceIds.IidNamedSelectionSetManager)
print(interface.FindFn("GetNamedSelSetItemCount"))

you get a nice "2" as output, instead of the -1 that you get if you put in other gibberish.

I know that something is hiding in there. But I don't know how to access and use it.
Any insight? 
Thanks!

0 Likes
Accepted solutions (1)
1,276 Views
2 Replies
Replies (2)
Message 2 of 3

drew_avis
Autodesk
Autodesk
Accepted solution

Hi Frederico, I would encourage you to look at using pymxs instead of MaxPlus for this task, for (as you've noticed) MaxPlus does not directly expose the NamedSelectionSetManager, while Maxscript (and therefore pymxs) does.

 

You can do something like:

import pymxs
rt = pymxs.runtime
named_mgr = rt.NamedSelectionSetManager
num_sets = named_mgr.GetNumNamedSelSets()
print num_sets
for i in range(num_sets):
	print named_mgr.GetNamedSelSetName(i)
	print named_mgr.GetNamedSelSetItemCount(i)

This doc covers the methods you can use:

https://help.autodesk.com/view/3DSMAX/2019/ENU/?guid=GUID-6CC6500C-FD5C-4646-A880-BC34E852CA2B

 

Hope that helps,

Drew



Drew Avis
Content Experience Designer
0 Likes
Message 3 of 3

federico.ciuffolini
Participant
Participant

Thank you ! That is way more simple.

Federico

0 Likes