Skip to content

Instantly share code, notes, and snippets.

View stevechap416's full-sized avatar

Steve Chappell stevechap416

View GitHub Profile
@stevechap416
stevechap416 / Top_Level_Layers.ms
Created April 27, 2020 02:08
Maxscript: Get the Names of the Top Level Layers
topLevelLayers = #()
for i = 0 to LayerManager.count - 1 do (
findParent = layerManager.getlayer i
if findParent.getParent() == undefined then (
appendIfUnique topLevelLayers findParent.name
)
)
@stevechap416
stevechap416 / Tabbed_Panel.ms
Created May 21, 2019 15:58
Maxscript: Tabbed Panel UI Template
--Creates a tabbed panel UI for complex maxscript tools.
--The concept for this script came from one of the great minds over at the CGTalk forum
--but I cannnot for the life of me find the original post. If you find it let me know.
global panelOne
global panelTwo
global panelThree
rollout panelOne "Panel Script Template" width:350 height:230
(
@stevechap416
stevechap416 / Create_Layer.ms
Last active July 18, 2019 22:24
Maxscript: Create Layer by Name
--Creates a layer with a given name if it doesn't already exist.
function createLayer newLayerName = (
layer = LayerManager.getLayerFromName newLayerName
if layer == undefined then (
layer = LayerManager.newLayer()
layer.setname newLayerName
)
@stevechap416
stevechap416 / Camera_Rotate.ms
Created May 16, 2018 20:46
Maxscript: Rotate camera and redraw viewpoint.
/*
This snippet here was created based on specific need to *maybe* rotate the camera 90 degrees before doing some other action.
*/
--Set some globals
global stopRotating = false
global resetAngleAmount = 0
--Camera to manipulate has been added to max scene and is named
camName = "STUDIO_Camera"
@stevechap416
stevechap416 / uiAccessor.ms
Last active October 13, 2019 10:49
Maxscript: Simple DialogMonitorOPS and uiAccessor Test
--Global Variables
global hwnd
fn checkDialogs = (
hwnd = dialogMonitorOps.getWindowHandle()
dialogTitle = uiAccessor.getWindowText hwnd
print(dialogTitle)
true
)
@stevechap416
stevechap416 / PS Extendscript: CubeMapSplit.jsx
Created June 13, 2017 22:41
Prepare a Rendered VR Cubemap for Post Processing
//Exports out the 12 images that make up cube maps into the current folder.
//Make sure you have your export setting setup correctly in PS so no hyphens are added to your filename.
//Check here: http://thesetchells.com/2012/06/preventing-dashes-hyphens-photoshop-save-web/
//Works on flattened images.
var doc = app.activeDocument;
var docName = doc.name.substr(0,doc.name.length-4);
var exportName = docName + "_split";
var dir = doc.path.toString()+"/";
@stevechap416
stevechap416 / PS Extendscript: CheckActions.jsx
Last active November 21, 2018 16:01
Check for Installed Photoshop Actions
//This script works by runnning a specific action in a given action set. I normally make this action
//do nothing at all, but if it's not present on a user's computer to throw a warning. This is important when
//scripts rely on specific actions and you want to alert the user that they may not work correctly unless they add or update
//the action set.
actionCheckFail = false;
try {
doAction('InstallCheck', 'MySetOfActions');
} catch(e) {
@stevechap416
stevechap416 / PS Extendscript: OpenURL.jsx
Last active June 13, 2017 22:27
Open Web Browser from Photoshop
openURL("www.google.com")
function openURL(url) {
var fname = "shortcut.url";
var shortcut = new File(Folder.temp + '/' + fname);
shortcut.open('w');
shortcut.writeln('[InternetShortcut]');
shortcut.writeln('URL=' + url);
shortcut.writeln();
shortcut.close();
@stevechap416
stevechap416 / PS Extendscript: SelectRectangle.jsx
Created June 13, 2017 22:13
Create Rectangular Selection
//Change app units to pixels so the selection below will perform correctly
app.preferences.rulerUnits = Units.PIXELS;
//Selects a 100px by 100px rectangle.
selectRect(0,0,100,100)
function selectRect(top, left, right, bottom)
{
app.activeDocument.selection.deselect()
// =======================================================
@stevechap416
stevechap416 / Weld Imported Geo.ms
Last active February 28, 2018 14:57
Maxscript: Weld geometry from an imported file.
for obj in selection do (
--Make sure whatever we are trying to weld is actually geometry
if( isKindOf obj GeometryClass ) then (
print("Welding...")
--Checking what type of geometry it is.
if classOf obj == Editable_Poly then (
--Put it inside a try-catch so if there are any issues with any one piece it doesn't break the script
try (