
! script name: offsets.d/lthdiafill

stat=ChangeLabelStr("ScriptNameStatus","Function: line chain ")

DIM Answer$[256]
DIM Destination$[256]
DEG

Stat=RemoveFile("tempdata")
File$= "tempdata"

Contour=CreateGroup("CONTOUR",WsContourGroup)

Smode= WsMultipleAuto

Pick_loop:!
Stat=SetPickMask(WsPickNoSurf)
E1=PickEntity("PICK AN ELEMENT OF THE SHAFT")
IF (ExitScript(Destination$)) THEN Leave
Number= GroupCount(Contour)

Stat=Highlight(E1,WsPickPen,WsDirArrowOff)

Ps=ContStartPt(E1)
Pe=ContEndPt(E1)

Group= ParentGroup(E1,0)
Stat= GroupName(Group,Name$)
stat=SetInputFormat("n4a1=",",I,A,")

Dia=GetValue("SHAFT DIA" ,Answer$)

Xs=XPointValue(Ps)
Ys=YPointValue(Ps)
Zs=ZPointValue(Ps)

Xe=XPointValue(Pe)
Ye=YPointValue(Pe)
Ze=ZPointValue(Pe)

P1=PointXYZ(Xe,Ye,Ze)
P2=PointXYZ(Xe,Dia,Ze)

L1=LineTwoPoints(P1,P2,WsTRIMMED)

Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)

P1=PointXYZ(Xe,Dia,Ze)
P2=PointXYZ(Xs,Dia,Ze)

L2=LineTwoPoints(P1,P2,WsTRIMMED)

Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)

P1=PointXYZ(Xs,Dia,Ze)
P2=PointXYZ(Xs,Ys,Ze)

L3=LineTwoPoints(P1,P2,WsTRIMMED)

Smode= WsMultipleAuto
Direction=WsForward
Estart=L1
Eend=L3

Number= GroupCount(Contour)
Econnect= GroupElement(Contour,number)

Group=AutoSequence("TempContour",Estart,Eend,Econnect,Smode,Direction,2,WsAutoseqPen)

IF (ValidGeometry(Group)) THEN
		Stat=CombineGroups(Contour,Group)
		Stat=DeleteEntity(Group)

!#Contour1=Name$
!#IF (ExitScript(Destination$)) THEN Leave
!#Contour1=CreateGroup
!#Contour1=FindNamedGrp(E1)
!#Contour2=PickGroupEnt("PICK NEXT CONTOUR ")
!#IF (ExitScript(Destination$)) THEN Leave
!#Contour2=contour2

!#New_contour=JoinContours(Contour1,Contour2)

END IF
Leave:!
Stat=SetPickMask(WsPickGeometry)
  N1=GroupCount(Contour)
  IF (N1=0) THEN
  Stat=DeleteEntity(Contour)
	  ELSE
  Stat=AutoNumberCont(Contour)
	END IF

Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
	 ELSE
		  LOAD Destination$
		  END IF
		  END

