After Effects
More info here
This script demonstrates the use of a Save-As dialog for scripts.
The plugin package is required to use this script. Download the plugin package here.
Code:
filedata = System.CreateDO('Clintons3d Package/File Save As data');
filedata.SetName("My special (*.bob)~*.BOB~Collada
Files (*.dae)~*.DAE~All Files (*.*)~*.*~~");
file = filedata.GetName();
System.Alert(file);
uses "~" as a delimiter between the description and the extension and end the string with 2 ~'s
The plugin package is required. Download the plugin package here.
Sample Code:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var util = System.CreateDO("Clintons3D Package/Utility functions");
var folder = "";
var filename = "some preexisting filename";
folder = fso.GetParentFolderName(filename);
filename = fso.GetFileName(filename);
//fso method return of folder or filename is flawed when path is invalid/empty
//causes returned value of plugin to cause tS crash
if(folder=="") folder="";
if(filename=="") filename="";
var defExt = "tga";
var filter = "TGA (*.tga)~*.tga~EXR (*.exr)~*.exr~HDR (*.hdr)~*.hdr~Jpeg (*.jpg)~*.jpg~PNG (*.png)~*.png~TIF (*.tif)~*.tif~All Files (*.*)~*.*~~";
var file = util.FileSaveAsDialog2(folder, filename, filter, defExt);
The default extension can be setup as the first extension for a prexisting filename giving a cleaner result.
var defExt = "bmp";
if(filename) {
var ext = fso.GetExtensionName(filename);
if(ext) {
defExt = ext.toLowerCase();
}
}
var filterArr = {};
filterArr["bmp"] = "Windows Bitmap (*.bmp)~*.bmp~"
filterArr["jpg"] = "JPEG (*.jpg)~*.jpg~"
filterArr["png"] = "Portable Network Graphics (*.png)~*.png~"
filterArr["dds"] = "DirectDraw Surface (*.dds)~*.dds~"
filterArr["dib"] = "Windows Device Independent Bitmap (*.dib)~*.dib~"
filterArr["hdr"] = "High dynamic range (*.hdr)~*.hdr~"
filterArr["pfm"] = "Portable float map (*.pfm)~*.pfm~"
//first filter to match the existing file name
var filter = filterArr[defExt];
for(arrind in filterArr) {
if(arrind != defExt) {
filter += filterArr[arrind];
}
}
filter += "All Files (*.*)~*.*~"
The plugin package is required. Download the plugin package here.
Sample Code:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var util = System.CreateDO("Clintons3D Package/Utility functions");
var folder = "";
var filename = "";
folder = fso.GetParentFolderName(filename);
filename = fso.GetFileName(filename);
//fso method return of folder or filename is flawed when path is invalid/empty
//causes returned value of plugin to cause tS crash
if(folder=="") folder="";
if(filename=="") filename="";
var defExt = "tga";
var filter = "TGA (*.tga)~*.tga~EXR (*.exr)~*.exr~HDR (*.hdr)~*.hdr~Jpeg (*.jpg)~*.jpg~PNG (*.png)~*.png~TIF (*.tif)~*.tif~All Files (*.*)~*.*~~";
var file = util.FileOpenDialog(folder, filename, filter, defExt);
System.Trace(file);
The plugin package is required to use this script. Download the plugin package here.
Code:
util = System.CreateDO("Clintons3D Package/Utility functions");
thedata = util.GetFolderDialog();
System.Alert(thedata);
Pass an initial folder. The dialog will open too, but may not scroll directly too the initial folder.
A blank or invalid path will give the default dialog behavior, the same as GetFolderDialog.
Code:
util = System.CreateDO("Clintons3D Package/Utility functions");
thedata = util.GetFolderDialog2("E:\\OpenSource\\DevApplicationUSD");
System.Alert(thedata);
Get and set a window frame position and size. Update the frame from values set on the node
developed because the trueSpace mouse listener only gives values relative to the active window
//set value on the frame node then run this to update the window
utilitydata = System.CreateDO("Clintons3D Package/Utility functions");
windowFrame = "Project/Windows Manager Space/Frame Window, 2"
utilitydata.UpdateFrameRect(windowFrame);
utilitydata = System.CreateDO("Clintons3D Package/Utility functions");
windowFrame = "Project/Windows Manager Space/Frame Window, 2"
value = utilitydata.GetFrameRect(windowFrame);
obj = eval("(" + value + ")");
left = obj.Rectangle.left;
top = obj.Rectangle.top;
right = obj.Rectangle.right;
bottom = obj.Rectangle.bottom;
//internal measurements? maybe not useful but left in for now
//left = obj.clientRectangle.left;
//top = obj.clientRectangle.top;
//right = obj.clientRectangle.right;
//bottom = obj.clientRectangle.bottom;
utilitydata = System.CreateDO("Clintons3D Package/Utility functions");
windowFrame = "Project/Windows Manager Space/Frame Window, 2"
left = 80; top = 90; width = 640; height = 480;
utilitydata.SetFrameRect(windowFrame, left, top, width, height);
var bWorkAreaSize = true;
var shLockWidth = -1;
var shLockHeight = -1;
WindowsManager.MoveWindow(workwind, left, top, width, height, bWorkAreaSize, shLockWidth, shLockHeight);
utilitydata = System.CreateDO("Clintons3D Package/Utility functions");
var activeWindow = WindowsManager.GetWorkWindow();
var aspect = utilitydata.GetWindowAspect(activeWindow);
System.Trace(aspect)
//aspect 5=anim view, 4=3D, 2=2D, 1=1D
Comes pre-installed in C3D Persistent Install v3 (Get Points Widget, PickFaceWidget2, PickVertexWidget2)
Comes pre-installed Unofficial Updates v10 (Get Points Widget, PickFaceWidget2, PickVertexWidget2)
Installer for the PickSelect script, Get Points Widget, PickFaceWidget, PickFaceWidget2, PickVertexWidget and PickVertexWidget2 described below.
This widget will return a list of mouse intersection points with scene geometry. It's like painting points on the geometry surface.
It uses an updated version of the PickSelect shown below. The new PickSelect has a MinDistance input used to control how close together the points can be in 3D space.
The NodeSelData will contain the last mesh and a colon seperated list of 3D points.
Use this commands after setting the ContinueAt of the PickSelect node.
Widgets.ReplaceWidget('{5C9008D4-B6B3-4359-9E63-18D2FC228A6E}','/Widgets/Tools/GetPointsWidget','Default','','')
var pickselect = "/Scripts/CustomCommands/PickSelect/data"
if(!Node.Exists(pickselect)) return;
var continueAt = System.ThisOwner() + "/Test Widget2"
Node.Value(pickselect, "ContinueAt") = continueAt;
Widgets.ReplaceWidget('{5C9008D4-B6B3-4359-9E63-18D2FC228A6E}','/Widgets/Tools/GetPointsWidget','Default','','')
//remove markers
if(Node.Exists("/Widgets/Active Widgets Layer2/Markers"))
Node.Delete("/Widgets/Active Widgets Layer2/Markers");
var pickselect = "/Scripts/CustomCommands/PickSelect/data"
if(!Node.Exists(pickselect)) return;
//System.Trace(Node.Value(pickselect, "NodeSelData"))
var nodeSelData = Node.Value(pickselect, "NodeSelData");
var nodeSelArr = nodeSelData.split(":");
if(nodeSelArr.length < 2) return;
for(var i=0;i < nodeSelArr.length;i++) {
System.Trace(nodeSelArr[i]);
}
LMB will get 1 point with each click
LMB drag will 'paint' a series of points
Ctrl snap to the nearest point
Shift no effect
RMB to end the widget and run the ContinueAt script
These widgets adds the ability for scripts to gather vertex and triangle selections from the user without the need to enter point edit mode.
The PickSelect contains a data node with the following connectors
The widgets are only active for 1 object at a time. The first selection will make the object active.
Use these commands after setting the ContinueAt of the PickSelect node.
Widgets.ReplaceWidget('{5C9008D4-B6B3-4359-9E63-18D2FC228A6E}','/Widgets/Tools/PickFaceWidget2','Default','','')
Widgets.ReplaceWidget('{5C9008D4-B6B3-4359-9E63-18D2FC228A6E}','/Widgets/Tools/PickVertexWidget2','Default','','')
LMB will select 1 triangle/vertex for PickfaceWidget and PickVertexWidget
LMB will 'paint' select triangles/vertices for PickfaceWidget2 and PickVertexWidget2
Ctrl + LMB will add to the selection
Shift + LMB will remove from the selection
Ctrl + Shift + LMB will toggle the selection for PickVertexWidget and PickFaceWidget - unreliable and only good for click selections
RMB to end the widget and run the ContinueAt script
"PickFace" really means "PickTriangle"
"PickVertex" is really picking a triangle then getting the vertex of that triangle closest to the intersection point.