Skip to content

Instantly share code, notes, and snippets.

@jaforsgren
jaforsgren / Select Faces Within Angle Threshold | .ms
Created June 16, 2017 06:58 — forked from JokerMartini/Select Faces Within Angle Threshold | .ms
Maxscript: Selects the faces of an editable poly within a given angle threshold from the Z normal. There is a max height parameter which ignores faces lower than the Max Height value.
--"Angle Threshold spinner" -- angle beetven face normal and Z-axis
--"Max Height" -- select only faces which center position is > Max Height
try(DestroyDialog ::bgaRoll)catch()
rollout bgaRoll "selectObjTops"
(
local poGFN = polyop.getFaceNormal, poGFC = polyop.getFaceCenter
spinner spn_ang "Angle Threshold:" range:[0,360,5] pos:[5,5]
spinner spn_heig "Max Height: " range:[0,360,0] pos:[4,25]
button btn "Select T O P S!" width:150 pos:[5,45]
@jaforsgren
jaforsgren / Desktop Notification | .ms
Created June 16, 2017 06:57 — forked from JokerMartini/Desktop Notification | .ms
Maxscript: Send a simple desktop notification similar to skype, from 3ds Max to the desktop. When users click on the balloon notification, in this example, it will open a windows explorer.
fn closeIcon s e = s.dispose()
fn balloonClicked s e = shelllaunch @"c:\windows\" ""
a = dotnetobject "notifyicon"
a.visible = true
a.icon = (dotnetclass "system.drawing.systemIcons").information
dotnet.addEventHandler a "BalloonTipClosed" closeIcon
dotnet.addEventHandler a "BalloonTipClicked" balloonClicked
a.showballoontip 1000 "test" "test2" (dotnetclass "tooltipicon").info
@jaforsgren
jaforsgren / Logger.ms
Created June 16, 2017 06:56 — forked from gtvfx/Logger.ms
Maxscript Logger object for formatting differing levels of information to the console. Inspired by the Python Logger module.
/***************************************************************************************************
Copyright (C) 2013 - 2017 Gavyn Thompson
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@jaforsgren
jaforsgren / Save Data to Max File | .ms
Created June 16, 2017 06:54 — forked from JokerMartini/Save Data to Max File | .ms
Maxscript: This demonstrates a simple way to save data to a max file.
CA = attributes MyData
(
parameters main
(
theNames type:#stringTab tabSizeVariable:true
nodes type:#nodeTab tabSizeVariable:true
)
)
--// variant #1 > add to rootNode to store with file
@jaforsgren
jaforsgren / Collect all nodes and children | .mxs
Created June 16, 2017 06:52 — forked from JokerMartini/Collect all nodes and children | .mxs
Maxscript: Collects all parents and their children nodes recursively
fn get_all_nodes nodes:#() =
(
allnodes = #()
for n in nodes do
(
append allnodes n
join allnodes (get_all_nodes nodes:(n.children))
)
@jaforsgren
jaforsgren / load_mat.ms
Created June 16, 2017 06:52 — forked from stevechap416/load_mat.ms
Maxscript: Load a .mat and Apply it to Current Object
fn loadMat locationToLoad = (
--Load material library.
loadMaterialLibrary locationToLoad
theStr = filenamefrompath (getMatLibFileName())
theStr = trimRight theStr ".mat"
$.material = currentMaterialLibrary[theStr]
deleteItem currentMaterialLibrary 1
@jaforsgren
jaforsgren / save_mat.ms
Created June 16, 2017 06:51 — forked from stevechap416/save_mat.ms
Maxscript: Save Current Object Material to a .mat
fn saveMat locationToSave = (
--Add current objects material to max's temp library.
append currentMaterialLibrary $.material
--Save that library to a location
saveMaterialLibrary locationToSave
--Clear that temp library
deleteItem currentMaterialLibrary 1
@jaforsgren
jaforsgren / Formatted with leading Zeros | .ms
Created June 16, 2017 06:46 — forked from JokerMartini/Formatted with leading Zeros | .ms
Maxscript: Creates a string with leading zeros.
formattedPrint 2 format:"3.3d"
@jaforsgren
jaforsgren / Finding Angle Between Two Vectors | .ms
Created June 16, 2017 06:45 — forked from JokerMartini/Finding Angle Between Two Vectors | .ms
Maxscript: finds the angle between two vectors
-- Option 1
fn GetVectorsAngle v1 v2 =
(
theAngle = acos(dot (normalize v1) (normalize v2))
)
vA = obj2.pos - obj1.pos -- vector between two objects
vA = obj3.pos - obj1.pos -- vector between two objects
GetVectorsAngle vA vB
@jaforsgren
jaforsgren / em_LMAddons.mcr
Created June 16, 2017 06:33 — forked from Moeamed/em_LMAddons.mcr
[MaxScript] LayerManager Add-Ons
/***********************************************************************************
NAME/ em_LMAddons
AUTHORS/ Mhamed Elmezoued
VERSION/ 1.0
DESCRIPTION/
Add-ons for the layer manager.
- Delete unused layer(s) : allows, as its name suggests deleting unused (or empty) layers