Message 1 of 1
Mel Script newbie Questions.(slider, optionmenu for vray)

Not applicable
03-24-2021
05:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Creating a V-ray 'Round edge' script.
But there's a problem.
It was 'slider' and 'option menu'.
It was okay until the UI was created.
But there was a problem connecting the function to the button.
Slider and option menu are the problems.
I don't know what the problem is when I check.
I need your help. please
I'm posting a script here, so please review it.
window -title "Vray Round Edges" -widthHeight 350 200;
columnLayout -adjustableColumn true;
frameLayout -label "Add / Delete" -collapsable true -collapse true;
rowLayout -numberOfColumns 2 -columnWidth2 70 70 -columnAttach 1 "both" 5 -columnAttach 2 "both" 5;
button -l "Add" -c "Add"; button -l "Delete" -c "Delete";
setParent ..;
setParent ..;
frameLayout -label "Round edges" -collapsable true -collapse true;
columnLayout;
checkBox -l "Enable Round Edges" -v 1 -onc "Enable" -ofc "Disable";
text -align left -l "";
text -align left -l "Radius";
floatSliderGrp -field 1 -precision 3 -min 0 -max 1 -fmn -100 -fmx -100 radiusslider;
text -l "";
checkBox -l "Consider Same Objects Only" -v 1 -onc "ConsiderEnable" -ofc "ConsiderDisable";
optionMenuGrp -l "Corners" -cc "CornerMenu" Cmenu;
menuItem -l "Convex and Concave";
menuItem -l "Convex only";
menuItem -l "Concave only";
setParent ..;
setParent ..;
setParent ..;
showWindow;
global proc Add()
{
string $mySelection[] = `ls -sl`;
string $shapes[] = `listRelatives -shapes -path $mySelection`;
for($each in $shapes)
{
vray addAttributesFromGroup $each vray_roundedges 1;
}
}
global proc Delete()
{
string $mySelection[] = `ls -sl`;
string $shapes[] = `listRelatives -shapes -path $mySelection`;
for($each in $shapes)
{
vray addAttributesFromGroup $each vray_roundedges 0;
}
}
global proc Enable()
{
string $mySelection[] = `ls -sl`;
string $shapes[] = `listRelatives -shapes -path $mySelection`;
for($each in $shapes)
{
setAttr ($each + ".vrayRoundEdges") 1;
}
}
global proc Disable()
{
string $mySelection[] = `ls -sl`;
string $shapes[] = `listRelatives -shapes -path $mySelection`;
for($each in $shapes)
{
setAttr ($each + ".vrayRoundEdges") 0;
}
}
global proc ConsiderEnable()
{
string $mySelection[] = `ls -sl`;
string $shapes[] = `listRelatives -shapes -path $mySelection`;
for($each in $shapes)
{
setAttr ($each + ".vrayRoundEdgesConsiderSameObjectsOnly") 1;
}
}
global proc ConsiderDisable()
{
string $mySelection[] = `ls -sl`;
string $shapes[] = `listRelatives -shapes -path $mySelection`;
for($each in $shapes)
{
setAttr ($each + ".vrayRoundEdgesConsiderSameObjectsOnly") 0;
}
}
global proc radiusslider()
{
float $rad = `floatSliderGrp -q -value edgeLength `;
string $mySelection[] = `ls -sl`;
string $shapes[] = `listRelatives -shapes -path $mySelection`;
for($each in $shapes)
{
setAttr ($each + ".vrayRoundEdgesRadius") $rad;
}
}
global proc CornerMenu()
{
string $mySelection[] = `ls -sl`;
string $shapes[] = `listRelatives -shapes -path $mySelection`;
for($each in $shapes)
{
setAttr ($each + ".vrayRoundEdgesCorners") 0;
{
if (`attributeExists vrayRoundEdgesCorners $each`) {
if (`optionMenuGrp -q -v Cmenu` == "Convex and Concave") {
vraySetAttr("$each", "vrayRoundEdgesCorners", "0", "int");
}
else if (`optionMenuGrp -q -v Cmenu` == "Convex Only") {
vraySetAttr("$each", "vrayRoundEdgesCorners", "1", "int");
}
else if (`optionMenuGrp -q -v Cmenu` == "Concave Only") {
vraySetAttr("$each", "vrayRoundEdgesCorners", "2", "int");
}
}
}
}
}