[Closed] Just have looked at new features…
if we are talking about ‘safe coding’ try to guess where these two global functions i got…
GetSelectedSubAnim(), IsFloatController()
or try:
isFloatController (bezier_float())
We could make a funny thread, showing some really old scripts we all wrote and how we’d make them 100x better and faster now.
Can I start?
My first script ever( don’t kill me):
(
global startEdge
global EdgeToSubstr
global EdgesAll
global nextEdge
global EdgeToShow
global spiner_val
global L1
global L2
global R1
global R2
global curObj
global debug = false
global selFace1
global selFace2
global selFace3
global obEdge
global obEdge3
global obEdge4
global selFace1Edges
global selFace3AllEdges
global selFace3NewEdges
rollout rol_ ""
(
button btn_FullLoop "Full Loop" pos:[11,6] width:59 height:16
button btn_FullRing "Full Ring" pos:[90,6] width:63 height:16
spinner set_edges "Skip Every: " pos:[26,38] width:91 height:16 range:[0,10000,0] type:#integer
label lbl1 "V-E-P" pos:[122,38] width:45 height:15
GroupBox SkipRing "Skip Ring" pos:[11,142] width:137 height:39
button btn_RingAcceptL "<<---" pos:[16,158] width:37 height:21 across:3
button btn_RingAcceptBothDirect "<<-->>" pos:[56,158] width:46 height:21
button btn_RingAcceptR "--->>" pos:[106,158] width:37 height:21
GroupBox SkipLoop "Skip Loop" pos:[11,99] width:138 height:39
button btn_LoopAcceptL "<<---" pos:[16,117] width:46 height:21
button bnt_LoopAcceptBothDirect "<<-->>" pos:[56,117] width:46 height:21
button btn_LoopAcceptR "--->>" pos:[106,117] width:37 height:21
spinner spn_steps "For " pos:[60,59] width:56 height:16 type:#integer
label lbl7 "Steps" pos:[122,60] width:35 height:12
checkbox checkboxL "PolyLoop" pos:[77,87] width:71 height:20 checked:false toolTip:"Select Face Loop"
----------------------------------------------------------------------------------------------------------------------------
function SelectEdges step =
(
)
-----------------------------------------------------------------------------------------------------------------------------
on btn_FullLoop pressed do
with undo "Select Edge Loop" on
(
)
on btn_FullRing pressed do
with undo "Select Edge Ring" on
(
)
on btn_RingAcceptL pressed do
with undo "Select" on
(
)
on btn_RingAcceptBothDirect pressed do
with undo "Select" on
(
)
on btn_RingAcceptR pressed do
with undo "Select" on
(
)
on btn_LoopAcceptL pressed do
with undo "Select" on
(
)
on bnt_LoopAcceptBothDirect pressed do
with undo "Select Edge" on
(
)
on btn_LoopAcceptR pressed do
with undo "Select Edge" on
(
)
on checkboxL changed theState do
(
)
)
createDialog rol_
)
Mine comes pre-baked with a wonderful Bobo destruction!
http://forums.cgsociety.org/showthread.php?f=98&t=505573
Looking at it now (look at all those global variable declarations! Why?! And why was I interpreting text box values as float?!) I’m amazed it worked. But I’m very grateful to Bobo for ripping it apart. I actually mentioned it to Bobo when he came to the studio I used to work at (on Thinkbox business) – obviously he didn’t remember it, as he does it all the time, but it stuck with me, that’s for sure!
Very grateful to CGTalk generally, actually, for helping to improve my scripting unimaginably over the years.
The first script I wrote was one to set animation keys on piano keys for my 1st year university project, I don’t have that any more but the irst script I wrote while in employment (back in 2007?), I don’t have the original, this is version 4 which had things slightly improved I think the original didn’t have a function and didn’t work with Vray Mats or Multisubs. Loads of poorly named buttons, long lines of many lines of code that could be written as one.
Simple Matte Material setup and keeps opacity on and shaders, but is quite badly written and really isn’t an optimised way of working, it creates a lot of duplicate materials rather than working on an individual material basis. I’ve got a much more advanced and sophisticated version in my latest tools which uses the replaceinstances and works with all material and map types.
fn OPMasker r g b a =
(
with undo off with redraw off
(
for i = 1 to selection.count do
(
--test Vray
--if material is vray
local m=selection[i].material
if (classof m)==VRayMtl then
(
--check for opacity map
if selection[i].material.texmap_opacity != undefined then
(
--convert to standard
obj_mat = selection[i].material
new_mat = StandardMaterial()
new_mat.opacitymap = obj_mat.texmap_opacity
new_mat.diffuse = color r g b
new_mat.selfIllumAmount = 100
selection[i].material = new_mat
--if not, assign standard black_mask
)
else
(
selection[i].material = meditMaterials[a]
)
)
--if material is standard
if (classof m)==Standardmaterial then
(
--check for opacity map
if selection[i].material.opacitymap != undefined then
(
--apply colours settings
selection[i].material.diffuse = color r g b
selection[i].material.Specular = color r g b
selection[i].material.ambient = color r g b
selection[i].material.selfIllumAmount = 100
selection[i].material.glossiness = 0
selection[i].material.specularLevel = 0
selection[i].material.glossiness = 0
selection[i].material.diffuseMapEnable = off
selection[i].material.specularMapEnable = off
selection[i].material.specularLevelMapEnable = off
selection[i].material.glossinessMapEnable = off
selection[i].material.selfillumMapEnable = off
selection[i].material.filterMapEnable = off
selection[i].material.bumpMapEnable = off
selection[i].material.reflectionMapEnable = off
selection[i].material.refractionMapEnable = off
selection[i].material.displacementMapEnable = off
selection[i].material.ambientMapEnable = off
)
--if not apply standard black_mask
else
(
selection[i].material = meditMaterials[a]
)
)
-- if material is multisub
if (classof m)==multimaterial then
(
-- get count of sub IDs
--loop
for n = 1 to selection[i].material.materialList.count do
(
if( classof selection[i].material.materialList[n] == Standardmaterial ) then
(
--check for opacity
if selection[i].material.materialList[n].opacitymap != undefined then
(
--apply colours settings
selection[i].material.materialList[n].diffuse = color r g b
selection[i].material.materialList[n].Specular = color r g b
selection[i].material.materialList[n].ambient = color r g b
selection[i].material.materialList[n].selfIllumAmount = 100
selection[i].material.materialList[n].glossiness = 0
selection[i].material.materialList[n].specularLevel = 0
selection[i].material.materialList[n].glossiness = 0
selection[i].material.materialList[n].diffuseMapEnable = off
selection[i].material.materialList[n].specularMapEnable = off
selection[i].material.materialList[n].specularLevelMapEnable = off
selection[i].material.materialList[n].glossinessMapEnable = off
selection[i].material.materialList[n].selfillumMapEnable = off
selection[i].material.materialList[n].filterMapEnable = off
selection[i].material.materialList[n].bumpMapEnable = off
selection[i].material.materialList[n].reflectionMapEnable = off
selection[i].material.materialList[n].refractionMapEnable = off
selection[i].material.materialList[n].displacementMapEnable = off
selection[i].material.materialList[n].ambientMapEnable = off
)
--if not apply standard black_mask
else
(
selection[i].material.materiallist[n] = meditMaterials[a]
)
)
if (classof selection[i].material.materialList[n] ==VrayMtl) then
(
--check for opacity
if selection[i].material.materialList[n].texmap_opacity != undefined then
(
--convert to standard
obj_mat = selection[i].material.materialList[n]
new_mat = StandardMaterial()
new_mat.opacitymap = obj_mat.texmap_opacity
new_mat.diffuse = color r g b
new_mat.selfIllumAmount = 100
selection[i].material.materialList[n] = new_mat
--if not, assign standard black_mask
)
else
(
selection[i].material.materialList[n] = meditMaterials[a]
)
)
)
--check for vray/standard
--check for vray/standard
)
)
)
)
rollout maskerrollout "Masker" width:409 height:153
(
button btn1 "Initiate Mask Materials" pos:[7,5] width:397 height:20
label lbl1 "Quick Masks" pos:[10,33] width:214 height:18 enabled:false
button btn2 "Red" pos:[8,55] width:76 height:24 enabled:false
button btn3 "Green" pos:[87,55] width:76 height:24 enabled:false
button btn4 "Blue" pos:[167,55] width:76 height:24 enabled:false
button btn5 "Black" pos:[246,54] width:76 height:24 enabled:false
label lbl2 "Opacity Masker - Respects Vray Mtls and Multisub" pos:[5,93] width:315 height:20
button btn6 "Red" pos:[8,117] width:76 height:24 enabled:false
button btn7 "Green" pos:[87,117] width:76 height:24 enabled:false
button btn8 "Blue" pos:[167,117] width:76 height:24 enabled:false
button btn9 "Black" pos:[246,117] width:76 height:24 enabled:false
button btn10 "White" pos:[325,54] width:76 height:24 enabled:false
button btn11 "White" pos:[325,117] width:76 height:24 enabled:false
button btn12 "Random Assigner (Quick - no opacity map keeper)" pos:[7,160] width:397 height:20 enabled:false
button btn13 "Multisub Random Assigner" pos:[7,180] width:397 height:20 enabled:false
on btn1 pressed do
(
--black
meditMaterials[1] = StandardMaterial()
meditMaterials[1].name = "Black_matte"
meditMaterials[1].diffuse = color 0 0 0
meditMaterials[1].SelfIllumAmount = 100
--red
meditMaterials[2] = StandardMaterial()
meditMaterials[2].name = "Red_matte"
meditMaterials[2].diffuse = color 255 0 0
meditMaterials[2].SelfIllumAmount = 100
--green
meditMaterials[3] = StandardMaterial()
meditMaterials[3].name = "Green_matte"
meditMaterials[3].diffuse = color 0 255 0
meditMaterials[3].SelfIllumAmount = 100
--blue
meditMaterials[4] = StandardMaterial()
meditMaterials[4].name = "Blue_matte"
meditMaterials[4].diffuse = color 0 0 255
meditMaterials[4].SelfIllumAmount = 100
--white
meditMaterials[5] = StandardMaterial()
meditMaterials[5].name = "White_matte"
meditMaterials[5].diffuse = color 255 255 255
meditMaterials[5].SelfIllumAmount = 100
btn2.enabled = true
btn3.enabled = true
btn4.enabled = true
btn5.enabled = true
btn6.enabled = true
btn7.enabled = true
btn8.enabled = true
btn9.enabled = true
btn10.enabled = true
btn11.enabled = true
btn12.enabled = true
btn13.enabled = true
)
on btn2 pressed do
(
with undo off with redraw off
(
for i = 1 to selection.count do
(
selection[i].material = meditMaterials[2]
)
)
)
on btn3 pressed do
(
with undo off with redraw off
(
for i = 1 to selection.count do
(
selection[i].material = meditMaterials[3]
)
)
)
on btn4 pressed do
(
with undo off with redraw off
(
for i = 1 to selection.count do
(
selection[i].material = meditMaterials[4]
)
)
)
on btn5 pressed do
(
for i = 1 to selection.count do
(
selection[i].material = meditMaterials[1]
)
)
on btn6 pressed do
OPMasker 255 0 0 2
on btn7 pressed do
OPMasker 0 255 0 3
on btn8 pressed do
OPMasker 0 0 255 4
on btn9 pressed do
OPMasker 0 0 0 1
on btn10 pressed do
(
for i = 1 to selection.count do
(
selection[i].material = meditMaterials[5]
)
)
on btn11 pressed do
(
OPMasker 255 255 255 5
)
on btn12 pressed do
(
for i = 1 to selection.count do
(
f = random 2 4
selection[i].material = meditMaterials[f]
)
)
on btn13 pressed do
(
for i = 1 to selection.count do
(
local m=selection[i].material
if (classof m)==multimaterial then
(
-- get count of sub IDs
--loop
for n = 1 to selection[i].material.materialList.count do
(
if( classof selection[i].material.materialList[n] == Standardmaterial ) then
(
--check for opacity
if selection[i].material.materialList[n].opacitymap != undefined then
(
-- get random colour
f = random 2 4
if f = 2 do
(
r = 255
g = 0
b = 0
)
if f = 3 do
(
r = 0
g = 255
b = 255
)
if f = 4 do
(
r = 0
g = 0
b = 255
)
--apply colours settings
selection[i].material.materialList[n].diffuse = color r g b
selection[i].material.materialList[n].Specular = color r g b
selection[i].material.materialList[n].ambient = color r g b
selection[i].material.materialList[n].selfIllumAmount = 100
selection[i].material.materialList[n].glossiness = 0
selection[i].material.materialList[n].specularLevel = 0
selection[i].material.materialList[n].glossiness = 0
selection[i].material.materialList[n].diffuseMapEnable = off
selection[i].material.materialList[n].specularMapEnable = off
selection[i].material.materialList[n].specularLevelMapEnable = off
selection[i].material.materialList[n].glossinessMapEnable = off
selection[i].material.materialList[n].selfillumMapEnable = off
selection[i].material.materialList[n].filterMapEnable = off
selection[i].material.materialList[n].bumpMapEnable = off
selection[i].material.materialList[n].reflectionMapEnable = off
selection[i].material.materialList[n].refractionMapEnable = off
selection[i].material.materialList[n].displacementMapEnable = off
selection[i].material.materialList[n].ambientMapEnable = off
)
--if not apply standard black_mask
else
(
f = random 2 4
selection[i].material.materiallist[n] = meditMaterials[f]
)
)
if (classof selection[i].material.materialList[n] ==VrayMtl) then
(
--check for opacity
if selection[i].material.materialList[n].texmap_opacity != undefined then
(
-- get random colour
f = random 2 4
if f = 2 do
(
r = 255
g = 0
b = 0
)
if f = 3 do
(
r = 0
g = 255
b = 255
)
if f = 4 do
(
r = 0
g = 0
b = 255
)
--convert to standard
obj_mat = selection[i].material.materialList[n]
new_mat = StandardMaterial()
new_mat.opacitymap = obj_mat.texmap_opacity
new_mat.diffuse = color r g b
new_mat.selfIllumAmount = 100
selection[i].material.materialList[n] = new_mat
--if not, assign standard black_mask
)
else
(
f = random 2 4
selection[i].material.materialList[n] = meditMaterials[f]
)
)
)
--check for vray/standard
--check for vray/standard
)
)
)
)
Masker = newRolloutFloater "Masker" 420 250
addRollout maskerrollout Masker rolledUp:false