### Example of a Line Feature Created from a Scan Segment

This topic provides an example of how to use PC-DMIS expression language, specifically the line segment functions, to export start and end point numbers for line segments within a scan and then to create your own line feature by using the extracted points within a constructed feature. You can use the same principles covered in this example to create an arc segment from a scan as well.

Suppose your part program has a scan feature named SCN1 that looks like this:

SCN1 =FEAT/SCAN,LINEAROPEN,SHOW HITS=NO,SHOWALLPARAMS=YES

EXEC MODE=RELEARN, NOMS MODE=FIND NOMS,CLEARPLANE=NO,SINGLE POINT=NO,THICKNESS=0

FINDNOMS=5,SELECTEDONLY=NO,USEBESTFIT=NO,PROBECOMP=YES,AVOIDANCE MOVE=NO,DISTANCE=0,CAD Compensation=NO

DIR1=VARIABLE,

HITTYPE=VECTOR

INITVEC=0,-1,0

DIRVEC=1,0,0

CUTVEC=0,0,1

ENDVEC=0,-1,0

PLANEVEC=-1,0,0

POINT1=100,0,-5

POINT2=70,0,-5

MEAS/SCAN

BASICSCAN/LINE,SHOW HITS=NO,SHOWALLPARAMS=YES

<100,0,-5>,<70,0,-5>,CutVec=0,0,1,DirVec=1,0,0

InitVec=0,-1,0,EndVec=0,-1,0,THICKNESS=0

FILTER/NULLFILTER,

EXEC MODE=RELEARN

BOUNDARY/PLANE,<70,0,-5>,PlaneVec=-1,0,0,Crossings=2

HITTYPE/VECTOR

NOMS MODE=FINDNOMS,5

ENDSCAN

ENDMEAS/

To create a line from this scan you will need to use the LINESEGMENTSTARTINDEX and LINESEGMENTENDINDEX functions to pull out the data, like this:

ASSIGN/LINESTARTINDEX = LINESEGMENTSTARTINDEX("SCN1", 1, 0.4,0.1)

ASSIGN/LINEENDINDEX = LINESEGMENTENDINDEX("SCN1", 1, 0.4, 0.1)

This tells PC-DMIS to go to the scan named "SCN1", and from its first line segment pull out the starting and ending index values that fall within the defined tolerances. It then assigns those index values to variables named LINESTARTINDEX and LINEENDINDEX.

Once you have the start and ending index values for the line segment assigned to variables, you can use those variables within a constructed line, like this:

LIN4 =FEAT/LINE,RECT,UNBND

THEO/100.225,0,-5.011,1,0,0

ACTL/100.225,-0.005,-5.011,1,-0.0000388,0

CONSTR/LINE,BF,2D,SCN1.HIT[LINESTARTINDEX..LINEENDINDEX],,

OUTLIER_REMOVAL/OFF,3

FILTER/OFF,WAVELENGTH=0

Notice that in the highlighted code from the line feature above, PC-DMIS uses the starting and ending numbers you pulled out of the scan to create the feature: SCN1.HIT[LINESTARTINDEX..LINEENDINDEX]