Skip to content

Instantly share code, notes, and snippets.

@ghiboz
Last active August 29, 2015 14:08
Show Gist options
  • Save ghiboz/ae017d0fbe7c370c3ea0 to your computer and use it in GitHub Desktop.
Save ghiboz/ae017d0fbe7c370c3ea0 to your computer and use it in GitHub Desktop.
ghiboz Tools v1
macroScript GhibozTools category:"ghiboz"
(
rollout GhibozTools "ghiboz tools"
(
group "Materials 255 :"
(
--spinner _SRad "radius" range:[0,30,10] scale:0.0001
--button _About "About Button"
button _Btn255 "Color Selected Objects"
toolTip:"Set ambient, diffuse and specular to 255 255 255"
)
group "Rename Mat:"
(
button _BtnRename "Rename Selected Objects"
toolTip: "Rename the materials of the selected objects to the diffuse texture"
)
group "Smooth:"
(
button _BtnWeld "Weld vertices"
toolTip:"Weld vertices of selected objects between 0.0001 m"
button _BtnSmooth "Smooth"
toolTip:"Smooth selected objects with an angle of 45°"
)
on _About pressed do
(
MessageBox "this is a demo\nto show"
)
-- events
on _Btn255 pressed do
(
for o in selection do
(
if( isKindOf o GeometryClass ) then -- weld only in geometry objects
(
if classof o.baseObject == Editable_Mesh then
(
print o.name
mymat = o.material
if classof o.material == Multimaterial do
(
print "multimaterial"
for singleMat in o.material.materialList do
(
if (singleMat != undefined) then
(
print singleMat.name
singleMat.ambient = color 255 255 255
singleMat.diffuse = color 255 255 255
singleMat.specular = color 255 255 255
)
)
)
if classof o.material == Standardmaterial do
(
print "standardmaterial"
singleMat = o.material
if (singleMat != undefined) then
(
print singleMat.name
singleMat.ambient = color 255 255 255
singleMat.diffuse = color 255 255 255
singleMat.specular = color 255 255 255
)
)
)
)
)
MessageBox "Operation done!"
)
on _btnRename pressed do
(
for o in selection do
(
if( isKindOf o GeometryClass ) then -- weld only in geometry objects
(
if classof o.baseObject == Editable_Mesh then
(
print o.name
mymat = o.material
if classof o.material == Multimaterial do
(
print "multimaterial"
for singleMat in o.material.materialList do
(
if (singleMat != undefined) then
(
print singleMat.name
newName = singleMat.maps[2].filename
newNameAr = filterString newName "\\"
newName = newNameAr[newNameAr.count]
newName = substituteString newName "_d.dds" ""
newName = substituteString newName ".dds" ""
print newName
print "..................................."
singleMat.name = newName
)
)
)
if classof o.material == Standardmaterial do
(
print "standardmaterial"
singleMat = o.material
if (singleMat != undefined) then
(
print singleMat.name
newName = singleMat.maps[2].filename
print newName
newNameAr = filterString newName "\\"
newName = newNameAr[newNameAr.count]
newName = substituteString newName "_d.dds" ""
newName = substituteString newName ".dds" ""
print newName
print "..................................."
singleMat.name = newName
)
)
)
)
)
MessageBox "Operation done!"
)
on _BtnWeld pressed do
(
for o in selection do
(
if( isKindOf o GeometryClass ) then -- weld only in geometry objects
(
if classof o.baseObject == Editable_Mesh then
(
--print o.name
meshOp.weldVertsByThreshold o.mesh o.mesh.verts 0.0001
)
)
)
MessageBox "Operation done!"
)
on _BtnSmooth pressed do
(
for o in selection do
(
if( isKindOf o GeometryClass ) then -- weld only in geometry objects
(
if classof o.baseObject == Editable_Mesh then
(
--print o.name
meshOp.autoSmooth o.mesh o.mesh.faces 45.0
)
)
)
MessageBox "Operation done!"
)
)
createdialog GhibozTools width:200
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment