Notifications
Clear all

[Closed] Shape Boolean operands name update

 MZ1

Let say we have shapeboolean with some operand. if we change a node name, the operand list wouldn’t be updated and always shows the old name. Anyone have idea to solve this?

8 Replies

what is shapeboolean? wtat max vertion do we talk about?

SetOperandName
… to get the index probably you can use GetReference for second param block. All operands are in reference order – object 1, transform 1, object 2, transform 2, …

most Boolean objects (Compaund) use the same interface

 MZ1

SetOperandName works just fine, But it’s difficult for me to get the operands (objects) list, would you please describe it more?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

ShapeBoolean uses a new interface for operand objects then ProBoolean or ProCut. All objects you can find in .objects now.
But they are stored as objects in the added state. So you usually see DerivedObjects in #objects
Technically, the operand node can be removed after you’ve created the ShapeBoolean (similar to how Morpher works). In this case, you cannot find the original node by dependency test.
But if the node of the operand still exists, you should be able to find it like:

a = refs.getreference <shapebool>.objects[n]
b = (refs.dependentnodes a)[1]

I couldn’t find operand nodes the other way. This of course won’t work if you remove operand or change the order of operands afterwards

shapebool = $

operands = for s in shapes collect
(
	if findItem (refs.dependentNodes s.baseobject) shapebool > 0 then s else dontCollect
)

print operands
deleteAllChangeHandlers id:#jah42
when name operands changes id:#jah42 val do
(
	format "%\n" val	
	index = findItem operands val	
	if index > 0 do shapebool.SetOperandName index val.Name
)

upd
or something like this

fn RenameShapeBooleanOperands =
(
	local names = callbacks.notificationParam()
		
	-- pseudocode
	if sb in getClassInstances ShapeBoolClass do
	(
		foreach operand in sb where operand.Name == names[1] do operand.Name = names[2]	
	)

)

callbacks.addScript #nodeRenamed "RenameShapeBooleanOperands()" id:#jah42
callbacks.addScript #nodeNameSet "RenameShapeBooleanOperands()" id:#jah42
 MZ1

sorry this always return the shapeboolean node itself, not the target objects.

objref = refs.getreference <shapebool>.objects[n] 1
baseobj = refs.getreference objref 1
nodes = (refs.dependentnodes baseobj)

there should be two nodes – one is the shapebool itself, and the second is an operand