-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFFDControlPointTransfer.ms
More file actions
182 lines (166 loc) · 5.27 KB
/
FFDControlPointTransfer.ms
File metadata and controls
182 lines (166 loc) · 5.27 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
(
global rol_test
try(destroyDialog rol_test)catch()
rollout rol_test "FFD Control points transfer"
(
local pointsDataFile = undefined
local savePath = undefined
local dNETopenFileDialog = dotNetObject "System.Windows.Forms.OpenFileDialog"
dotNetControl btn_Browse "system.windows.forms.button" pos:[5,20] height:20 width:109
edittext et_name "Name:" text:"example_01" width:105 pos:[5,40] labelontop:true
dotNetControl btn_save "system.windows.forms.button" pos:[5,80] height:20 width:60
dotNetControl btn_loadData "system.windows.forms.button" pos:[5,125] height:20 width:60
checkbox chkbox_applyX "X" pos:[5,148]
checkbox chkbox_applyY "Y" pos:[44,148]
checkbox chkbox_applyZ "Z" pos:[82,148]
dotNetControl btn_apply "system.windows.forms.button" pos:[5,175] height:20 width:109
function DotNetButtonsStyle _btn _name =
(
_btn.flatStyle=(dotNetClass "System.Windows.Forms.FlatStyle").System
--Or
-- _btn.flatStyle = _btn.flatStyle.flat
_btn.text = _name
-- _btn.TextAlign = (dotNetClass "System.Drawing.ContentAlignment").middleleft
_btn.backColor = _btn.backColor.black
_btn.foreColor = _btn.backColor.gray
)
function Btn_BrowsePressed =
(
savePath = getSavePath caption:"Select folder" initialDir:"$previews"
)
function Btn_saveFFDCPPressed =
(
infoFile = undefined
-- infoFile = createFile (savePath + "\\" + et_name.text + ".dat")
local topMod = modpanel.getCurrentObject()
if ( substring (topMod as string) 1 3 ) == "FFD" then
(
if (substring (topMod as string) 1 3) == "FFD" then
(
theMaster = topMod[#master]
theCount = theMaster.numsubs
animateAll topMod
for i = 1 to theCount where theMaster[i].value != undefiend do
(
format "%
" (theMaster[i].value) to:infoFile
)
close infoFile
free infoFile
lbl_info.text = "Saved"
)
else
messagebox "The top modifier is not FFD" title:"Invalid Selection"
)
else
messagebox "The selected object does not have applyed FFD modifier" title:"Invalid Selection"
)
function Btn_loadDataPressed =
(
result = dNETopenFileDialog.showDialog()
result.ToString()
if (result.Equals result.OK) do
(
pointsDataFile = (dNETopenFileDialog.fileNames)[1]
btn_loadData.tooltip = pointsDataFile
lbl_info02.text = "Loaded"
)
if (result.Equals result.Cancel) do
pointsDataFile = undefined
)
function Btn_applyPressed =
(
if doesFileExist pointsDataFile do
infoFile = openFile pointsDataFile
local topMod = modpanel.getCurrentObject()
if ( substring (topMod as string) 1 3 ) == "FFD" then
(
theMaster = topMod[#master]
theCount = theMaster.numsubs
animateAll topMod
cnt = 0
while not eof infoFile do
(
cnt += 1
local ffdPpos = readLine infoFile
local ffdPos = (execute ffdPpos)
if chkbox_applyX.state == true and chkbox_applyY.state == true and chkbox_applyZ.state == true then
(theMaster[cnt].value) = ffdPos
else
(
if chkbox_applyX.state == true do
(
local curPos = (theMaster[cnt].value)
curPos.x = ffdPos.x
(theMaster[cnt].value) = curPos
)
if chkbox_applyY.state == true do
(
local curPos = (theMaster[cnt].value)
curPos.y = ffdPos.y
(theMaster[cnt].value) = curPos
)
if chkbox_applyZ.state == true do
(
local curPos = (theMaster[cnt].value)
curPos.z = ffdPos.z
(theMaster[cnt].value) = curPos
)
)
)
close infoFile
free infoFile
)
else
messagebox "Invalid selection" title:"Invalid Selection"
)
on btn_Browse mouseUp senderArg arg do
(
if arg.button==arg.button.left do Btn_BrowsePressed()
)
on btn_Browse KeyUp evnt do
(
if evnt.KeyCode == (dotNetClass "System.Windows.Forms.Keys").Enter do print "Browse is pressed"
)
on btn_save mouseUp senderArg arg do
(
if arg.button==arg.button.left do Btn_saveFFDCPPressed()
)
on btn_save KeyUp evnt do
(
if evnt.KeyCode == (dotNetClass "System.Windows.Forms.Keys").Enter do print "Save is pressed"
)
on btn_loadData mouseUp senderArg arg do
(
if arg.button==arg.button.left do Btn_loadDataPressed()
)
on btn_loadData KeyUp evnt do
(
if evnt.KeyCode == (dotNetClass "System.Windows.Forms.Keys").Enter do print "Load is pressed"
)
on btn_apply mouseUp senderArg arg do
(
if arg.button==arg.button.left do Btn_applyPressed()
)
on btn_apply KeyUp evnt do
(
if evnt.KeyCode == (dotNetClass "System.Windows.Forms.Keys").Enter do print "Apply is pressed"
)
on rol_test open do
(
dNETopenFileDialog.title = "Select file"
dNETopenFileDialog.Multiselect = false
dNETopenFileDialog.Filter = "DAT (*.dat)|*.dat"
dNETopenFileDialog.FilterIndex = 1
dNETopenFileDialog.RestoreDirectory = true
-- dotNet buttons
DotNetButtonsStyle btn_Browse "Browse(save path)"
DotNetButtonsStyle btn_save "Save FFD"
DotNetButtonsStyle btn_loadData "Load FFD"
DotNetButtonsStyle btn_apply "Apply"
--
setFocus btn_Browse
)
)
createdialog rol_test width:119
)