-
Notifications
You must be signed in to change notification settings - Fork 0
/
HZCopyPasteAttr.mel
95 lines (92 loc) · 2.4 KB
/
HZCopyPasteAttr.mel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// --------------------------------------------------------------------------
// HZCopyPasteAttr.mel - MEL Script
// --------------------------------------------------------------------------
//
// DESCRIPTION:
// by using this tool you can copy attribute values from selected object to
// own clipboard. if any attribute selected in channelbox this script copy selected ones
// otherwise copy all attributes on channelbox
//
//
// REQUIRES:
// Nothing.
//
//
// USAGE:
// source "HZCopyPasteAttr.mel"; HZCopyAttr(); OR HZPasteAttr();
//
//
// AUTHORS:
// Hamed Zandieh - [email protected]
// Copyright 2010 Hamed Zandieh - All Rights Reserved.
//
// VERSIONS:
// 1.00 - Mar 2010 - Initial Release.
//
// --------------------------------------------------------------------------
global string $HZCopyAttr_HOLDER;
global proc HZCopyAttr()
{
string $objs[] = `ls -sl`;
string $selectedAttrs[] = `channelBox -q -sma mainChannelBox`;
string $allAttrs[] = `listAttr -k`;
if (size($objs) == 0)
{
print "Please Selected at least one object.";
return;
}
if (size($selectedAttrs) > 0)
{
hz_fill_clipboard($objs[0],$selectedAttrs);
} else {
hz_fill_clipboard($objs[0],$allAttrs);
}
print "Attributes Copy Done.";
}
global proc hz_fill_clipboard(string $obj, string $arr[])
{
global string $HZCopyAttr_HOLDER;
$HZCopyAttr_HOLDER = "";
for ($node in $arr)
{
float $objAttr = `getAttr ($obj + "." + $node)`;
$HZCopyAttr_HOLDER += $node + ":" + $objAttr + ",";
}
}
global proc HZPasteAttr()
{
global string $HZCopyAttr_HOLDER;
if ($HZCopyAttr_HOLDER == "")
{
print "Empy Clipboard!";
return;
}
string $objs[] = `ls -sl`;
if (size($objs) == 0)
{
print "Please Selected at least one object.";
return;
}
string $buffer1[];
int $numTokens1 = `tokenize $HZCopyAttr_HOLDER "," $buffer1`;
if ($numTokens1 < 1)
{
print "Invalid Clipboard!!!";
return;
}
for ($attr in $buffer1)
{
string $buffer2[];
int $numTokens2 = `tokenize $attr ":" $buffer2`;
if ($numTokens2 < 2)
{
print "Invalid Clipboard!!!";
return;
}
$isExists = `attributeQuery -node ($objs[0]) -ex ($buffer2[0])`;
$isWritable = `attributeQuery -node ($objs[0]) -w ($buffer2[0])`;
if ($isExists == 0 || $isWritable == 0) continue;
eval("setAttr "+$objs[0]+"."+$buffer2[0]+" "+$buffer2[1]);
}
print "Attributes Paste Done.";
}