Verktøy/Tools

Forskjellige verktøy og scripter laget av meg. (Various tools and scripts developed by me.)

MAXSCRIPT – Color Checker
ColorChecker1.0

/*
[DESCRIPTION]
ColorChecker.ms

[CREATION INFO]
Last Modified: Apr 14, 2011
Author: Raymond Homme Ingebretsen
Webpage: http://www.homme3d.com

[History]
V1.0: First version.
*/

try(destroyDialog ::rol_ColorChecker)catch()
 
rollout rol_ColorChecker "ColorChecker V1.0"
(
    colorPicker Color_cp "Drag/Drop Color: " height:18 fieldwidth:75
    label lbl1 "__________________________________" height:14
    label RGB_lab "RGB:" align:#left
    label lbl2 "__________________________________" height:14
    label HSV_lab "HSV:" align:#left
    label lbl3 "__________________________________" height:14
    label txtrgb "0-1-0:" align:#left across:4
    label rgb1_lab "R:" width:22
    label rgb2_lab "G:" width:22
    label rgb3_lab "B:" width:22
     
     
    on Color_cp changed col do
    (
        local colR=col.r
        local colG=col.g
        local colB=col.b
        local colRString=(colR as integer) as string
        local colGString=(colG as integer) as string
        local colBString=(colB as integer) as string
        RGB_lab.text="RGB: "+colRString+", "+colGString+", "+colBString
         
        local colH=col.h
        local colS=col.s
        local colV=col.v
        local colHString=(colH as integer) as string
        local colSString=(colS as integer) as string
        local colVString=(colV as integer) as string
        HSV_lab.text="HSV: "+colHString+", "+colSString+", "+colVString
         
        local colmrR=col.r
        local colmrG=col.g
        local colmrB=col.b
        local colmrRString=(colR/255 as integer) as string
        local colmrGString=(colG/255 as integer) as string
        local colmrBString=(colB/255 as integer) as string
        rgb1_lab.text=""+colmrRString
        rgb2_lab.text=""+colmrGString
        rgb3_lab.text=""+colmrBString
    )
)
createDialog rol_ColorChecker width:185 height:140

MAXSCRIPT – Lazy Random Colors V1.1 – Assigns Random or Gray color to objects.
LazyRandomColors_v1.1

/*
[DESCRIPTION]
Lazy Random Colors V1.1 – Assigns Random colors to objects or Gray color to objects.

[INFO]
- Put the files in maxroot\scripts\ (e.g.: C:\3dsmax2012\Scripts\)
- Tested with 3DS Max 2009 <--> 2012

[CREATION INFO]
Last Modified: Apr 14, 2011
Author: Raymond Homme Ingebretsen
Webpage: http://www.homme3d.com

[History]
V1.0: First version.
*/
----------------------------------------------------------------------------------------------------------------------------------------------------------
	try(closeRolloutFloater LazyRandomColorFloater) catch()
----------------------------------------------------------------------------------------------------------------------------------------------------------
	(     
        Rollout Roll_RandomColor "Random Colors"
        (
			function Fn_RandomColors objs =
				(
					for i in objs do
					i.wirecolor = random black white
                )
				
			function Fn_RandomColorsGray objs =
                (
					for i in objs do
					i.wirecolor = white * random 0.2 0.8
                )
				
			function Fn_RandomColorsGrayOnly objs =
                (
					for i in objs do
					i.wirecolor = gray
                )
----------------------------------------------------------------------------------------------------------------------------------------------------------
				group "Random Colors"
                (
					radiobuttons RanWho labels:#("By Selected", "By Geometry", "By Objects (All)") across:2
					Button DoRandCol "Assign" width:70 height:30 align:#right
                )
				
                group "Random Gray"
                (
					radiobuttons RanGray labels:#("By Selected", "By Geometry", "By Objects (All)") across:2
					button DoGrayCol "Assign" width:70 height:30 align:#right
                )
				
				group "Gray Only"
                (
					radiobuttons RanGrayOnly labels:#("By Selected", "By Geometry", "By Objects (All)") across:2
					button DoGrayOnly "Assign" width:70 height:30 align:#right
                )
				
                group "About"
                (
					HyperLink homepage2 "..:: Raymond H.Ingebretsen'2011 ::.." address:"http://www.homme3d.com/" color:(color 255 255 255) hovercolor:(color 111 111 111) visitedcolor:(color 255 255 255) align:#center
				)
----------------------------------------------------------------------------------------------------------------------------------------------------------				
                on DoRandCol pressed do
                (
					if RanWho.state==1 then
						Fn_RandomColors selection
							else
					if RanWho.state==2 then
						Fn_RandomColors geometry
							else
						Fn_RandomColors objects
                )
				
                on DoGrayCol pressed do
                (
					if RanGray.state==1 then
						Fn_RandomColorsGray selection
							else
					if RanGray.state==2 then
						Fn_RandomColorsGray geometry
							else
						Fn_RandomColorsGray objects
                )  
				
                 on DoGrayOnly pressed do
                (
					if RanGrayOnly.state==1 then
						Fn_RandomColorsGrayOnly selection
							else
					if RanGrayOnly.state==2 then
						Fn_RandomColorsGrayOnly geometry
							else
						Fn_RandomColorsGrayOnly objects
                )       
		)
----------------------------------------------------------------------------------------------------------------------------------------------------------
        LazyRandomColorFloater=NewRolloutFloater "Lazy Random Colors" 210 310 280 150
        Addrollout Roll_RandomColor LazyRandomColorFloater
----------------------------------------------------------------------------------------------------------------------------------------------------------
	)

MAXSCRIPT – Open/Close All Groups and Sub-Groups (Not hidden Groups)
Open-CloseAllGroups1.0

/*
-------------------------------------------------------------------------------
-- Open/Close All Groups and Sub-Groups (Not hidden Groups)
-------------------------------------------------------------------------------
-- This Script is based on le1setreter open/close all/selected groups
-- http://www.scriptspot.com/3ds-max/scripts/openclose-allselected-groups
--
-- Thankz goes to:
-- http://www.scriptspot.com/users/barigazy
-- http://www.scriptspot.com/users/le1setreter
-------------------------------------------------------------------------------
 */
try (destroyDialog ::rol_OpenCloseGroups) catch()
rollout rol_OpenCloseGroups "Open/Close Groups"
(
    fn groupFIlter grp = isGroupHead grp and not grp.isHidden
    mapped fn openGroups arr toggle: = if groupFIlter arr do setGroupOpen arr toggle
    checkbutton ckb_OpenClose "OPEN GROUP" height:35 width:140 highlightColor:[0,80,255] tooltip:"OPEN / CLOSE GROUPS" 
    on ckb_OpenClose changed state do
    (
        openGroups (helpers as array) toggle:state
        ckb_OpenClose.text = (if state then "CLOSE" else "OPEN") + " GROUP"
    )
)   
createdialog rol_OpenCloseGroups

MAXSCRIPT – Selection methods / Examples
Open-CloseAllGroups1.0

try(destroyDialog SelectionTools)catch()
 
 
--Create a rollout
    rollout SelectionTools "Selection Tools V1.0 -- (C) By Raymond H.Ingebretsen -- Homepage: http:www.homme3d.com"
    (
        button btn_1 "Standard Lights" width:95 height:22 align:#center tooltip:"Select Standard Lights" across:17
        button btn_2 "Photometric Lights" width:95 height:22 align:#center tooltip:"Select Photometric Lights"
        button btn_3 "All Lights" width:95 height:22 align:#center tooltip:"Select All Lights In Scene"
        button btn_4 "Free Cameras" width:95 height:22 align:#center tooltip:"Select Free Cameras"
        button btn_5 "Target Cameras" width:95 height:22 align:#center tooltip:"Select Target Cameras"
        button btn_6 "All Cameras" width:95 height:22 align:#center tooltip:"Select All Cameras"
        button btn_7 "Helpers" width:95 height:22 align:#center tooltip:"Select All Helpers"
        button btn_8 "Shapes/Splines" width:95 height:22 align:#center tooltip:"Select All Shapes and Splines"
        button btn_9 "SpaceWarps" width:95 height:22 align:#center tooltip:"Select All Space Warps"
        button btn_10 "Instances" width:95 height:22 align:#center tooltip:"Select Instance Objects"
        button btn_11 "Bones & Biped" width:95 height:22 align:#center tooltip:"Select Bones & Biped"
        button btn_12 "Opposite Objects" width:95 height:22 align:#center tooltip:"Select Opposite Objects From Selection (Hidden Obj's are ignored)"
        button btn_13 "By Material" width:95 height:22 align:#center tooltip:"Select objects by materials"
        button btn_14 "By Modifier" width:95 height:22 align:#center tooltip:"Select objects by modifier"
        button btn_15 "By Wire Color" width:95 height:22 align:#center tooltip:"Select Objects by Wire Color"
        button btn_16 "By Edit Poly" width:95 height:22 align:#center tooltip:"Select Poly objects"
        button btn_17 "By Edit Mesh" width:95 height:22 align:#center tooltip:"Select Mesh objects"
         
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select Standard Light
        on btn_1 pressed do
            (
                select (for i in lights where i.category == #standard collect i)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select Photometric Lights
        on btn_2 pressed do
            (
                select (for i in lights where i.category == #Photometric collect i)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select All Lights
        on btn_3 pressed do
            (
                select (for l in lights collect l)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select Free Cameras
        on btn_4 pressed do
            (
                select (for c in cameras where classOf c == freeCamera collect c)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select Target Camera + Target
        on btn_5 pressed do
            (
                 select (for c in cameras where classof c == targetObject or classOf c == targetCamera collect c)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select All Cameras
        on btn_6 pressed do
            (
                select (for c in cameras collect c)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select Helpers
        on btn_7 pressed do
            (
                select (for h in helpers where h.category == #standard collect h)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select Splines / Shapes
        on btn_8 pressed do
            (
                select (for s in shapes where s.category == #splines collect s)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select Spacewarps
        on btn_9 pressed do
            (
                select (for s in spacewarps collect s)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select All instance objects in scene
        on btn_10 pressed do
            (
                InstanceObjs = #()
                for obj in geometry where (instanceMgr.getInstances obj &instances) > 1 and (findItem instanceObjs  obj) == 0 do
                join instanceObjs instances
                 
                select InstanceObjs
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select bone objects & biped
        on btn_11 pressed do
        (
        select (for b in objects where classof b == boneGeometry or classOf b == Biped_Object collect b)
        )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select opposite objects that is'nt in the selection (Hidden Objects are ignored)
        on btn_12 pressed do
        (
            select (for obj in $* where not obj.isSelected and not obj.isHidden collect obj)
        )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select objects with same material
        on btn_13 pressed do
        (
            obj_list=#()
            current_obj = getCurrentSelection()     
            current_mat = current_obj[1].material
             
            if current_obj.count != 1 then exit -- works ONLY if ONE object is selected
             
            for obj in Geometry do
            (
                if obj.material == current_mat do   -- if object's material is the same of father's one
                append obj_list obj -- add to selection list
            )
                select obj_list -- select array
        )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select object by modifiers
        on btn_14 pressed do
        (
            select (for i in geometry where i.modifiers.count > 0 and not i.isHidden collect for j in i.modifiers where (classof j == classof selection[1].modifiers[1]) do exit with i)
        )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select object by same wirecolor
        on btn_15 pressed do
        (
            select (for o in objects where o.wirecolor == ($.wirecolor) collect o) --select by wire
        )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select object by edit poly objects
        on btn_16 pressed do   
            (
                --select (for o in objects where isKindOf o editable_poly collect o)
                select (for o in geometry where classOf o == editable_poly or classOf o == polyMeshObject collect o)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
-- Select object by edit mesh objects
        on btn_17 pressed do   
            (
                --  select (for o in objects where isKindOf o Editable_Mesh collect o)
                select (for o in geometry where classOf o == editable_mesh collect o)
            )
----------------------------------------------------------------------------------------------------------------------------------------------
    ) -- End rollout
     
createDialog SelectionTools width:1680 height:35
 
cui.RegisterDialogBar SelectionTools minSize:[1024,35] maxSize:[1680,35] style:\
#(#cui_dock_bottom, #cui_dock_top, #cui_floatable,#cui_handles,#cui_max_sized)
 
cui.dockDialogBar SelectionTools #cui_dock_top  -- change to #cui_dock_bottom if you want it to dock at the bottom..
                                                -- Or just remove this line if you dont want it to dock at all in startup

Tassel @ Scriptspot:

Flere av mine max script snutter finner du her // Several of my MAX Scripts can be found here :

Reset 3DS Max Windows
Lazy Caddy Controller
Lazy Random Colors
Lazy Clay Render
Easy RenderSwitcher
Lazy Group Selector
Lazy Viewport Settings
Lazy Primitives