<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>RemoteControl_en.htm</TITLE>
<style>body{font: 10pt Verdana,sans-serif;}</style>
</HEAD>
<BODY LANG="en-US">
<PRE>

Last update: 2013-01-04

<h2>RemoteControl gCAD3D</h2> 
 
<A HREF='#rc1'>What is RemoteControl</A>

<A HREF='#PRI'>PRINT</A>(text)          // print text (into messagewindow)
<A HREF='#ADD'>ADD</A>(code)            // process and store source-objects
<A HREF='#ADF'>ADDFILE</A>(filNam)      // process and store cad-objects in file 
<A HREF='#MOD'>MOD</A>(code)            // modify cad-code, update
NEW                  // clear whole model
MODSIZ(newsize)      // change modelsize; use 'END' to update.
END                  // reprocess whole model

<A HREF='#SYM'>GETSYMDIR</A>(sym)       // returns path for symbolic-directory <sym>
<A HREF='#SYM'>SETSYMDIR</A>(sym,path)  // set new symbolic-directory
<A HREF='#SYM'>DELSYMDIR</A>(sym)       // delete symbolic-directory <sym>

<A HREF='#LOA'>LOAD</A>(modelname)      // clear and load new model (native, step, iges, dxf ..)
<A HREF='#LSM'>LOADSM</A>(submodel)     // load submodel (can only load native models (.gcad))

<A HREF='#SAV'>SAVE</A>                 // save model with current modelname
<A HREF='#SAV'>SAVE</A>(new_modelname)  // save model with given modelname

ZOOMALL              // set zoomfactor to view all objects
<A HREF='#VIE'>VIEW</A>(center, scale, rotAng, tiltAng)  // define view;
<A HREF='#SHO'>SHOW</A>(obj,off)        // hide object
<A HREF='#SHO'>SHOW</A>(obj)            // show hidden object
<A HREF='#ATL'>ATTL</A>(linetypNr,objects) // change linetype for objects
<A HREF='#ATS'>ATTS</A>("code",objects) // change surface-attribute
<A HREF='#LDT'>LOADTEX</A>(texFilNam)   // load texturefile (image)

ERRCLR               // returns errcode and clears error; 0=OK
GETMODSIZ            // get current modelsize
<A HREF='#GOI'>GETOBJINDNXT</A>(P)      // get next free object-index for points
<A HREF='#GLN'>GETLNR</A>               // get current lineNr
<A HREF='#DFO'>DELFOLL</A>(lnr)         // delete all lines following lineNr'
<A HREF='#USE'>USER</A>                 // get object from user (selection); Esc: empty.
<A HREF='#DUM'>DUMP</A>(list)           // dump list to console-window
<A HREF='#MOD'>MODE</A>(widget,off|on)  // hide or show subwindows: browser, menu, toolbars ..


__________________________________________________________________________
<p><a name="rc1"></a></p>
What is RemoteControl

With RemoteControl you can control the cad-program gCAD3D from programs.
All programming languages can be used, even shell-scripts.
For input and output 2 pipes are used.
Input and output is done with textcodes, not binary.

How does it work:
The inputpipe is <home>/gCAD3D/tmp/CTRLpin;
the outputpipe is <home>/gCAD3D/tmp/CTRLpout.

You can send commands from a terminalprogram (xterm oder gnome-terminal)
  to gcad (example: clear active model):
echo 'new' > ~/gCAD3D/tmp/CTRLpin


Send a commandfile to remoteControl:
 - put the following 6 lines into  file t1.dat:
MODE(BRW,off)
new
add(P1=P(100 0 0))
add(C1=P1 50)
zoomall
#eof

Send the file:
cat t1.dat > ~/gCAD3D/tmp/CTRLpin


Receiving output from gcad (eg display the output in a terminal-window):
cat  ~/gCAD3D/tmp/CTRLpout

Gcad sends after each command at least a new-line-character (ascii 10).


<i><b>Programming Examples:</b></i>
<A HREF="test_java.java">test_java.java</A>



__________________________________________________________________________
<p><a name="PRI"></a></p>
PRINT(text)          // print text (into messagewindow)

Objects (points, vectors, variables) are decoded.

Example:
echo 'print("TestPrint 1")' > ~/gCAD3D/tmp/CTRLpin
# display coordinates of point p1 and vector D1 with:
echo 'print("P1 = ",P1," D1 = ",D1)' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="GLN"></a></p>
<p><a name="DFO"></a></p>
GETLNR               // get current lineNr
DELFOLL(lnr)         // delete all lines following lineNr

# lineNr from GETLNR can eg later be used for DELFOLL
#   (delete all objects created after getting 'GETLNR')


__________________________________________________________________________
<p><a name="GOI"></a></p>
GETOBJINDNXT(typ)     // get next free object-index for points


# example: get next free DB-index for type point:
echo 'GETOBJINDNXT(P)' > ~/gCAD3D/tmp/CTRLpin
# See list of <a href="CAD_Base_en.htm#Codeletters">objecttypes</a>


__________________________________________________________________________


__________________________________________________________________________
<p><a name="ADD"></a></p>
ADD(code)            // process and store source-objects

# code is any valid gcad-text; see <a href="CAD_Base_en.htm#Codes">Codes</a>
# eg create a point with:
echo 'add(P1=P(100 0 20))' > ~/gCAD3D/tmp/CTRLpin

__________________________________________________________________________
<p><a name="ADF"></a></p>
ADDFILE(filNam)      // process and store cad-objects in file

echo 'addfile("t1")' > ~/gCAD3D/tmp/CTRLpin

Example for file t1:
MODE(MEN,off)
MODE(BRW,off)
MODE(BAR1,off)
MODE(BAR2,off)
new
add(P1=P(100 0 0))
add(C1=P1 50)
zoomall
#eof


__________________________________________________________________________
<p><a name="MOD"></a></p>
MOD(code)            // modify cad-code, update


Example:
echo 'MOD(V1=70)' > ~/gCAD3D/tmp/CTRLpin

# modifies the line "V1=50" in the existing code:
# and updates the variable V1 and the circle C1.

P1=P(100 100 0)
V1=50
C1=P1 V1


__________________________________________________________________________
<p><a name="SYM"></a></p>
GETSYMDIR(sym)       // returns path for symbolic-directory <sym>
SETSYMDIR(sym,path)  // set new symbolic-directory
DELSYMDIR(sym)       // delete symbolic-directory <sym>


# get absolute path for (existing) symbol "Data"
echo 'GETSYMDIR("Data")' > ~/gCAD3D/tmp/CTRLpin

# set new symbol "myPath" to path "/tmp/gcad/"
echo 'SETSYMDIR("myPath","/tmp/gcad/")' > ~/gCAD3D/tmp/CTRLpin

# delete symbol "myPath"
echo 'DELSYMDIR("myPath")' > ~/gCAD3D/tmp/CTRLpin

# clear error
echo 'ERRCLR' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="LOA"></a></p>
LOAD(modelname)      // clear and load new model (native, step, iges, dxf ..)


Load models; filename can be symbolic, relativ or absolut.
# Example symbolic-filename:
echo 'load("Data/sample_area1.gcad")' > ~/gCAD3D/tmp/CTRLpin
# Example relative-filename (using current symbolic directory):
echo 'load("../dat/sample_area2.gcad")' > ~/gCAD3D/tmp/CTRLpin
# Example absolute-filename:
echo 'load("/tmp/test1.gcad")' > ~/gCAD3D/tmp/CTRLpin


echo 'MODSIZ(10000)' > ~/gCAD3D/tmp/CTRLpin
echo 'END' > ~/gCAD3D/tmp/CTRLpin


<p><a name="LSM"></a></p>
LOADSM(submodel)     // load submodel (can only load native models (.gcad))

# submodels need to be in a symbolic directory. See SETSYMDIR.
# Example load submodels, use submodels:
echo 'new' > ~/gCAD3D/tmp/CTRLpin
echo 'loadsm("Data/sample_mod_blech1.gcad")' > ~/gCAD3D/tmp/CTRLpin
echo 'loadsm("Data/sample_mod_screw1.gcad")' > ~/gCAD3D/tmp/CTRLpin
echo 'loadsm("Data/sample_mod_nut1.gcad")' > ~/gCAD3D/tmp/CTRLpin
echo 'add(M20="sample_mod_blech1" P(0 10 0))' > ~/gCAD3D/tmp/CTRLpin
echo 'add(M21="sample_mod_screw1" P(30 36.5 67))' > ~/gCAD3D/tmp/CTRLpin
echo 'add(M22="sample_mod_nut1" P(36 36.5 67))' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="SAV"></a></p>
SAVE                 // save model with current modelname
SAVE(new_modelname)  // save model with given modelname

# save active model as "test1.gcad" in symbolic direcory "Data". See SETSYMDIR.
echo 'save("Data/test1.gcad")' > ~/gCAD3D/tmp/CTRLpin
echo 'save' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="VIE"></a></p>
VIEW(center, scale, rotAng, tiltAng)  // define view;

# change view-scale
echo 'view(0.25)' > ~/gCAD3D/tmp/CTRLpin

# change view by rotation-angle and tilt-angle (degrees)
echo 'view(ang(45) ang(30))' > ~/gCAD3D/tmp/CTRLpin

# move view (change center-of-screen-point)
echo 'view(P(38 49 7))' > ~/gCAD3D/tmp/CTRLpin

__________________________________________________________________________
<p><a name="SHO"></a></p>
SHOW(obj,off)        // hide object
SHOW(obj)            // show hidden object


# hide line L21
echo 'show(L21,off)' > ~/gCAD3D/tmp/CTRLpin

# show hidden line L21
echo 'show(L21)' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="DUM"></a></p>
DUMP(list)           // Dump list to console-window

DUMP("GA")           // dump Grafic_Attributes_list
DUMP("DL")           // dump display-list
DUMP("AT")           // dump linetypetable
DUMP("TX")           // dump textures
DUMP("SD")           // dump all symbolic directories

# dump Grafic_Attributes_list
echo 'DUMP("GA")' > ~/gCAD3D/tmp/CTRLpin
# dump display-list
echo 'DUMP("DL")' > ~/gCAD3D/tmp/CTRLpin
# dump linetypetable
echo 'DUMP("AT")' > ~/gCAD3D/tmp/CTRLpin
# dump textures
echo 'DUMP("TX")' > ~/gCAD3D/tmp/CTRLpin
# dump all symbolic directories
echo 'DUMP("SD")' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="MOD"></a></p>
MODE(widget,off|on)
Hide /restore menu, browser, upper toolbar, messagebar.

echo 'MODE(MEN,off)' > ~/gCAD3D/tmp/CTRLpin
echo 'MODE(BRW,off)' > ~/gCAD3D/tmp/CTRLpin
echo 'MODE(BAR1,off)' > ~/gCAD3D/tmp/CTRLpin
echo 'MODE(BAR2,off)' > ~/gCAD3D/tmp/CTRLpin
# Restore messagebar.
echo 'MODE(BAR2,on)' > ~/gCAD3D/tmp/CTRLpin



__________________________________________________________________________
<p><a name="ATL"></a></p>
ATTL(linetypNr,objects)             // apply predefined linetype to object


# linetypNr 0 - 12 are predefined in file ~/gCAD3D/cfg/ltyp.rc
# See <a href="Settings_en.htm#Linetypes">Defaultsettings</a>

# use linetypNr=8 for L21 and L22
echo 'ATTL(8,L21,L22)' > ~/gCAD3D/tmp/CTRLpin

# change/create linetype (G<linetypNr> = color,linetyp,thick)
# create linetype G13: green, full-line, thick=4 with:
echo 'add(G13=3,0,4))' > ~/gCAD3D/tmp/CTRLpin

# set linetypNr=13 for L21 and L22
echo 'ATTL(13,L21,L22)' > ~/gCAD3D/tmp/CTRLpin



__________________________________________________________________________
<p><a name="ATS"></a></p>
ATTS("code",objects)                          // change surface-attribute


Examples:
# set surface A21 symbolic (not shaded)
echo 'ATTS("S" A21)' > ~/gCAD3D/tmp/CTRLpin

# reset previous color
echo 'ATTS("C" A21)' > ~/gCAD3D/tmp/CTRLpin

# set color green (red-0, green-255, blue-0)
echo 'ATTS("C00ff00" A21)' > ~/gCAD3D/tmp/CTRLpin

# set transparent  (T0=reset, T1=half transparent, T2=full transparent)
echo 'ATTS("T2" A21)' > ~/gCAD3D/tmp/CTRLpin

<p><a name="LDT"></a></p>
# load texture and make active. Textures must be in symbolic directory.
echo 'LOADTEX("DIR_BMP/Ziegel1.bmp")' > ~/gCAD3D/tmp/CTRLpin

# apply texture to surface A21; set hor./vert.scales to "0.5,0.5".
# ATTS("Xscale,offset,angle",objects) // apply active texture
echo 'ATTS("X0.5,0.5" A21)' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="USE"></a></p>
USER                                // get object from user (selection); Esc: empty.


# get user-selection;
echo 'USER' > ~/gCAD3D/tmp/CTRLpin
# returns "SEL(P(-3.244327 -10.077265 0.000000))"  for indicate position or
# returns "SEL(C16)"                               for selection of obj C16 or
# returns "SEL()"                                  for key esc pressed.



</PRE>
</BODY>
</HTML>
