Example of a JScript
: a- U* y, J; Dvar vbOKCancel = 1; ) p# s* X( C% _$ V
var vbCancel = 2; * Q2 L$ T4 W1 Z( E2 ]2 @
var vbInformation = 64; ' m$ }0 k7 o% M% l T9 t- C& U; n
var Finished=false; - F/ W6 B ]2 v, j8 o7 j
8 [5 ^- E- m# N: {0 o# n, z
var WSHShell = new ActiveXObject("WScript.Shell"); : w8 s5 o/ \1 H9 g" d* X6 T
% `. a/ S: R2 y! e/ a1 m
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 5 I3 r7 C: U1 G" I1 Y
( b% T9 @, [1 ]. G3 @simple.SetLicenseType("Runtime"); : l, T, D& K2 h g& @8 i O4 v
- J, `/ E% m @5 n; t' P7 P
try ! j6 g8 e7 {6 a1 \& Q
{ & L) X N, R7 {1 A( d) f3 ^
// Enter the path to a model file!
9 e/ W% c( s1 d9 ^6 K simple.LoadModel("C:\\Models\\Test.spp");
7 U0 P4 q8 i. w- C! [* e% z$ v} " }" H% @/ t9 q1 @ S
catch (e)
1 o3 C" v1 ] b{ , b1 N; G1 v& D" r9 M
WScript.Echo("Could not load Model!");
! O5 s1 Y, J# X: I) P WScript.Quit(); , Y9 O, l/ d$ H) [
} & j$ Y# p- D$ @4 l
5 Z$ \. }4 Z, U) e, `1 ^! g
try , r- x: i% w3 N4 }% i* p- H
{
- z7 M. u2 Q- M4 u7 x$ n! m simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
3 {/ K r1 a: o: o$ e" _; F7 B r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 2 b: L3 U: N0 z: S& ^
if (r == vbCancel) ' M8 G2 E$ j- g0 h ~9 d" J
{ ; n" W. n& b. s1 j! ~4 W7 u0 [
simple.CloseModel();
6 q' R0 c8 W2 L. |8 Q3 T, g WScript.Quit(); : h% f+ I; x' G1 P$ ~) X
}
4 ?" U; T1 h* W}
0 q# B( I: }$ ]$ p0 c
f7 D( A9 x% W; Usimple.StartSimulation(".Models.Frame.EventController"); ) b( z" b; n2 h: k# L# m, n
' P, {- I: W8 @- g: Y6 R" Hif (simple.IsSimulationRunning()) / Y! } Y! P9 W- B1 b! I
WScript.Echo("Simulation is running!"); " C3 d3 U) I7 r
8 A; Q! a+ D" E, Y3 J, V// Wait until simulation is finished
5 K/ k" d" Y( s( fwhile (!Finished) WScript.Sleep(2000); % _/ J( @# }3 q9 s) _/ N% y
; D C5 ~6 d2 e# b' Xsimple.CloseModel();
! V" K3 n% `. Q/ E9 c- hsimple.Quit();
' p% _$ b( B7 B! j5 O4 O' T! NWScript.Quit();
( ^1 h9 Z* G3 F( D7 P 0 h" B: j& `' R
6 ]0 b! D4 g( ?6 l' Y
function RemoteControl_SimulationFinished() " h; A( q, U. y$ m" D, D! P
{
) l: A- k5 V% H* {& O2 c5 H WScript.Echo("Simulation Finished!"); |