[MXS] 1) Access to nested ProBoolean or 2) select an item in ProBoolean's listbox


#1

Hello.
I’ve encountered a weird behavior of the ProBoolean. Sometimes (I don’t know why and when) it creates nested ProBoolean objects while I’m picking the operands objects, for example:
I’ve created an initial Object_A (my ProBoolean object), subtract an Object_B from it and union with Object_C - then my ProBoolean object have only 1 operand in the list (Union Object_C ) and the base object (0: Union) becomes another ProBoolean object (with the Subtr Object_B).

It happens very rarely, but sometimes it does and I want to handle it in my script which extracts ALL the operands objects from ProBoolean.

My question is: how to select an item in a nested ProBoolean object to press the Extract selected button later? The ProBoolean.SetOperandSel function doesn’t seem to work in such case, but maybe I’m doing something wrong? Or maybe I can select an item from the nested ProBoolean listbox using the UIAccessor + windows.sendMessage? I’ve tried it, but failed.


#2

do you know that you can extract any item via mxs without pressing the button?


#3

Yes, I’m using this function:

fn pressExtractSelectedButton =
(
  max modify mode
  maxHWND = windows.getMAXHWND()
  cmdHWND = for c in windows.getChildrenHWND #max where c[4] == "ModifyTask" do exit with c[1]
  btnHWND = (windows.getChildHWND cmdHWND "Extract Selected")[1]
  UIAccessor.PressButton btnHWND -- press the button
)

Here’s my 3ds max 2014 scene with the weird Boolean:
PB_max2014.max (828 KB)


#4

I mean with no pressing the button at all


#5

Hmm… I don’t know, but I’d like to :wink:


#6

create a ProBoolean object.
Lets say, the Union of a Cylinder and a Sphere.

select the ProBoolean just for easy playing… (for the extracting items it can be not selected)

check it’s baseobject:

$.baseobject

it has to be ProBoolean
check references of the baseobject:

aa = for k=1 to refs.getNumRefs $.baseobject collect (refs.getreference $.baseobject k)

you will see the references those make the object: geometries and their transforms relative to current node

now we can extract any of ‘items’ as a new node doing it for example as:

n0 = editable_mesh()
n0.baseobject = aa[1]

it will make an instance of the first item. You can try to change its parameters and see that ProBoolean object will change as well.

you can set the transform controller as instance too:

n0.controller = aa[2]

and try to move n0 node…

it’s easy, isn’t it?

PS. Play with the idea, and you should find that is the same easy to replace any ProBoolean item with another object, as well as change or constraint its transformation via MXS


#7

This looks very promising. However I need to extract those objects with “Remove” option, so basically delete it from ProBoolean as well. Is there a way to set the reference to undefined after I get it with refs.getReference?