PCI Example - involute.pci

This example creates an involute form with parameters supplied by the user.

Note that this and other example PCI files can be found in your edge\cam\examples\pci directory.

 

*

* Demonstration PCI

*

* Create an Involute curve with an option to smooth the resultant lines.

*

* This PCI demonstrates:

*

* %SETPACKAGE

* %ASKBOX

* %CALCSIN() COS()

* %IF %ENDIF

* %GOTO %LABEL

* %DISPLAY

* %ADDFREEDIG

* %OPTION

* Using a loop to create data.

* Holding onto a data array

***********************************

*

%setpackage=0

 

**** Set default values ****

 

%calc=diam=10

%calc=ang=0

%calc=eang=360

%calc=deg=30

 

%label=ask

 

%ASKBOX=Diameter=diam=Endangle=eang=Degreeincrement=deg

 

%if[eang]=<0

 %display=End angle must be positive.\

 %goto=ask

%endif

 

%if[eang]<=[deg]

 %display=End angle is less than increment.\

 %goto=ask

%endif

 

%if[deg]=<0

 %display=Degree increment must be greater than 0.\

 %goto=ask

%endif

 

 

 

%CALC=RAD=[diam]/2

 

* Initialising command:- Arc

%INITCOMMAND=cmdh=2,2

%CLEARMODS=[cmdh]

* Setting modifier 'Diameter'

%SETMODIFIER=[cmdh],111,[diam]

* Setting modifier 'Colour'

%SETMODIFIER=[cmdh],1,Green|1

* Setting modifier 'Layer'

%SETMODIFIER=[cmdh],3,88

* Setting modifier 'Style'

%SETMODIFIER=[cmdh],2,Solid|0

%INITDIGINFO=gdh1

* Add Free dig to Digitised input data

%ADDFREEDIG=[gdh1],X0Y0

* Finish Digitised input

%ADDFINISHDIG=[gdh1],[#FINISH]

%EXECCOMMAND=cmdret=[cmdh],[gdh1]

%FREEDIGINFO=[gdh1]

* Initialising command:- Line

%INITCOMMAND=cmdh=2,1

%CLEARMODS=[cmdh]

* Setting modifier 'Polyline'

%SETMODIFIER=[cmdh],155,1

* Setting modifier 'Colour'

%SETMODIFIER=[cmdh],1,Cyan|3

* Setting modifier 'Layer'

%SETMODIFIER=[cmdh],3,88

* Setting modifier 'Style'

%SETMODIFIER=[cmdh],2,Solid|0

%INITDIGINFO=gdh1

* Add Free dig to Digitised input data

%ADDFREEDIG=[gdh1],X[RAD]Y0

*

%LABEL=LOOP

%CALC=ANG=[ANG]+[DEG]

%CALC=LEN=(6.2831853*[RAD])/(360/[ANG])

%CALC=HYP=SQR(([LEN]*[LEN])+([RAD]*[RAD]))

%CALC=HYPANG=ATAN([LEN]/[RAD])

%CALC=REANG=[ANG]-[HYPANG]

%CALC=XCOORD=[HYP]*COS([REANG])

%CALC=YCOORD=[HYP]*SIN([REANG])

 

* Add Free dig to Digitised input data

 

%display=End [eang] degrees : [ang] degrees Coord= x[xcoord] y[ycoord]

 

%ADDFREEDIG=[gdh1],X[XCOORD]Y[YCOORD]

 

%IF[ANG]=>[EANG]%GOTO=endloop

%GOTO=LOOP

%LABEL=endloop

* Finish Digitised input

%ADDFINISHDIG=[gdh1],[#FINISH]

%EXECCOMMAND=cmdret=[cmdh],[gdh1]

***%FREEDIGINFO=[gdh1]

*

* The %FREEDIGINFO line has been removed so that the data handle can be used for the smooth operation.

*%FREEDIGINFO=[gdh1]

*

********** SMOOTH *********

*

%option=Smooth^Yes^no=smooth

%if[smooth]=2

* No smooth required. Ensure data handle is freed before PCI ends

 %FREEDIGINFO=[gdh1]

 %goto=nosmooth

%endif

%calc=tol=0.01

%askbox=Tolerance=tol

*

* Initialising command:- Smooth

%INITCOMMAND=cmdh=2,56

%CLEARMODS=[cmdh]

* Setting modifier 'Tolerance'

%SETMODIFIER=[cmdh],56,[tol]

* Setting modifier 'Colour'

%SETMODIFIER=[cmdh],1,Red|4

* Setting modifier 'Layer'

%SETMODIFIER=[cmdh],3,1

* Setting modifier 'Style'

%SETMODIFIER=[cmdh],2,Solid|0

* Setting modifier 'Continuous'

%SETMODIFIER=[cmdh],43,1

*%INITDIGINFO=gdh1

* Remove INITDIGINFO so that the data handle does not get cleared

%EXECCOMMAND=cmdret=[cmdh],[gdh1]

%FREEDIGINFO=[gdh1]

%label=nosmooth

* Initialising command:- Zoom Port

%INITCOMMAND=cmdh=4,6

%CLEARMODS=[cmdh]

* Setting modifier 'Extents'

%SETMODIFIER=[cmdh],8,1

%INITDIGINFO=gdh1

%EXECCOMMAND=cmdret=[cmdh],[gdh1]

%FREEDIGINFO=[gdh1]