[Closed] setFaceMatID of modifiers[#edit_mesh]
first. English is not good. very very sorry!!
I hope you understand.
I want to automatic change the MaterialID of select obj.
i have a modifiers [#edit mesh] on base oject (line).
but i can see the error
setFaceMatID $ 1 3
– Runtime error: Cannot change mesh with modifiers present: Line
plz help me
Why Edit_Mesh and not Edit_Poly?
This is for EditPoly modifier.
(
local matId = 10
local ep = modPanel.getCurrentObject()
ep.materialIDToSet = matId-1
ep.SetOperation #SetMaterial
)
Thank you for answer.
It must be applied to all selected objects.
So I have to look at every case. (mesh , poly , modifier[mesh] , modifier[poly])
I still can not MaterialID of modifier[mesh]
are you referring to the error message:
– Runtime error: Cannot change mesh with modifiers present: Line
if I’m reading you right, are you ‘looking’ for the error message after…‘line’ (as in code line 123…etc ?) Well that’s a bit confusing because your geo is a LINE ! (bloody coders…just kidding ppl…)
- Let’s do a simple test, If you were using a Plane, try your script, it will return – Runtime error: Mesh operation on non-mesh: Plane
- continue with the test, convert your Plane to Editable Mesh, run the script again, it works perfectly !!!
- now here’s the clincher, we know it just worked a second ago, now add an Edit Mesh modifier on your ‘mesh’, run the script again, it returns:
– Runtime error: Cannot change mesh with modifiers present: Editable Mesh
Conclusion: it CANNOT work on non-collapsed meshes…ie. the orig message makes total sense…it will not work with modifiers…you have to collapse your geo to Editable Mesh
very very think you vusta.
I have to non-collapsed it to fix it later.
anyways I have to think about other ways.
it’s not very elegant but you could do it something like this…
fn set_material_id mobj faces matid = if mobj.modifiers[#Edit_Mesh] != undefined do
(
setCommandPanelTaskMode mode:#modify;
setfaceselection mobj mobj.modifiers[#Edit_Mesh] faces;
setSelectionLevel mobj.modifiers[#Edit_Mesh] #face;
modPanel.addModToSelection (materialModifier materialID:matid);
)
set_material_id $ #{193..240} 5;
it would be pretty simple to add support for other object types
And something even less elegant.
struct editMeshModOps (
fn getEditMeshModMaterialIDSpinnerHWND = (
windows_getHWNDData = windows.getHWNDData
local hwnd = undefined
for w in UIAccessor.GetChildWindows (windows.getMAXHWND()) while hwnd == undefined where (d = windows_getHWNDData w)[5] == "Set ID:" do hwnd = UIAccessor.GetPrevWindow d[1]
hwnd
),
fn resetSpinner hwnd = (
windows.sendMessage hwnd 0x204 0 0
windows.sendMessage hwnd 0x205 0 0
),
fn setSpinner hwnd val = (
for i=1 to val-1 do (
windows.sendMessage hwnd 0x201 0 0
windows.sendMessage hwnd 0x202 0 0
)
),
debugMessages = false,
fn setValue val = (
modif = modPanel.getCurrentObject()
if isKindOf modif Edit_Mesh then (
if subobjectlevel > 2 then (
local hwnd = getEditMeshModMaterialIDSpinnerHWND()
try (
resetSpinner hwnd
setSpinner hwnd val
return true
) catch (
if debugMessages do format "Error. SendMessage Set ID failed.
"
)
) else ( if debugMessages do format "Error. Incorrect subobject level.
" )
) else ( if debugMessages do format "Not an Edit Mesh Mod
")
false
)
)
em = editMeshModOps()
em.setvalue (random 1 5)
more elegant solution if it’s all the same ID
fn set_line_mesh_materialID spline_shape spline matID =
(
spline_shape.render_useViewportSettings = false; -- forces notifydependents
nsegs = numSegments spline_shape spline;
for s = 1 to nsegs do setMaterialID spline_shape spline s matID;
spline_shape.render_useViewportSettings = true; -- forces notifydependents so the edit mesh updates
)
though maybe quite slow on complex shapes if the code is rebuilding the mesh from scratch.
very very thankyou Serejah
i think it’s perfectly work.
but don’t understand because i know little maxscript.
i have myscript like trash. myscript add the your script. but i can’t that.
I hate to make my trash public. I want to hide in a rat hole. (i talk to again very little english, and i hope you understand)
plz help me. Bounce
———————————————————- my trash ———————————————————-
rollout CBTMaterialLibrary “CBT Material Library”
(
local IconCount = 0
local readlinearray = #()
local ReadButtonImage = #()
local ButtonArray=#()
local ButtontextArray=#()
fn PageButtonActionFn PBBum=
(
if PBBum == 1 do
(
CBTMaterialLibrary.MatPageBt01.enabled = false
)
if PBBum == 2 do
(
CBTMaterialLibrary.MatPageBt02.enabled = false
)
if PBBum == 3 do
(
CBTMaterialLibrary.MatPageBt03.enabled = false
)
if PBBum == 4 do
(
CBTMaterialLibrary.MatPageBt04.enabled = false
)
CBTMaterialLibrary.MatPageBt02.checked = false
CBTMaterialLibrary.MatPageBt03.checked = false
CBTMaterialLibrary.MatPageBt04.checked = false
)
fn SelcSetIdFN _obj Btnum =
(
local _pageNum = 1
if CBTMaterialLibrary.MatPageBt01.state ==true do
(
_pageNum = 0
)
if CBTMaterialLibrary.MatPageBt02.state ==true do
(
_pageNum = 50
)
if CBTMaterialLibrary.MatPageBt03.state ==true do
(
_pageNum = 100
)
if CBTMaterialLibrary.MatPageBt04.state ==true do
(
_pageNum = 150
)
if _obj != undefined then
(
if _obj.count == 1 then
(
case (classof _obj[1]) of
(
Editable_mesh :
(
if _obj[1].modifiers[1] == undefined then
(
if subobjectLevel == 0 do
(
for n=1 to getNumFaces _obj[1] do --
(
setFaceMatID _obj[1] n ((Btnum as integer)+(_pageNum as integer))
)
)
if subobjectLevel == 4 or subobjectLevel == 5 do
(
_selecFace = getFaceSelection _obj[1] as array
for n=1 to _selecFace.count do
(
setFaceMatID _obj[1] _selecFace[n] ((Btnum as integer)+(_pageNum as integer))
)
if CBTMaterialLibrary.FaceUnselecCheckBox.state == true do
(
subobjectLevel = 0
)
)
update _obj[1]
)
else
(
)
)
Editable_Poly :
(
if subobjectLevel == 0 do
(
for n=1 to polyop.getNumFaces _obj[1] do --
(
polyop.setFaceMatID _obj[1] n Btnum
)
)
if subobjectLevel == 4 or subobjectLevel == 5 do
(
_selecFace = polyop.getFaceSelection _obj[1] as array
for n=1 to _selecFace.count do
(
polyop.setFaceMatID _obj[1] _selecFace[n] ((Btnum as integer)+(_pageNum as integer))
)
if CBTMaterialLibrary.FaceUnselecCheckBox.state == true do
(
subobjectLevel = 0
)
)
update _obj[1]
)
PolyMeshObject :
(
)
Edit_Poly :
(
)
line :
(
messagebox "line 입니다."
)
SplineShape :
(
messagebox "SplineShape 입니다."
)
)
)
else
(
for _ObjNum = 1 to _obj.count do
(
_faceAllNum = getNumFaces _obj[_ObjNum]
if _obj[_ObjNum].modifiers[1] == undefined then
(
for _faceNum = 1 to _faceAllNum do
(
case (classof _obj[_ObjNum]) of
(
Editable_mesh : setFaceMatID _obj[_ObjNum] _faceNum ((Btnum as integer)+(_pageNum as integer))
Editable_Poly : polyop.setFaceMatID _obj[_ObjNum] _faceNum ((Btnum as integer)+(_pageNum as integer))
)
)
)
else
(
)
)
for n=1 to _obj.count do
(
if _obj[n].modifiers[1] == undefined then
(
update _obj[n]
)
)
)
)
else
(
messagebox "변경할 오브젝트를 선택하시오"
)
)
–===================================================================== U I =====================================================================–
button LibraryUrlOpen “Open” offset:[-274,0]
group “”
(
checkbox FaceUnselecCheckBox “모드 해제” checked:false offset:[0,-5]
)
group “Material Library”
(
checkbutton MatPageBt01 “1” checked:true offset:[-60,0] across:4 tooltip:“1 page”
checkbutton MatPageBt02 “2” offset:[-180,0] tooltip:“2 page”
checkbutton MatPageBt03 “3” offset:[-300,0] tooltip:“3 page”
checkbutton MatPageBt04 “4” offset:[-420,0] tooltip:“4 page”
BUtton BT1 "1" width:50 height:50 offset:[-7,0] across:10
BUtton BT2 "2" width:50 height:50 offset:[-7,0]
BUtton BT3 "3" width:50 height:50 offset:[-7,0]
BUtton BT4 "4" width:50 height:50 offset:[-7,0]
BUtton BT5 "5" width:50 height:50 offset:[-7,0]
BUtton BT6 "6" width:50 height:50 offset:[7,0]
BUtton BT7 "7" width:50 height:50 offset:[7,0]
BUtton BT8 "8" width:50 height:50 offset:[7,0]
BUtton BT9 "9" width:50 height:50 offset:[7,0]
BUtton BT10 "10" width:50 height:50 offset:[7,0]
edittext SoonMTex1 width:53 offset:[-7,0]across:10
edittext SoonMTex2 width:53 offset:[-7,0]
edittext SoonMTex3 width:53 offset:[-7,0]
edittext SoonMTex4 width:53 offset:[-7,0]
edittext SoonMTex5 width:53 offset:[-7,0]
edittext SoonMTex6 width:53 offset:[7,0]
edittext SoonMTex7 width:53 offset:[7,0]
edittext SoonMTex8 width:53 offset:[7,0]
edittext SoonMTex9 width:53 offset:[7,0]
edittext SoonMTex10 width:53 offset:[7,0]
BUtton BT11 "11" width:50 height:50 offset:[-7,0] across:10
BUtton BT12 "12" width:50 height:50 offset:[-7,0]
BUtton BT13 "13" width:50 height:50 offset:[-7,0]
BUtton BT14 "14" width:50 height:50 offset:[-7,0]
BUtton BT15 "15" width:50 height:50 offset:[-7,0]
BUtton BT16 "16" width:50 height:50 offset:[7,0]
BUtton BT17 "17" width:50 height:50 offset:[7,0]
BUtton BT18 "18" width:50 height:50 offset:[7,0]
BUtton BT19 "19" width:50 height:50 offset:[7,0]
BUtton BT20 "20" width:50 height:50 offset:[7,0]
edittext SoonMTex11 width:53 offset:[-7,0] across:10
edittext SoonMTex12 width:53 offset:[-7,0]
edittext SoonMTex13 width:53 offset:[-7,0]
edittext SoonMTex14 width:53 offset:[-7,0]
edittext SoonMTex15 width:53 offset:[-7,0]
edittext SoonMTex16 width:53 offset:[7,0]
edittext SoonMTex17 width:53 offset:[7,0]
edittext SoonMTex18 width:53 offset:[7,0]
edittext SoonMTex19 width:53 offset:[7,0]
edittext SoonMTex20 width:53 offset:[7,0]
BUtton BT21 "21" width:50 height:50 offset:[-7,0] across:10
BUtton BT22 "22" width:50 height:50 offset:[-7,0]
BUtton BT23 "23" width:50 height:50 offset:[-7,0]
BUtton BT24 "24" width:50 height:50 offset:[-7,0]
BUtton BT25 "25" width:50 height:50 offset:[-7,0]
BUtton BT26 "26" width:50 height:50 offset:[7,0]
BUtton BT27 "27" width:50 height:50 offset:[7,0]
BUtton BT28 "28" width:50 height:50 offset:[7,0]
BUtton BT29 "29" width:50 height:50 offset:[7,0]
BUtton BT30 "30" width:50 height:50 offset:[7,0]
edittext SoonMTex21 width:53 offset:[-7,0] across:10
edittext SoonMTex22 width:53 offset:[-7,0]
edittext SoonMTex23 width:53 offset:[-7,0]
edittext SoonMTex24 width:53 offset:[-7,0]
edittext SoonMTex25 width:53 offset:[-7,0]
edittext SoonMTex26 width:53 offset:[7,0]
edittext SoonMTex27 width:53 offset:[7,0]
edittext SoonMTex28 width:53 offset:[7,0]
edittext SoonMTex29 width:53 offset:[7,0]
edittext SoonMTex30 width:53 offset:[7,0]
BUtton BT31 "31" width:50 height:50 offset:[-7,0] across:10
BUtton BT32 "32" width:50 height:50 offset:[-7,0]
BUtton BT33 "33" width:50 height:50 offset:[-7,0]
BUtton BT34 "34" width:50 height:50 offset:[-7,0]
BUtton BT35 "35" width:50 height:50 offset:[-7,0]
BUtton BT36 "36" width:50 height:50 offset:[7,0]
BUtton BT37 "37" width:50 height:50 offset:[7,0]
BUtton BT38 "38" width:50 height:50 offset:[7,0]
BUtton BT39 "39" width:50 height:50 offset:[7,0]
BUtton BT40 "40" width:50 height:50 offset:[7,0]
edittext SoonMTex31 width:53 offset:[-7,0] across:10
edittext SoonMTex32 width:53 offset:[-7,0]
edittext SoonMTex33 width:53 offset:[-7,0]
edittext SoonMTex34 width:53 offset:[-7,0]
edittext SoonMTex35 width:53 offset:[-7,0]
edittext SoonMTex36 width:53 offset:[7,0]
edittext SoonMTex37 width:53 offset:[7,0]
edittext SoonMTex38 width:53 offset:[7,0]
edittext SoonMTex39 width:53 offset:[7,0]
edittext SoonMTex40 width:53 offset:[7,0]
BUtton BT41 "41" width:50 height:50 offset:[-7,0] across:10
BUtton BT42 "42" width:50 height:50 offset:[-7,0]
BUtton BT43 "43" width:50 height:50 offset:[-7,0]
BUtton BT44 "44" width:50 height:50 offset:[-7,0]
BUtton BT45 "45" width:50 height:50 offset:[-7,0]
BUtton BT46 "46" width:50 height:50 offset:[7,0]
BUtton BT47 "47" width:50 height:50 offset:[7,0]
BUtton BT48 "48" width:50 height:50 offset:[7,0]
BUtton BT49 "49" width:50 height:50 offset:[7,0]
BUtton BT50 "50" width:50 height:50 offset:[7,0]
edittext SoonMTex41 width:53 offset:[-7,0] across:10
edittext SoonMTex42 width:53 offset:[-7,0]
edittext SoonMTex43 width:53 offset:[-7,0]
edittext SoonMTex44 width:53 offset:[-7,0]
edittext SoonMTex45 width:53 offset:[-7,0]
edittext SoonMTex46 width:53 offset:[7,0]
edittext SoonMTex47 width:53 offset:[7,0]
edittext SoonMTex48 width:53 offset:[7,0]
edittext SoonMTex49 width:53 offset:[7,0]
edittext SoonMTex50 width:53 offset:[7,0]
)
–==========================================================================================================================================
on CBTMaterialLibrary open do
(
CBTMaterialLibrary.MatPageBt01.enabled = false
for n=1 to 50 do
(
appendIfUnique ButtonArray (execute ("CBTMaterialLibrary.BT"+(n as string)))
appendIfUnique ButtontextArray (execute ("CBTMaterialLibrary.SoonMTex"+(n as string)))
)
)
on CBTMaterialLibrary close do
(
)
on LibraryUrlOpen pressed do
(
readlinearray = #()
IconCount = 0
for n=1 to 50 do
(
ButtonArray.images = undefined
)
BtFilename = openfile (GetOpenFilename caption:"Open Material Script initial value.txt:" types:"Text(*.txt)") mode:"r+"
if BtFilename != undefined do
(
_StrArray = (filterstring ((BtFilename ) as string) ",\\,:")
_ReStrArray = ""
deleteitem _StrArray 1
deleteitem _StrArray _StrArray.count
append _ReStrArray "\\\\"
for n=1 to _StrArray.count do
(
append _ReStrArray (_StrArray[n] as string)
if _StrArray.count != n do
(
append _ReStrArray "\\"
)
)
while not eof BtFilename do
(
r= readline BtFilename
_r = #()
_r = filterString r "_"
insertItem r readlinearray (_r[1] as integer)
IconCount += 1
_BmpFile = (_ReStrArray as string)+"\Icon_"+(_r[1] as string)+".bmp"
insertItem (_BmpFile) ReadButtonImage (_r[1] as integer)
if (_r[1] as integer) < 51 do
(
ButtonArray[(_r[1] as integer)].images = #(_BmpFile,undefined,1,1,1,1,1)
ButtonArray[(_r[1] as integer)].tooltip = readlinearray[(_r[1] as integer)]
CBTMaterialLibrary.ButtontextArray[(_r[1] as integer)].text = r
)
)
close BtFilename
)
)
on MatPageBt01 changed pressed do
(
CBTMaterialLibrary.MatPageBt02.checked = false
CBTMaterialLibrary.MatPageBt03.checked = false
CBTMaterialLibrary.MatPageBt04.checked = false
CBTMaterialLibrary.MatPageBt01.enabled = false
CBTMaterialLibrary.MatPageBt02.enabled = true
CBTMaterialLibrary.MatPageBt03.enabled = true
CBTMaterialLibrary.MatPageBt04.enabled = true
for n=1 to 50 do
(
ButtonArray[n].text = n as string
if readlinearray[n] != undefined then
(
ButtonArray[n as integer].images = #(((ReadButtonImage[n]) as string) , undefined , 1,1,1,1,1 )
ButtonArray[n as integer].tooltip = readlinearray[n] as string
CBTMaterialLibrary.ButtontextArray[n].text = readlinearray[n] as string
)
else
(
ButtonArray[n as integer].images = undefined
ButtonArray[n as integer].tooltip = ""
CBTMaterialLibrary.ButtontextArray[n].text = ""
)
)
)
on MatPageBt02 changed theState do
(
CBTMaterialLibrary.MatPageBt01.checked = false
CBTMaterialLibrary.MatPageBt03.checked = false
CBTMaterialLibrary.MatPageBt04.checked = false
CBTMaterialLibrary.MatPageBt01.enabled = true
CBTMaterialLibrary.MatPageBt02.enabled = false
CBTMaterialLibrary.MatPageBt03.enabled = true
CBTMaterialLibrary.MatPageBt04.enabled = true
for n=1 to 50 do
(
ButtonArray[n].text = (n+50) as string
if readlinearray[n+50] != undefined then
(
ButtonArray[n as integer].images = #(((ReadButtonImage[n+50]) as string) , undefined , 1,1,1,1,1 )
ButtonArray[n as integer].tooltip = readlinearray[n+50] as string
CBTMaterialLibrary.ButtontextArray[n].text = readlinearray[n+50] as string
)
else
(
ButtonArray[n as integer].images = undefined
ButtonArray[n as integer].tooltip = ""
CBTMaterialLibrary.ButtontextArray[n].text = ""
)
)
)
on MatPageBt03 changed theState do
(
CBTMaterialLibrary.MatPageBt01.checked = false
CBTMaterialLibrary.MatPageBt02.checked = false
CBTMaterialLibrary.MatPageBt04.checked = false
CBTMaterialLibrary.MatPageBt01.enabled = true
CBTMaterialLibrary.MatPageBt02.enabled = true
CBTMaterialLibrary.MatPageBt03.enabled = false
CBTMaterialLibrary.MatPageBt04.enabled = true
for n=1 to 50 do
(
ButtonArray[n].text = (n+100) as string
if readlinearray[n+100] != undefined then
(
ButtonArray[n as integer].images = #(((ReadButtonImage[n+100]) as string) , undefined , 1,1,1,1,1 )
ButtonArray[n as integer].tooltip = readlinearray[n+100] as string
CBTMaterialLibrary.ButtontextArray[n].text = readlinearray[n+100] as string
)
else
(
ButtonArray[n as integer].images = undefined
ButtonArray[n as integer].tooltip = ""
CBTMaterialLibrary.ButtontextArray[n].text = ""
)
)
)
on MatPageBt04 changed theState do
(
CBTMaterialLibrary.MatPageBt01.checked = false
CBTMaterialLibrary.MatPageBt02.checked = false
CBTMaterialLibrary.MatPageBt03.checked = false
CBTMaterialLibrary.MatPageBt01.enabled = true
CBTMaterialLibrary.MatPageBt02.enabled = true
CBTMaterialLibrary.MatPageBt03.enabled = true
CBTMaterialLibrary.MatPageBt04.enabled = false
for n=1 to 50 do
(
ButtonArray[n].text = (n+150) as string
if readlinearray[n+150] != undefined then
(
ButtonArray[n as integer].images = #(((ReadButtonImage[n+150]) as string) , undefined , 1,1,1,1,1 )
ButtonArray[n as integer].tooltip = readlinearray[n+150] as string
CBTMaterialLibrary.ButtontextArray[n].text = readlinearray[n+150] as string
)
else
(
ButtonArray[n as integer].images = undefined
ButtonArray[n as integer].tooltip = ""
CBTMaterialLibrary.ButtontextArray[n].text = ""
)
)
)
on BT1 pressed do SelcSetIdFN (selection as array) 1
on BT2 pressed do SelcSetIdFN (selection as array) 2
on BT3 pressed do SelcSetIdFN (selection as array) 3
on BT4 pressed do SelcSetIdFN (selection as array) 4
on BT5 pressed do SelcSetIdFN (selection as array) 5
on BT6 pressed do SelcSetIdFN (selection as array) 6
on BT7 pressed do SelcSetIdFN (selection as array) 7
on BT8 pressed do SelcSetIdFN (selection as array) 8
on BT9 pressed do SelcSetIdFN (selection as array) 9
on BT10 pressed do SelcSetIdFN (selection as array) 10
on BT11 pressed do SelcSetIdFN (selection as array) 11
on BT12 pressed do SelcSetIdFN (selection as array) 12
on BT13 pressed do SelcSetIdFN (selection as array) 13
on BT14 pressed do SelcSetIdFN (selection as array) 14
on BT15 pressed do SelcSetIdFN (selection as array) 15
on BT16 pressed do SelcSetIdFN (selection as array) 16
on BT17 pressed do SelcSetIdFN (selection as array) 17
on BT18 pressed do SelcSetIdFN (selection as array) 18
on BT19 pressed do SelcSetIdFN (selection as array) 19
on BT20 pressed do SelcSetIdFN (selection as array) 20
on BT21 pressed do SelcSetIdFN (selection as array) 21
on BT22 pressed do SelcSetIdFN (selection as array) 22
on BT23 pressed do SelcSetIdFN (selection as array) 23
on BT24 pressed do SelcSetIdFN (selection as array) 24
on BT25 pressed do SelcSetIdFN (selection as array) 25
on BT26 pressed do SelcSetIdFN (selection as array) 26
on BT27 pressed do SelcSetIdFN (selection as array) 27
on BT28 pressed do SelcSetIdFN (selection as array) 28
on BT29 pressed do SelcSetIdFN (selection as array) 29
on BT30 pressed do SelcSetIdFN (selection as array) 30
on BT31 pressed do SelcSetIdFN (selection as array) 31
on BT32 pressed do SelcSetIdFN (selection as array) 32
on BT33 pressed do SelcSetIdFN (selection as array) 33
on BT34 pressed do SelcSetIdFN (selection as array) 34
on BT35 pressed do SelcSetIdFN (selection as array) 35
on BT36 pressed do SelcSetIdFN (selection as array) 36
on BT37 pressed do SelcSetIdFN (selection as array) 37
on BT38 pressed do SelcSetIdFN (selection as array) 38
on BT39 pressed do SelcSetIdFN (selection as array) 39
on BT40 pressed do SelcSetIdFN (selection as array) 40
on BT41 pressed do SelcSetIdFN (selection as array) 41
on BT42 pressed do SelcSetIdFN (selection as array) 42
on BT43 pressed do SelcSetIdFN (selection as array) 43
on BT44 pressed do SelcSetIdFN (selection as array) 44
on BT45 pressed do SelcSetIdFN (selection as array) 45
on BT46 pressed do SelcSetIdFN (selection as array) 46
on BT47 pressed do SelcSetIdFN (selection as array) 47
on BT48 pressed do SelcSetIdFN (selection as array) 48
on BT49 pressed do SelcSetIdFN (selection as array) 49
on BT50 pressed do SelcSetIdFN (selection as array) 50
)
createdialog CBTMaterialLibrary width:600 pos:[400,200] –pos:[700,750]
If you define all your functions after UI then you don’t need to reference your rollout all the time
little example
try (destroydialog X ) catch ()
rollout X "Fn before UI" (
fn getBtnState = (
format ">>> %
" btn.enabled -- x.btn.enabled will work just fine
)
button btn "button"
on btn pressed do getBtnState()
)
createDialog X pos:[100,100]
try (destroydialog Xx ) catch ()
rollout Xx "Fn after UI" (
button btn "button"
fn getBtnState = (
format ">>> %
" btn.enabled
)
on btn pressed do getBtnState()
)
createDialog Xx pos:[270,100]
… and your edited code.
------------------------------------------------------- my trash ----------------------------------------------------------
rollout CBTMaterialLibrary "CBT Material Library"
(
struct editMeshModOps (
fn getEditMeshModMaterialIDSpinnerHWND = (
windows_getHWNDData = windows.getHWNDData
local hwnd = undefined
for w in UIAccessor.GetChildWindows (windows.getMAXHWND()) while hwnd == undefined where (d = windows_getHWNDData w)[5] == "Set ID:" do hwnd = UIAccessor.GetPrevWindow d[1]
hwnd
),
fn resetSpinner hwnd = (
windows.sendMessage hwnd 0x204 0 0
windows.sendMessage hwnd 0x205 0 0
),
fn setSpinner hwnd val = (
for i=1 to val-1 do (
windows.sendMessage hwnd 0x201 0 0
windows.sendMessage hwnd 0x202 0 0
)
),
debugMessages = false,
fn setValue val = (
modif = modPanel.getCurrentObject()
if isKindOf modif Edit_Mesh then (
if subobjectlevel > 2 then (
local hwnd = getEditMeshModMaterialIDSpinnerHWND()
try (
resetSpinner hwnd
setSpinner hwnd val
return true
) catch (
if debugMessages do format "Error. SendMessage Set ID failed.
"
)
) else ( if debugMessages do format "Error. Incorrect subobject level.
" )
) else ( if debugMessages do format "Not an Edit Mesh Mod
")
false
)
)
local editMeshMod = editMeshModOps()
local IconCount = 0
local readlinearray = #()
local ReadButtonImage = #()
local ButtonArray = #()
local ButtontextArray = #()
--================================================== =================== U I ================================================== ===================--
button LibraryUrlOpen "Open" offset:[-274,0]
group ""
(
checkbox FaceUnselecCheckBox "모드 해제" checked:false offset:[0,-5]
)
group "Material Library"
(
checkbutton MatPageBt01 "1" checked:true offset:[-60,0] across:4 tooltip:"1 page"
checkbutton MatPageBt02 "2" offset:[-180,0] tooltip:"2 page"
checkbutton MatPageBt03 "3" offset:[-300,0] tooltip:"3 page"
checkbutton MatPageBt04 "4" offset:[-420,0] tooltip:"4 page"
BUtton BT1 "1" width:50 height:50 offset:[-7,0] across:10
BUtton BT2 "2" width:50 height:50 offset:[-7,0]
BUtton BT3 "3" width:50 height:50 offset:[-7,0]
BUtton BT4 "4" width:50 height:50 offset:[-7,0]
BUtton BT5 "5" width:50 height:50 offset:[-7,0]
BUtton BT6 "6" width:50 height:50 offset:[7,0]
BUtton BT7 "7" width:50 height:50 offset:[7,0]
BUtton BT8 "8" width:50 height:50 offset:[7,0]
BUtton BT9 "9" width:50 height:50 offset:[7,0]
BUtton BT10 "10" width:50 height:50 offset:[7,0]
edittext SoonMTex1 width:53 offset:[-7,0]across:10
edittext SoonMTex2 width:53 offset:[-7,0]
edittext SoonMTex3 width:53 offset:[-7,0]
edittext SoonMTex4 width:53 offset:[-7,0]
edittext SoonMTex5 width:53 offset:[-7,0]
edittext SoonMTex6 width:53 offset:[7,0]
edittext SoonMTex7 width:53 offset:[7,0]
edittext SoonMTex8 width:53 offset:[7,0]
edittext SoonMTex9 width:53 offset:[7,0]
edittext SoonMTex10 width:53 offset:[7,0]
BUtton BT11 "11" width:50 height:50 offset:[-7,0] across:10
BUtton BT12 "12" width:50 height:50 offset:[-7,0]
BUtton BT13 "13" width:50 height:50 offset:[-7,0]
BUtton BT14 "14" width:50 height:50 offset:[-7,0]
BUtton BT15 "15" width:50 height:50 offset:[-7,0]
BUtton BT16 "16" width:50 height:50 offset:[7,0]
BUtton BT17 "17" width:50 height:50 offset:[7,0]
BUtton BT18 "18" width:50 height:50 offset:[7,0]
BUtton BT19 "19" width:50 height:50 offset:[7,0]
BUtton BT20 "20" width:50 height:50 offset:[7,0]
edittext SoonMTex11 width:53 offset:[-7,0] across:10
edittext SoonMTex12 width:53 offset:[-7,0]
edittext SoonMTex13 width:53 offset:[-7,0]
edittext SoonMTex14 width:53 offset:[-7,0]
edittext SoonMTex15 width:53 offset:[-7,0]
edittext SoonMTex16 width:53 offset:[7,0]
edittext SoonMTex17 width:53 offset:[7,0]
edittext SoonMTex18 width:53 offset:[7,0]
edittext SoonMTex19 width:53 offset:[7,0]
edittext SoonMTex20 width:53 offset:[7,0]
BUtton BT21 "21" width:50 height:50 offset:[-7,0] across:10
BUtton BT22 "22" width:50 height:50 offset:[-7,0]
BUtton BT23 "23" width:50 height:50 offset:[-7,0]
BUtton BT24 "24" width:50 height:50 offset:[-7,0]
BUtton BT25 "25" width:50 height:50 offset:[-7,0]
BUtton BT26 "26" width:50 height:50 offset:[7,0]
BUtton BT27 "27" width:50 height:50 offset:[7,0]
BUtton BT28 "28" width:50 height:50 offset:[7,0]
BUtton BT29 "29" width:50 height:50 offset:[7,0]
BUtton BT30 "30" width:50 height:50 offset:[7,0]
edittext SoonMTex21 width:53 offset:[-7,0] across:10
edittext SoonMTex22 width:53 offset:[-7,0]
edittext SoonMTex23 width:53 offset:[-7,0]
edittext SoonMTex24 width:53 offset:[-7,0]
edittext SoonMTex25 width:53 offset:[-7,0]
edittext SoonMTex26 width:53 offset:[7,0]
edittext SoonMTex27 width:53 offset:[7,0]
edittext SoonMTex28 width:53 offset:[7,0]
edittext SoonMTex29 width:53 offset:[7,0]
edittext SoonMTex30 width:53 offset:[7,0]
BUtton BT31 "31" width:50 height:50 offset:[-7,0] across:10
BUtton BT32 "32" width:50 height:50 offset:[-7,0]
BUtton BT33 "33" width:50 height:50 offset:[-7,0]
BUtton BT34 "34" width:50 height:50 offset:[-7,0]
BUtton BT35 "35" width:50 height:50 offset:[-7,0]
BUtton BT36 "36" width:50 height:50 offset:[7,0]
BUtton BT37 "37" width:50 height:50 offset:[7,0]
BUtton BT38 "38" width:50 height:50 offset:[7,0]
BUtton BT39 "39" width:50 height:50 offset:[7,0]
BUtton BT40 "40" width:50 height:50 offset:[7,0]
edittext SoonMTex31 width:53 offset:[-7,0] across:10
edittext SoonMTex32 width:53 offset:[-7,0]
edittext SoonMTex33 width:53 offset:[-7,0]
edittext SoonMTex34 width:53 offset:[-7,0]
edittext SoonMTex35 width:53 offset:[-7,0]
edittext SoonMTex36 width:53 offset:[7,0]
edittext SoonMTex37 width:53 offset:[7,0]
edittext SoonMTex38 width:53 offset:[7,0]
edittext SoonMTex39 width:53 offset:[7,0]
edittext SoonMTex40 width:53 offset:[7,0]
BUtton BT41 "41" width:50 height:50 offset:[-7,0] across:10
BUtton BT42 "42" width:50 height:50 offset:[-7,0]
BUtton BT43 "43" width:50 height:50 offset:[-7,0]
BUtton BT44 "44" width:50 height:50 offset:[-7,0]
BUtton BT45 "45" width:50 height:50 offset:[-7,0]
BUtton BT46 "46" width:50 height:50 offset:[7,0]
BUtton BT47 "47" width:50 height:50 offset:[7,0]
BUtton BT48 "48" width:50 height:50 offset:[7,0]
BUtton BT49 "49" width:50 height:50 offset:[7,0]
BUtton BT50 "50" width:50 height:50 offset:[7,0]
edittext SoonMTex41 width:53 offset:[-7,0] across:10
edittext SoonMTex42 width:53 offset:[-7,0]
edittext SoonMTex43 width:53 offset:[-7,0]
edittext SoonMTex44 width:53 offset:[-7,0]
edittext SoonMTex45 width:53 offset:[-7,0]
edittext SoonMTex46 width:53 offset:[7,0]
edittext SoonMTex47 width:53 offset:[7,0]
edittext SoonMTex48 width:53 offset:[7,0]
edittext SoonMTex49 width:53 offset:[7,0]
edittext SoonMTex50 width:53 offset:[7,0]
)
fn PageButtonActionFn PBBum =
(
case PBBum of (
1 : MatPageBt01.enabled = false
2 : MatPageBt02.enabled = false
3 : MatPageBt03.enabled = false
4 : MatPageBt04.enabled = false
)
MatPageBt02.checked = false
MatPageBt03.checked = false
MatPageBt04.checked = false
)
fn SelcSetIdFN _obj Btnum =
(
local _pageNum = 1
case of (
(MatPageBt01.state) : _pageNum = 0
(MatPageBt02.state) : _pageNum = 50
(MatPageBt03.state) : _pageNum = 100
(MatPageBt04.state) : _pageNum = 150
)
if _obj != undefined then
(
if _obj.count == 1 then
(
case classof _obj[1] of
(
Editable_mesh :
(
if _obj[1].modifiers[1] == undefined then
(
if subobjectLevel == 0 do
(
for n=1 to getNumFaces _obj[1] do --
(
setFaceMatID _obj[1] n ((Btnum as integer)+(_pageNum as integer))
)
)
if subobjectLevel == 4 or subobjectLevel == 5 do
(
_selecFace = getFaceSelection _obj[1] as array
for n=1 to _selecFace.count do
(
setFaceMatID _obj[1] _selecFace[n] ((Btnum as integer)+(_pageNum as integer))
)
if FaceUnselecCheckBox.state == true do
(
subobjectLevel = 0
)
)
update _obj[1]
)
else
(
max modify mode
_mod = modPanel.getCurrentObject()
if isKindOf _mod Edit_Mesh and subobjectLevel > 2 do editMeshMod.setValue Btnum
)
)
Editable_Poly :
(
if subobjectLevel == 0 do
(
for n=1 to polyop.getNumFaces _obj[1] do --
(
polyop.setFaceMatID _obj[1] n Btnum
)
)
if subobjectLevel == 4 or subobjectLevel == 5 do
(
_selecFace = polyop.getFaceSelection _obj[1] as array
for n=1 to _selecFace.count do
(
polyop.setFaceMatID _obj[1] _selecFace[n] ((Btnum as integer)+(_pageNum as integer))
)
if FaceUnselecCheckBox.state == true do
(
subobjectLevel = 0
)
)
update _obj[1]
)
PolyMeshObject :
(
)
Edit_Poly :
(
)
line :
(
messagebox "line 입니다."
)
SplineShape :
(
messagebox "SplineShape 입니다."
)
)
)
else
(
for _ObjNum = 1 to _obj.count do
(
_faceAllNum = getNumFaces _obj[_ObjNum]
if _obj[_ObjNum].modifiers[1] == undefined then
(
for _faceNum = 1 to _faceAllNum do
(
case (classof _obj[_ObjNum]) of
(
Editable_mesh : setFaceMatID _obj[_ObjNum] _faceNum ((Btnum as integer)+(_pageNum as integer))
Editable_Poly : polyop.setFaceMatID _obj[_ObjNum] _faceNum ((Btnum as integer)+(_pageNum as integer))
)
)
)
else
(
)
)
for n=1 to _obj.count do
(
if _obj[n].modifiers[1] == undefined then
(
update _obj[n]
)
)
)
)
else
(
messagebox "변경할 오브젝트를 선택하시오"
)
)
--================================================== ================================================== ======================================
on CBTMaterialLibrary open do
(
MatPageBt01.enabled = false
for n=1 to 50 do
(
appendIfUnique ButtonArray (execute ("CBTMaterialLibrary.BT"+(n as string)))
appendIfUnique ButtontextArray (execute ("CBTMaterialLibrary.SoonMTex"+(n as string)))
)
)
on CBTMaterialLibrary close do
(
)
on LibraryUrlOpen pressed do
(
readlinearray = #()
IconCount = 0
for n=1 to 50 do
(
ButtonArray.images = undefined
)
BtFilename = openfile (GetOpenFilename caption:"Open Material Script initial value.txt:" types:"Text(*.txt)") mode:"r+"
if BtFilename != undefined do
(
_StrArray = (filterstring ((BtFilename ) as string) ",\\,:")
_ReStrArray = ""
deleteitem _StrArray 1
deleteitem _StrArray _StrArray.count
append _ReStrArray "\\\\"
for n=1 to _StrArray.count do
(
append _ReStrArray (_StrArray[n] as string)
if _StrArray.count != n do
(
append _ReStrArray "\\"
)
)
while not eof BtFilename do
(
r= readline BtFilename
_r = #()
_r = filterString r "_"
insertItem r readlinearray (_r[1] as integer)
IconCount += 1
_BmpFile = (_ReStrArray as string)+"\Icon_"+(_r[1] as string)+".bmp"
insertItem (_BmpFile) ReadButtonImage (_r[1] as integer)
if (_r[1] as integer) < 51 do
(
ButtonArray[(_r[1] as integer)].images = #(_BmpFile,undefined,1,1,1,1,1)
ButtonArray[(_r[1] as integer)].tooltip = readlinearray[(_r[1] as integer)]
CBTMaterialLibrary.ButtontextArray[(_r[1] as integer)].text = r
)
)
close BtFilename
)
)
fn setMatPage index count:50 = (
MatPageButtons = #( MatPageBt01, MatPageBt02, MatPageBt03, MatPageBt04 )
MatPageButtons[ index ] = false
for i=1 to MatPageButtons.count where i != index do (
MatPageButtons[i].checked = false
MatPageButtons[i].enabled = true
)
for n=1 to 50 do
(
ButtonArray[n].text = (n + ((index-1)*count)) as string
if readlinearray[n] != undefined then
(
ButtonArray[ n ].images = #(((ReadButtonImage[n]) as string) , undefined , 1,1,1,1,1 )
ButtonArray[ n ].tooltip = readlinearray[n] as string
ButtontextArray[n].text = readlinearray[n] as string
)
else
(
ButtonArray[ n ].images = undefined
ButtonArray[ n ].tooltip = ""
ButtontextArray[n].text = ""
)
)
)
on MatPageBt01 changed theState do setMatPage 1
on MatPageBt02 changed theState do setMatPage 2
on MatPageBt03 changed theState do setMatPage 3
on MatPageBt04 changed theState do setMatPage 4
on BT1 pressed do SelcSetIdFN (selection as array) 1
on BT2 pressed do SelcSetIdFN (selection as array) 2
on BT3 pressed do SelcSetIdFN (selection as array) 3
on BT4 pressed do SelcSetIdFN (selection as array) 4
on BT5 pressed do SelcSetIdFN (selection as array) 5
on BT6 pressed do SelcSetIdFN (selection as array) 6
on BT7 pressed do SelcSetIdFN (selection as array) 7
on BT8 pressed do SelcSetIdFN (selection as array) 8
on BT9 pressed do SelcSetIdFN (selection as array) 9
on BT10 pressed do SelcSetIdFN (selection as array) 10
on BT11 pressed do SelcSetIdFN (selection as array) 11
on BT12 pressed do SelcSetIdFN (selection as array) 12
on BT13 pressed do SelcSetIdFN (selection as array) 13
on BT14 pressed do SelcSetIdFN (selection as array) 14
on BT15 pressed do SelcSetIdFN (selection as array) 15
on BT16 pressed do SelcSetIdFN (selection as array) 16
on BT17 pressed do SelcSetIdFN (selection as array) 17
on BT18 pressed do SelcSetIdFN (selection as array) 18
on BT19 pressed do SelcSetIdFN (selection as array) 19
on BT20 pressed do SelcSetIdFN (selection as array) 20
on BT21 pressed do SelcSetIdFN (selection as array) 21
on BT22 pressed do SelcSetIdFN (selection as array) 22
on BT23 pressed do SelcSetIdFN (selection as array) 23
on BT24 pressed do SelcSetIdFN (selection as array) 24
on BT25 pressed do SelcSetIdFN (selection as array) 25
on BT26 pressed do SelcSetIdFN (selection as array) 26
on BT27 pressed do SelcSetIdFN (selection as array) 27
on BT28 pressed do SelcSetIdFN (selection as array) 28
on BT29 pressed do SelcSetIdFN (selection as array) 29
on BT30 pressed do SelcSetIdFN (selection as array) 30
on BT31 pressed do SelcSetIdFN (selection as array) 31
on BT32 pressed do SelcSetIdFN (selection as array) 32
on BT33 pressed do SelcSetIdFN (selection as array) 33
on BT34 pressed do SelcSetIdFN (selection as array) 34
on BT35 pressed do SelcSetIdFN (selection as array) 35
on BT36 pressed do SelcSetIdFN (selection as array) 36
on BT37 pressed do SelcSetIdFN (selection as array) 37
on BT38 pressed do SelcSetIdFN (selection as array) 38
on BT39 pressed do SelcSetIdFN (selection as array) 39
on BT40 pressed do SelcSetIdFN (selection as array) 40
on BT41 pressed do SelcSetIdFN (selection as array) 41
on BT42 pressed do SelcSetIdFN (selection as array) 42
on BT43 pressed do SelcSetIdFN (selection as array) 43
on BT44 pressed do SelcSetIdFN (selection as array) 44
on BT45 pressed do SelcSetIdFN (selection as array) 45
on BT46 pressed do SelcSetIdFN (selection as array) 46
on BT47 pressed do SelcSetIdFN (selection as array) 47
on BT48 pressed do SelcSetIdFN (selection as array) 48
on BT49 pressed do SelcSetIdFN (selection as array) 49
on BT50 pressed do SelcSetIdFN (selection as array) 50
)
createdialog CBTMaterialLibrary width:600 pos:[400,200] --pos:[700,750]