Collada plugin for
After Effects

More info here
Plugins and Scripts > trueSpace > Development

Widgets and Windows

Save-As Dialog for trueSpace

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

November 22, 2009

Save As Dialog (v2) for trueSpace

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);

  • folder - can be blank
  • filename - full path or just file name
  • filter - first item is the default extension shown
  • defExt - can be blank, used if user does not enter an extension

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 (*.*)~*.*~"
June 21, 2018

Open File Dialog for trueSpace

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);

  • folder - can be blank
  • filename - full path or just file name
  • filter - first item is the default extension shown
  • defExt - can be blank, used if user does not enter an extension
January 3, 2021

Folder Dialog for trueSpace

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);

October 2024 - GetFolderDialog2

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);

May 19, 2013

Window Frame Update and Absolute Positioning

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

update window from node value

    //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);
                    

read window position

    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;

set window position (use WindowsManager.MoveWindow instead)

    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);
                    

undocumented WindowsManager.MoveWindow is more flexible than SetFrameRect

    var bWorkAreaSize = true;
    var shLockWidth = -1;
    var shLockHeight = -1;
    WindowsManager.MoveWindow(workwind, left, top, width, height, bWorkAreaSize, shLockWidth, shLockHeight);

get window aspect

	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

Notes:

  • if a window is snapped to another window, it will move but snap back if the parent window is changed.
  • if won't snap back if the new position is not touching the parent window borders
  • position is relative to the main trueSpace window upper left.
  • set position probably only works on floating windows?
  • position values can be negative
September 11, 2020

Widget Tools Installer

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.

Clintons3dPlugin.rsx v.1638452 required

June 28, 2024

  • updated installer
  • GetPointsWidget updated to use new ctrl snapping option
  • installer options to include each widget

Get Points Widget

This widget will return a list of mouse intersection points with scene geometry. It's like painting points on the geometry surface.

GetPointsWidget

PickSelect

Clintons3dPlugin.rsx v.1638452 required

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.

Installation:

  • Place GetPointsWidget inside /Widgets/Tools
  • Place PickSelect inside /Scripts/CustomCommands

Widget Commands:

Use this commands after setting the ContinueAt of the PickSelect node.

Widgets.ReplaceWidget('{5C9008D4-B6B3-4359-9E63-18D2FC228A6E}','/Widgets/Tools/GetPointsWidget','Default','','')

Example

Test Widget
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','','')
Test Widget2
//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]);
}

Widget Interactions:

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

June 2024

  • ctrl snap to vertices
  • esc to cancel modified from the UU

Triangle and Vertex Pick Widgets

These widgets adds the ability for scripts to gather vertex and triangle selections from the user without the need to enter point edit mode.

PickFaceWidget2

PickVertexWidget2

PickFaceWidget

PickVertexWidget

PickSelect

Clintons3dPlugin.rsx v.1638423 required

pickselect

The PickSelect contains a data node with the following connectors

  • ContinueAt - script that will be run after RMB exiting the widget
  • FaceIndex - index of the last triangle selected
  • HoverColor - the color used in the markers to indicate hover state
  • NodeSelData - a colon delimited string that holds the object name and a list of triangle indices for the PickFaceWidget or a list of vertex indices for the PickVertexWidget.
  • PositionXYZ - the trace point of the selection that intersects the last triangle selected.
  • SelectedColor - the color used to highlight selected triangles/vertices

The widgets are only active for 1 object at a time. The first selection will make the object active.

Installation:

  • Place PickFaceWidget2 and PickVertexWidget2 inside /Widgets/Tools
  • Place PickSelect inside /Scripts/CustomCommands

Widget Commands:

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','','')

Widget Interactions:

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.

October 23, 2020

  • new paint selection widgets PickFaceWidget2, PickVertexWidget2
  • new cursors for triangle and vertex widgets
  • widgets read dot size from the UI
October 13, 2020
June 5, 2013