Example of a JScript 2 E! T9 g' d& _% H0 W
var vbOKCancel = 1; 1 C- E" b0 ]1 J0 L2 g" L5 c
var vbCancel = 2;
/ k) N; L% q9 r/ @# U- Svar vbInformation = 64;
, o. G6 C5 h ]* svar Finished=false; 4 t1 @; a/ J6 n& J9 i3 l1 g6 F8 c
Q' C1 t8 o* D0 z
var WSHShell = new ActiveXObject("WScript.Shell"); 1 r* {; Z4 F3 O( D
- N1 O) a+ J. y) J& B, [% Ovar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
$ O- Y$ e/ z. t2 A6 Y
0 z+ n7 B+ o5 Y; c8 `9 V) rsimple.SetLicenseType("Runtime"); # F) G. a$ n# ~, F4 w0 s
/ E7 J2 ^1 Q/ a- j* ?9 X9 Utry ( t3 d- U3 @. c+ {
{ , k, r) B0 d( u
// Enter the path to a model file! 0 L: g9 h# I! i7 z* {6 K+ I+ y
simple.LoadModel("C:\\Models\\Test.spp");
3 D6 W' g% ]8 i' x9 c# U} " m/ t7 R" Y) h; W3 |4 }/ f$ {6 ?
catch (e)
9 E' B: a8 J# @2 K! Y{
& i+ P/ f. [% }" C+ F- \ ? WScript.Echo("Could not load Model!"); * ]; ?( a" c+ Z0 m5 D4 R
WScript.Quit(); o$ y# @: f' ^8 G6 I5 H
} 4 ^: P6 m/ g. H9 s! u, G' ~) y
$ g F0 X+ k* W8 R! U# z& H
try ; Y9 n8 d( L, E/ D, k9 k5 ^; n
{ & ^! i/ r+ y+ L z
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
4 r* L* V; z' H9 U r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
; e* ?: ?" l' p! o( a1 N if (r == vbCancel)
% v9 y- T% W: `8 k {
q# c3 J7 @) \ simple.CloseModel();
' _' _2 k' h; ~ ]3 U5 j WScript.Quit();
8 H, K/ h3 ~- _! x: t }
% n. q/ S9 n1 X' p8 q$ V& G}
+ P& C7 O% {& j0 E, t! D6 q + m8 L0 k; P" V( [9 V# X& _
simple.StartSimulation(".Models.Frame.EventController"); ; Q; o0 G9 D5 M2 v3 y* O5 _
4 E) t* U, H( X& W6 [' @7 a" C1 qif (simple.IsSimulationRunning()) 5 [- L4 p6 S3 f
WScript.Echo("Simulation is running!");
7 k: \7 ^1 g+ a" |* T' g" H* R
5 L4 I! B) U( S) r* Z// Wait until simulation is finished 4 p1 A# r/ _+ A- y" I6 d
while (!Finished) WScript.Sleep(2000);
% U `# V: g: x 9 v2 ?6 _, E# ?3 m& l! u/ D
simple.CloseModel(); 8 p8 z7 m. l8 n( M' p
simple.Quit(); * }: U+ y; y' @+ w
WScript.Quit();
1 m! ~3 B B. Q: `
$ E: B, ^+ q7 D1 F4 q ; ~& M8 d( L8 K: e0 C) J2 W& A
function RemoteControl_SimulationFinished() ) `$ o2 h$ g3 D8 q
{ & e9 ~- h0 F+ ~3 P
WScript.Echo("Simulation Finished!"); |