File: dag_test.javascript

package info (click to toggle)
k3d 0.4.3.0-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 51,716 kB
  • ctags: 81,610
  • sloc: cpp: 283,698; ansic: 64,095; xml: 61,533; sh: 9,026; makefile: 5,282; python: 431; perl: 308; awk: 130
file content (48 lines) | stat: -rw-r--r-- 1,343 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//javascript

/// Boilerplate to determine which document to modify ...
function FindDocument(ScriptName)
{
	if(Document)
			return Document;
	else
			{
					if(Application.documents.length == 1)
							return Application.documents[0];
					else if(Application.documents.length == 0)
							Application.ui.ErrorMessage("You must have an open document to run this script!", ScriptName + ":");
					else
							Application.ui.ErrorMessage("Not sure which document to use ... try using the desired document's Document Window > Tools > Play Script.", ScriptName + ":");
			}
			
	return null;
}

document = FindDocument("dag_test.javascript");
if(document)
	{
		// Start recording changes for undo-purposes ...
		document.StartChangeSet();

		sphere1 = document.CreateObject("Sphere");
		sphere2 = document.CreateObject("Sphere");

		// Link the first sphere's radius property to the second's ...
		document.SetDependency(sphere1.Property("radius"), sphere2.Property("radius"));

		// Finish recording undos ...
		document.FinishChangeSet("DAG Test");

		sphere1.name = "Sphere1";
		sphere2.name = "Sphere2";

		sphere1.position = [-6, 0, 0];
		sphere2.position = [6, 0, 0];

		document.RedrawAll();

		Application.ui.Show(sphere2);
		Application.ui.Message("Modify the Sphere2 radius to see that the Sphere1 radius is linked", "dag_test:");
	}