
! script name: conics.d/helixfromcir
! topic: make a helix entity from a circle.

!A
!A NAME:
!A
!A 	Helix from circular arc.
!A
!A DESCRIPTION:
!A
!A 	This script makes a helix from a circular arc.
!A
!B INSTRUCTIONS:
!B
!B	PICK CIRCLE:  Pick the circle which determines the radius and angles.
!B
!B 	Z START: Enter the Z coordinate of the start point of the helix.
!B
!B 	Z END: Enter the Z coordinate of the end point of the helix.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: helix ")

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

ActivateUndo
Start:!
Stat=SetInputFormat("n4","")

C1=PickSpecificEnt("PICK CIRCLE",WsPickCircles)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(C1) THEN Line_loop
Pick_para= LastPickPara

Stat=SetPickReturn(WsGeometryZ)
Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Zstart)
Zstart=GetValue("Z START",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Stat=SetPickReturn(WsGeometryEnd)

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Zend)
Zend=GetValue("Z END",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Stat=SetPickReturn(WsGeometryEnd)

IF Pick_para<= 0.5 THEN
	H1=HelixFromCircle(C1,Zstart,Zend)
ELSE
	H1=HelixFromCircle(C1,Zend,Zstart)
END IF

ActivateUndo
Stat= AdvanceUndoNumber("helix")
Stat= AddItemToUndo(WsUBCreateMode,H1)


GOTO Start


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

