-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoxMaker.jsx
167 lines (141 loc) · 5.32 KB
/
BoxMaker.jsx
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// Made by rlarhsid. 24.09.21
// Play EZ2ON REBOOT: R! It's the best game I've ever played.
(function (thisObj) {
function BoxMaker(thisObj) {
var myPanel =
thisObj instanceof Panel
? thisObj
: new Window("palette", "BoxMaker", undefined, { resizeable: true });
myPanel.minimumSize = [300, 150];
myPanel.preferredSize = [300, 150];
myPanel.alignChildren = ["left", "top"]; // Left align children
var XInputGrp = myPanel.add("group", undefined, "X Length Group");
XInputGrp.orientation = "row";
XInputGrp.alignChildren = ["right", "center"]; // Align right
XInputGrp.add("statictext", undefined, "X 너비: ").preferredSize = [70, 30];
var XInput = XInputGrp.add("edittext", undefined, "0");
XInput.preferredSize.width = 45;
XInput.preferredSize.height = 30;
var YInputGrp = myPanel.add("group", undefined, "Y Length Group");
YInputGrp.orientation = "row";
YInputGrp.alignChildren = ["right", "center"]; // Align right
YInputGrp.add("statictext", undefined, "Y 너비: ").preferredSize = [70, 30];
var YInput = YInputGrp.add("edittext", undefined, "0");
YInput.preferredSize.width = 45;
YInput.preferredSize.height = 30;
var ZInputGrp = myPanel.add("group", undefined, "Z Length Group");
ZInputGrp.orientation = "row";
ZInputGrp.alignChildren = ["right", "center"]; // Align right
ZInputGrp.add("statictext", undefined, "Z 너비: ").preferredSize = [70, 30];
var ZInput = ZInputGrp.add("edittext", undefined, "0");
ZInput.preferredSize.width = 45;
ZInput.preferredSize.height = 25;
var runButton = myPanel.add("button", undefined, "PlumSnack");
runButton.alignChildren = ["center", "center"];
runButton.preferredSize = [120, 40]; // Button size
runButton.onClick = function () {
var XLength = parseFloat(XInput.text);
var YLength = parseFloat(YInput.text);
var ZLength = parseFloat(ZInput.text);
if (
isNaN(XLength) ||
XLength <= 0 ||
isNaN(YLength) ||
YLength <= 0 ||
isNaN(ZLength) ||
ZLength <= 0
) {
alert("그런 숫자?");
return;
}
var XHalfLength = XLength / 2;
var YHalfLength = YLength / 2;
var ZHalfLength = ZLength / 2;
var comp = app.project.activeItem;
if (!(comp instanceof CompItem)) {
alert("컴포지션 선택도 안하는 그런 행동?");
return;
}
app.beginUndoGroup("Create Box");
var shapeLayers = [
createShapeLayer(comp, "Layer A", [ZLength, YLength], [1, 0, 0]),
createShapeLayer(comp, "Layer B", [ZLength, YLength], [1, 0, 0]),
createShapeLayer(comp, "Layer C", [XLength, ZLength], [0, 0, 1]),
createShapeLayer(comp, "Layer D", [XLength, ZLength], [0, 0, 1]),
createShapeLayer(comp, "Layer E", [XLength, YLength], [0, 1, 0]),
createShapeLayer(comp, "Layer F", [XLength, YLength], [0, 1, 0]),
];
var nullLayer = comp.layers.addNull();
nullLayer.name = "NULCTRL";
nullLayer.label = 1;
nullLayer.threeDLayer = true;
for (var i = 0; i < shapeLayers.length; i++) {
shapeLayers[i].parent = nullLayer;
}
shapeLayers[0]
.property("ADBE Transform Group")
.property("ADBE Position")
.setValue([XHalfLength, 0, 0]);
shapeLayers[0]
.property("ADBE Transform Group")
.property("ADBE Rotate Y")
.setValue(90);
shapeLayers[1]
.property("ADBE Transform Group")
.property("ADBE Position")
.setValue([-XHalfLength, 0, 0]);
shapeLayers[1]
.property("ADBE Transform Group")
.property("ADBE Rotate Y")
.setValue(90);
shapeLayers[2]
.property("ADBE Transform Group")
.property("ADBE Position")
.setValue([0, YHalfLength, 0]);
shapeLayers[2]
.property("ADBE Transform Group")
.property("ADBE Rotate X")
.setValue(90);
shapeLayers[3]
.property("ADBE Transform Group")
.property("ADBE Position")
.setValue([0, -YHalfLength, 0]);
shapeLayers[3]
.property("ADBE Transform Group")
.property("ADBE Rotate X")
.setValue(90);
shapeLayers[4]
.property("ADBE Transform Group")
.property("ADBE Position")
.setValue([0, 0, ZHalfLength]);
shapeLayers[5]
.property("ADBE Transform Group")
.property("ADBE Position")
.setValue([0, 0, -ZHalfLength]);
alert("펑!! (작업 끝나는 소리)");
app.endUndoGroup();
};
if (myPanel instanceof Window) {
myPanel.center();
myPanel.show();
} else {
myPanel.layout.layout(true);
myPanel.layout.resize();
}
function createShapeLayer(comp, name, size, color) {
var shapeLayer = comp.layers.addShape();
shapeLayer.name = name;
var rectGroup = shapeLayer
.property("ADBE Root Vectors Group")
.addProperty("ADBE Vector Shape - Rect");
rectGroup.property("ADBE Vector Rect Size").setValue(size);
var fillGroup = shapeLayer
.property("ADBE Root Vectors Group")
.addProperty("ADBE Vector Graphic - Fill");
fillGroup.property("ADBE Vector Fill Color").setValue(color);
shapeLayer.threeDLayer = true;
return shapeLayer;
}
}
BoxMaker(thisObj);
})(this);