Isotropix Forums

Set_expression() works but expression does not activate

Clarisse Scripting related topics

Set_expression() works but expression does not activate

Unread postby atnreg » Wed May 15, 2019 12:29 pm

Hi!

Here is very simple code that is supposed to make Bound automatic as 10% larger than the current front_value.
Code: Select all
dsp=ix.cmds.CreateObject("disp","Displacement")
battr=dsp.attrs.bound.attr
battr.set_expression('get_double("front_value")*1.1',0, True)
battr.set_expression('get_double("front_value")*1.1',1, True)
battr.set_expression('get_double("front_value")*1.1',2, True)


When that code runs, the Displacement object is created and the expression is added correctly BUT it is not activated even though the zigma sign is highlighted i.e. active. The expression starts to work when and only when I MANUALLY click on the zigma signs one by one off and then back on.

What am I doing wrong? :)

Thank you !

Antti
Antti
AMD Ryzen Threadripper 2990wx (32c/64t),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP3,Blender2.80,Fusion360,ZBrush,Onyx,Houdini,SubstPnt...
Started: Clarisse 2016/10 (Py 2017/01), Python 2016/11
No business, just fun :)
atnreg
 
Posts: 508
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: Set_expression() works but expression does not activate

Unread postby dcourtois » Wed May 15, 2019 1:46 pm

Hi, if the sigma is highlighted, the expression should be enabled. By default, it just only show the expression in the attribute editor, not the actual result of the expression. In the Attribute Editor's header bar, the sigma can be toggled to show the result. See:

(click on the image to view the animation :)

expressions.gif
User avatar
dcourtois
 
Posts: 45
Joined: Tue Jul 25, 2017 3:15 pm

Re: Set_expression() works but expression does not activate

Unread postby atnreg » Wed May 15, 2019 5:10 pm

Thank you, you confirmed that it should work so I started checking my code (yes I know the sigma value/expression toggle) :)

Please try this code (I have the first part in startup script but it works in script editor as well) which sets the default bound to that expression like this:
Code: Select all
# class defaults
disp_class = ix.application.get_factory().get_classes().get("Displacement")
attr_bound=disp_class.get_attribute("bound")
active=True # see text
attr_bound.set_expression('get_double("front_value")*1.1',0,active)
attr_bound.set_expression('get_double("front_value")*1.1',1,active)
attr_bound.set_expression('get_double("front_value")*1.1',2,active)

# test
disp=ix.cmds.CreateObject("disp","Displacement")
ix.selection.deselect_all()
ix.selection.add(disp)


Here is what happens with active=True when a new Displacement item is created (manually or by code):
-the expression looks fine
-in value mode the value is 0.0 m (which is wrong as the default front value is 1.0 m so the expression should set them to 1.1 m)
-changing the front value does not change the bound values (still 0.0 m)
-if I click on ONE sigma button to disable the expression, ALL three update to last calculated value (this looks strange)
-I turn it (and only that one) back on, it works fine and from that on, and ALL the bound values update correctly

And here with active=False:
-sigma sign is orange i.e. the expression is there but disabled (correct)
-in value mode the values are 0.0 m (correct)
-changing the front value does not change the bound values (still 0.0 m, correct)
-I click each sigmas to activate the expressions, they work as expected

The active=False seems to work as expected and correctly but active=True behaves strangely, what do you think? :mrgreen:

Antti
Antti
AMD Ryzen Threadripper 2990wx (32c/64t),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP3,Blender2.80,Fusion360,ZBrush,Onyx,Houdini,SubstPnt...
Started: Clarisse 2016/10 (Py 2017/01), Python 2016/11
No business, just fun :)
atnreg
 
Posts: 508
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: Set_expression() works but expression does not activate

Unread postby dcourtois » Fri May 17, 2019 4:34 pm

Hi,

There is indeed a bug in expressions when you set them on Class's attributes. I'm working on a fix, and in the meantime you can set the expression on the object instead.
User avatar
dcourtois
 
Posts: 45
Joined: Tue Jul 25, 2017 3:15 pm

Re: Set_expression() works but expression does not activate

Unread postby atnreg » Fri May 17, 2019 8:13 pm

dcourtois wrote:Hi,

There is indeed a bug in expressions when you set them on Class's attributes. I'm working on a fix, and in the meantime you can set the expression on the object instead.


Thank you, so it is supposed to work as default value, that is great, it will give huge benefit, I hope it will not be difficult to fix :mrgreen:
For now I just make the default expression there but as disabled by default, so any Displacement item has it ready, only need is to click on those 3 sigmas. But of course it will be even much cooler when it works without need for extra edit :)
Antti
AMD Ryzen Threadripper 2990wx (32c/64t),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP3,Blender2.80,Fusion360,ZBrush,Onyx,Houdini,SubstPnt...
Started: Clarisse 2016/10 (Py 2017/01), Python 2016/11
No business, just fun :)
atnreg
 
Posts: 508
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland


Return to Scripting