3ds Max Plugins
...
Utility Plugins
SiNiScript
SiNiScript - MAXScript code samples
4min
siniscript maxscript samples the following are a few maxscript examples to help you understand writing your own scripts tip copy and paste the code to use the below maxscript samples, copy the whole text, then in 3ds max open the maxscript editor and paste the code into it save the maxscript to evaluate hit ctrl+e attach by parent this maxscript has been written to incorporate siniscript functions it's designed to attach revit objects by their parent objects, ie doors \ created by josh gruitt sini software listparentsarray = #() allobjstoattach = #() fn getmainparent obj =( if isvalidnode obj then ( if isvalidnode obj parent then ( getmainparent obj parent ) else( if finditem listparentsarray obj == 0 then append listparentsarray obj ) ) ) fn getallchildren obj arr =( if obj children count > 0 then ( for o in obj children do ( appendifunique arr o getallchildren o arr ) ) ) allobjs = selection for o in allobjs do getmainparent o for i = 1 to listparentsarray count do ( allobjstoattach = #(listparentsarray\[i]) getallchildren listparentsarray\[i] allobjstoattach si mesh attachobj allobjstoattach false 0 0 listparentsarray\[i] name ) forensic remove empty layers \ \ sini software example delete empty layers script \ press \<ctrl e> to run this from maxscript editor \ clearlistener() gc() try(destroydialog open deleteemptylayers dlg)catch() rollout open deleteemptylayers dlg "delete empty layers" width 150 height 70( 	button open bt "delete empty layers" pos \[5,10] width 140 height 23 	label mesage chk "" pos \[10,40] width 140 height 23 	 	on open bt pressed do( 	 local removeamount = si clean deleteemptylayers() 	 mesage chk text = ("delete " + (removeamount as string) + " empty layers") 	) ) createdialog open deleteemptylayers dlg sculpt attach all mesh objects into one mesh \ \ sini software example attach objects script \ press \<ctrl e> to run this from maxscript editor \ clearlistener() gc() try(destroydialog attachobj dlg)catch() rollout attachobj dlg "attach objects" width 150 height 125( 	checkbox weld chk "weld attached" pos \[10,10] width 110 height 18 checked\ true 	spinner weld spn "weld threshold " pos \[10,30] type #float fieldwidth 38 range \[ 100,100,0 001] 	checkbox newname chk "change name" pos \[10,50] width 110 height 18 	edittext new name "" pos \[5,70] width 140 height 18 enabled\ false 	button attachobj bt "attach selected objects" pos \[5,95] width 140 height 23 	 	on newname chk changed state do ( 	 if state == true then( 	 new name enabled = true	 	 ) 	 else( 	 new name text = "" 	 new name enabled = false 	 ) 	) 	 	on weld chk changed state do ( 	 if state == true then weld spn enabled = true else weld spn enabled = false 	) 	 	on attachobj bt pressed do( 	 objs = selection as array 	 if weld chk checked == true then 	 si mesh attachobj objs weld chk state weld spn value new name text 	 else 	 si mesh attachobj objs weld chk state 0 0 new name text 	) ) createdialog attachobj dlg unite relink missing files in an external 3ds max file, to a given path \ \ sini software relink files maxscript sample script \ press \<ctrl e> to run this from maxscript editor \ clearlistener() gc() try(destroydialog extrelinkfiles dlg)catch() global maxfiledir = undefined global relinkdir = undefined rollout extrelinkfiles dlg "relink files external max file maxscript sample" width 500 height 70( 	label maxfile lb "select max file" pos \[10,10] width 390 height 23 style sunkenedge\ true 	button btn browsemaxfile " " pos \[410,10] width 40 height 23 	label path lb "select search path" pos \[10,40] width 390 height 23 style sunkenedge\ true 	button btn browse " " pos \[410,40] width 40 height 23 	button btn relink "relink" pos \[455,40] width 40 height 23 enabled\ false 	 	on btn browsemaxfile pressed do ( 	 maxfiledir = getopenfilename caption "select max file " types "max file( max)| max|all| |" 	 if maxfiledir != undefined do ( 	 maxfile lb text = maxfiledir 	 if(maxfiledir != undefined and relinkdir != undefined) then btn relink enabled = true 	 ) 	) 	 	on btn browse pressed do ( 	 relinkdir = getsavepath caption "select relink directory " 	 if relinkdir != undefined do ( 	 path lb text = relinkdir 	 if(maxfiledir != undefined and relinkdir != undefined) then btn relink enabled = true 	 ) 	) 	 	on btn relink pressed do ( 	 si relink relinkmaxfile maxfiledir relinkdir 	) ) createdialog extrelinkfiles dlg learning 3ds max maxscript if you are interested in learning the basics of maxscripting please check out the following link autodesk 3ds max developer help maxscript learning 3ds max python if you are interested in learning the basics of python scripting please check out the following link autodesk 3ds max developer help python