Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

xGen query&set description map-attribute

xGen query&set description map-attribute

asi.sudai
Participant Participant
998 Views
1 Reply
Message 1 of 2

xGen query&set description map-attribute

asi.sudai
Participant
Participant

Hi,

 

Is there a way to query (and also set) the value of a description map attribute?

 

To be specific, I want to query the "Custom Shader Parameter"

In this case, I would love to get the full attribute value of a fur_root_color.
screen.png

 

# Query attribute like this, doesn't work for the map attributes.
import xgenm
xgenm.getAttr('attribute_name','collection_name', 'description_name')

 

0 Likes
Accepted solutions (1)
999 Views
1 Reply
Reply (1)
Message 2 of 2

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

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