Hi,
I've got two samples for setAttr, getAttr should be same.
There are two different conditions.
For the global expression tab.
import xgenm as xg
import xgenm.xgGlobal as xgg
#Add attribute and expandable tab
de = xgg.DescriptionEditor
attr = "custom_" + "color" + "_" + "hairColor"
key = "collection1 " + attr
xg.addCustomAttr(attr, 'collection1')
de.addAttrExprsLayout(attr, True)
#Update with custom expression
myExpression = """
$freq_fine = 0.200; #0.00,1.00
$freq_coarse = 1.000; # 0,100
$X = 1.000; #0.00,10.00
$Y = 1; #0.00,10.00
$Z = 1; #0.00,10.00
$frequency = ($freq_fine+$freq_coarse) * [$X,$Y,$Z];
$Strength=1.000;
$Contrast = 0.962;
$Color = 0.000; #0,1
$Cnew = choose($Color, noise($P*$frequency), cnoise($P*$frequency))
-> contrast($Contrast);
mix($Cs,$Cnew,$Strength)
"""
#Attr is stored in the palette, check xgDescriptionEditor.getAttr for more details about how to access Description/Palette object
xg.setAttr('custom_color_hairColor', xg.prepForAttribute(myExpression), "collection1", "",'Palette')
#Refresh
de.refresh("Full")
For stored in preview/expression tab
import xgenm as xg
import xgenm.xgGlobal as xgg
import maya.cmds as cmds
cmds.file(new=True, force=True)
cmds.polySphere()
PALETTE = "collection1"
DESCRIPTION = "description1";
PRIMITIVE = "Spline";
GENERATOR = "Random";
RENDERER = "Renderman";
METHOD = "Guides";
GROOMING = False
res = xg.createBindDescription( PALETTE, DESCRIPTION, PRIMITIVE, GENERATOR, RENDERER , METHOD, GROOMING)
#RenderAPIObject
k_RenderAPIRenderer = "Renderman"
k_RenderAPIRendererObj = k_RenderAPIRenderer + "Renderer"
#From noiseE expression in library
myExpression = """
$freq_fine = 0.200; #0.00,1.00
$freq_coarse = 1.000; # 0,100
$X = 1.000; #0.00,10.00
$Y = 1; #0.00,10.00
$Z = 1; #0.00,10.00
$frequency = ($freq_fine+$freq_coarse) * [$X,$Y,$Z];
$Strength=1.000;
$Contrast = 0.962;
$Color = 0.000; #0,1
$Cnew = choose($Color, noise($P*$frequency), cnoise($P*$frequency))
-> contrast($Contrast);
mix($Cs,$Cnew,$Strength)
"""
de = xgg.DescriptionEditor
#please follow the attribute naming format, custom_%typeindroplist%_%attributename%
xg.addCustomAttr('custom_color_hairColor', de.currentPalette(), de.currentDescription(), k_RenderAPIRendererObj)
xg.setAttr('custom_color_hairColor', xg.prepForAttribute(myExpression), "collection1", "description1", k_RenderAPIRendererObj)
de.refresh("Full")
Yours,
Li