Example of a JScript
. E' B6 Y w, y _' h! H* Z) Gvar vbOKCancel = 1; # |# i% a1 ^9 M8 a
var vbCancel = 2; ; `+ K! W' v6 p- ^, Y; a5 F3 O
var vbInformation = 64; . q; G9 y7 o4 \/ B: v V
var Finished=false; 0 [* q$ d. G% t: C$ |
h' o& t$ A+ }' }3 gvar WSHShell = new ActiveXObject("WScript.Shell"); ' I" E% C. F) P1 J3 ~2 r$ n. y% ~
" g1 p$ J' y% A7 j1 G8 H( y- Tvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); - d* e( d" A! |! w# C4 R
6 }! d# @# t5 a; \. k8 O. G4 I) lsimple.SetLicenseType("Runtime"); 6 a% _2 L0 u7 n
( L! ^4 g |8 K9 ~5 @try
6 M4 `5 }0 h4 o/ a{ : l1 j4 ^" d6 r! B4 k1 H
// Enter the path to a model file! 0 B- f4 }: e. C* I7 y: V
simple.LoadModel("C:\\Models\\Test.spp");
]5 ]( E. A. y} / n' p4 U7 n1 }, w# Y% M( }
catch (e)
% c% B: @$ {6 p5 F! Z{ # C7 v8 h' |# ~* G9 u" Q
WScript.Echo("Could not load Model!"); * w6 l- s( u, H$ v* [
WScript.Quit();
: K7 U$ G2 U7 R. j* }% `}
& X% O; t" `" L1 n6 u
A; S% ^3 a. i7 [2 Ntry
7 d/ G3 D* I0 y- U6 e$ f{ 0 f* s7 R; M% y* @' F. h/ Y+ ^4 ^
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ]9 y% `5 O' e
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
2 ?* z( x: |& P& O. k- {6 z if (r == vbCancel)
7 ^ \& J: E/ @ { ' p, O* y* c, `7 ?1 K! K
simple.CloseModel();
1 {& \7 y4 b: B5 ]: ? WScript.Quit();
! ?* X7 K! B1 q$ \ }
( Z9 G# l M, k, F7 ~; f} 8 U2 l+ s( m4 D6 w
5 C; U8 j; H: x1 q1 e
simple.StartSimulation(".Models.Frame.EventController");
+ G* C, C& U$ T1 ? y9 L
& I& S6 n4 Y6 `$ E6 ]4 `" F2 f3 [if (simple.IsSimulationRunning()) 1 {. Y1 Y; o% ?+ a
WScript.Echo("Simulation is running!"); M6 L* ~ o5 r' [) S
2 ~8 m* F$ y2 B% e# h0 u
// Wait until simulation is finished
- D: w; `0 k8 ] ^, ^+ Pwhile (!Finished) WScript.Sleep(2000); % Y2 \8 w/ ~" l$ U5 U
( K* X+ L$ T8 U* E! L+ Y9 y
simple.CloseModel();
6 H3 Z% b3 [( w3 E: _ @/ I9 psimple.Quit();
0 L2 `7 w7 H7 `- IWScript.Quit(); 3 `$ p# |. E* n0 }- S1 N
4 `: a+ x8 E' t; \ 3 a1 Q3 ?7 Y1 Z
function RemoteControl_SimulationFinished() 5 X( r3 r/ \7 }) ^6 a8 t
{
+ E1 Q* a8 ~6 s# C* d1 {. z& k WScript.Echo("Simulation Finished!"); |