
! script name: vsolids.d/entrevolution
! var_topic: generate solid of revolution by rotating an entity about an axis

!A
!A NAME:
!A
!A 	Entity Revolution  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script generates a solid of revolution by rotating an entity
!A 	about an axis.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR: Pick the contour to be used to generate a solid of
!B 		revolution.
!B
!B 	STARTING ANGLE: Enter the starting angle of the solid of revolution.
!B
!B 	ANGULAR EXTENT: Enter the number of degrees and the direction
!B 		( + CCW, - CW) from the starting angle to the ending angle.
!B 		The angular extent determines the ending angle.
!B
!B 	PICK AXIS LINE: Pick the line to be used as the axis of the revolution.
!B
!B 	ORIENTATION POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the
!B 		orientation point of the revolution.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!C NOTES:
!C
!C 	The U contours of a revolution are the contour and the V contours
!C 	are the circles.
!C
!# see also - points.d/xyzinput.hlp

Stat=ChangeLabelStr("ScriptNameStatus","Function: entity revolution ")

DIM Destination$[256]
DIM Answer$[256]
DIM Axis_line$[256]
DIM Element$[256]
DIM Name$[256]
DIM Angle_var$[256]
DIM Sangle_var$[256]


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

ActivateUndo
Astart= 0.0
Angle= 180.0

Pick_line:Axis_line=PickSpecificEnt("PICK AXIS LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Axis_line) THEN Pick_line
Stat= EntityNameCheck(Axis_line,Axis_line$)

stat= SetAngleEquals(Astart)
Astart=InputAngle("STARTING ANGLE ( 0 90 180 270) ")
IF (ExitScript(Destination$)) THEN Leave
No_sangle_var= LastVariableInput(Sangle_var$)

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Angle)
Angle= GetValue("ANGULAR EXTENT ( 90 180 360 ) ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_angle_var= LastVariableInput(Angle_var$)


Pick_entity:!
Stat=SetPickMask(WsPickNoSurf)
E1=PickEntity("PICK ENTITY ")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_entity
Stat= EntityNameCheck(E1,Element$)
Stat=SetPickMask(WsPickAll)


Stat= GenerateVarName(WsRevolutionEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("REVOLUTION: Entity ")
Stat= SetRecDelLastExec
Pt= ParameterPt(Element$,0.33)
T1= RevAxisTransform(Axis_line$,Pt)
IF No_sangle_var THEN
        IF No_angle_var THEN
                V1= FreeParameter("Start angle",Astart)
                V2= FreeParameter("Angle",Angle)
                R1= Revolution(T1,Element$,Axis_line$,V1,V2)
        ELSE
                V1= FreeParameter("Start angle",Astart)
                R1= Revolution(T1,Element$,Axis_line$,V1,Angle_var$)
        END IF
ELSE
        IF No_angle_var THEN
                V2= FreeParameter("Angle",Angle)
                R1= Revolution(T1,Element$,Axis_line$,Sangle_var$,V2)
        ELSE
                R1= Revolution(T1,Element$,Axis_line$,Sangle_var$,Angle_var$)
        END IF
END IF
Stat= NameEntity(R1,Name$)
Stat= DeleteEntity(Pt)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(R1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("revolution")
	Stat= AddItemToUndo(WsUBCreateMode,R1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Pick_entity

Leave:!
Stat=DeleteEntity(Pt)
Stat=SetPickMask(WsPickAll)

IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
