
! script name: points.d/circlelimitpt
! topic: create point along the axis of a circle

!A
!A NAME:
!A
!A 	Circle Axis Limit Point
!A
!A DESCRIPTION:
!A
!A 	This script creates a point along the axis of a circle.
!A
!B INSTRUCTIONS:
!B
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: circle axis limit point ")

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


DEG



ActivateUndo
Stat=SetInputFormat("n4","")
Stat=SetXyzInput(WsXyzInput)


Circle_loop:!
Stat=SetInputFormat("n4","")
Circle=PickSpecificEnt("PICK CIRCLE",WsPickCircles)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Circle) THEN Circle_loop


E1=PickEntity("PICK LIMIT ENTITY")
IF (ExitScript(Destination$)) THEN Leave


Active_workplane=0
Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane=1

Stat= SetWorkplane(Circle)
Pc= CircleCenter(Circle)
L1= EntityMaxMin(E1)
P1= ParameterPt(L1,0.0)
P2= ParameterPt(L1,1.0)
Z1= ZPointValue(P1)
Z2= ZPointValue(P2)
Zc= ZPointValue(Pc)
IF ABS(Z1-Zc)< ABS(Z2-Zc) THEN
	Z_height= Z2-Zc
ELSE
	Z_height= Z1-Zc
END IF
Pt=PtIncrXyz(Pc,0.0,0.0,Z_height)
L2= LineTwoPoints(Pc,Pt)
Stat=DeleteEntityList(Pc,L1,P1,P2)

IF Active_workplane THEN
        Stat=SetWorkplane(Work)
ELSE
        StdWorkplane
END IF

Stat=SetLastPoint(Pt,WsXyzInput)
ActivateUndo
Stat= AdvanceUndoNumber("circle axis limit point")
Stat= AddItemToUndo(WsUBCreateMode,L2)
Stat= AddItemToUndo(WsUBCreateMode,Pt)
GOTO Circle_loop

Leave:!
Stat=SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
