Isotropix Forums

Get the actual value of an attribute vs. "resolved" value

Clarisse Scripting related topics

Get the actual value of an attribute vs. "resolved" value

Unread postby bvz » Thu Apr 02, 2020 7:15 pm

Hi,

We have some broken Clarisse projects in which we have accidentally managed to get expression data into both the "value" portion of a project as well as the "expression" portion.

Example:

Code: Select all
#Isotropix_Serial_Version 1.2

#Isotropix_Clarisse_Version 4
#Isotropix_Clarisse_Project_Version 0.94
TextureStreamedMapFile {
    name "spec_strength_s_file"
    #version 0.98
    #created 1580516999
    #modified 1585808746
    positions "mat_1" 2280 160 2
    colortag "pink"
    projection 6
    uv_translate {
        value 25 0.0 0.0
        expression[] "5*5"
    }
    filename {
        value "$PDIR/../maps/textures/veg_bambooStalkMedium_spec.tx"
        expression "settings_loc = get_context(get_context()) + \"/settings_leaf\"; \n\nget_string(settings_loc + \".spec_color_file\")"
        locked yes
    }
    frame_rate 60
    color_space_auto_detect no
    file_color_space "sRGB"
}


Note how "$PDIR" is in the value section. This is a by-product of some faulty code on our part. But now I need to fix this for a ton of assets.

I thought I would just go through each attribute on a node and check to see if $PDIR was in the value of that attribute. But unfortunately attribute.get_string() returns the resolved value. So instead of returning:

Code: Select all
$PDIR/../maps/textures/veg_bambooStalkMedium_spec.tx


I get:

Code: Select all
/show/showname/veg_bambooStalkMedium_a/../maps/textures/veg_bambooStalkMedium_spec.tx


So I cannot fix these assets.

Is there some way to get that actual string that is stored in the .project file instead of the resolved version?

Thanks.
bvz
 
Posts: 69
Joined: Tue Dec 03, 2013 9:55 am

Re: Get the actual value of an attribute vs. "resolved" valu

Unread postby dboude » Thu Apr 02, 2020 9:15 pm

Hi,

Use get_expression instead of get_string

Cheers ;)
Démian
Isotropix
Technical Artist - Clarisse Specialist
User avatar
dboude
 
Posts: 1407
Joined: Mon Jul 03, 2017 10:51 am

Re: Get the actual value of an attribute vs. "resolved" valu

Unread postby anemoff » Fri Apr 03, 2020 8:57 am

I think you meant get_raw_string.
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Re: Get the actual value of an attribute vs. "resolved" valu

Unread postby bvz2000 » Fri Apr 03, 2020 11:27 pm

Thanks.

Unfortunately this does not work for us.

The problem is that we have some old code that messed up our projects (totally our fault - it is left over code from version 2.0 of Clarisse in which we had to manipulate the paths to files by directly editing the project file).

As a result of this faulty code, we have a lot of situations as described above. There is an expression in the value section as well as an expression in the expression section of the project file. Note the "$PDIR" in the vaue. This is in addition to there being a separate expression.

Specifically, note this part of the project file:

Code: Select all
    filename {
        value "$PDIR/../maps/textures/veg_bambooStalkMedium_spec.tx"
        expression "settings_loc = get_context(get_context()) + \"/settings_leaf\"; \n\nget_string(settings_loc + \".spec_color_file\")"
        locked yes
    }


There is an expression in the value portion as well as an expression in the expression section.

I am trying to write code to repair this error. The way I thought I would do that is to look at each parameter and see if there is data in both the value AND the expression. If so, I would check to see if the value had a variable in it ($PDIR for example). If so, I would simply remove the value and only leave the expression. If not, I would leave the value alone.

The issue is that get_expression gives me the expression that is stored in the "expression" part of the project file. If I use get_string, it gives me the value, but only after $PDIR is evaluated. So in the above case I get:

Code: Select all
/show/showname/veg_bambooStalkMedium_a/../maps/textures/veg_bambooStalkMedium_spec.tx


when what I really want is the raw string value, which is:

Code: Select all
$PDIR/../maps/textures/veg_bambooStalkMedium_spec.tx


So I can't tell if the value is a legitimate value that I should leave alone, or an erroneous expression that should be removed in favor of the real expression on the attribute.

Is there a way to get the raw string of the value (vs. getting the actual expression which is returned from get_expression)? If not, I guess I'll have to edit the .project files directly. That was how we got into this mess in the first place. :)

Thanks!
bvz2000
 
Posts: 415
Joined: Thu Nov 13, 2014 6:05 pm

Re: Get the actual value of an attribute vs. "resolved" valu

Unread postby dboude » Mon Apr 06, 2020 8:48 am

Hi,

Did you see the answer from Anthony ?

get_raw_string()

Let me know if it works.

Cheers
Démian
Isotropix
Technical Artist - Clarisse Specialist
User avatar
dboude
 
Posts: 1407
Joined: Mon Jul 03, 2017 10:51 am

Re: Get the actual value of an attribute vs. "resolved" valu

Unread postby bvz » Tue Apr 07, 2020 5:26 am

I had not seen that. I guess I didn’t refresh my browser before posting. I’ll check that out tomorrow. Thanks!
bvz
 
Posts: 69
Joined: Tue Dec 03, 2013 9:55 am

Re: Get the actual value of an attribute vs. "resolved" valu

Unread postby dboude » Tue Apr 07, 2020 8:44 am

It will do the job. Good luck fixing your files ;)
Démian
Isotropix
Technical Artist - Clarisse Specialist
User avatar
dboude
 
Posts: 1407
Joined: Mon Jul 03, 2017 10:51 am


Return to Scripting
cron