SiNi Help Documentation

⌘K
👍SiNi Software Help Docs
â–ļī¸Getting started!
🎓Education Licences
👤SiNi Account
🆗Registration and Account
â„šī¸User Dashboard
đŸ› ī¸Installation and Licensing
✅Subscription as a Service (SaaS)
🔄Resellers
đŸ–Ĩī¸3ds Max Plugins
đŸ–Ĩī¸Utility Plugins
đŸ–Ĩī¸Object Plugins
đŸ–Ĩī¸Licensing Plugins
âš™ī¸SiNi Configuration
đŸ–Ĩī¸MAXScripts
đŸ–Ĩī¸Setup and installation
đŸ–Ĩī¸SiNi MAXScripts Directory
đŸ–Ĩī¸MAXScripting for BATCH
đŸ–Ĩī¸MAXScript - StackUp Instructions
đŸ”ĸRelease Changelog
đŸ”ĸCurrent versions
#ī¸âƒŖLegacy versions
✅Known Issues
🎓Knowledge Base
❓FAQ - Questions?
âœ´ī¸Suggested workflows
🌐Shortcuts
🌐Customer Support
🌐Technical Support
🌐Downloads
🌐YouTube Channel
🌐SiNi Forum
🌐Social Media
🌐3Disciple Magazine
🌐3ds Max Indie License
Docs powered by
Archbee
3ds Max Plugins
...
Utility Plugins
SiNiScript

SiNiScript - MAXScript code samples

6min

īģŋ

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.

Text
|
-- 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

Text
|
------------------------------------------------------------------
--  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

Text
|
------------------------------------------------------------------
--  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

Text
|
------------------------------------------------------------------
--  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

īģŋ

īģŋ

Updated 03 Mar 2023
Did this page help you?
PREVIOUS
SiNiScript (UI)
NEXT
Forensic
Docs powered by
Archbee
TABLE OF CONTENTS
SiNiScript MAXScript Samples
Tip - Copy and paste the code
Learning 3ds Max MAXScript
Learning 3ds Max Python
Docs powered by
Archbee