
! script name: pksolids.d/pkspinbody
! solids: construct body by spinning a sheet or wire body

!A
!A NAME:
!A
!A 	Spin Body
!A
!A DESCRIPTION:
!A
!A	This script will spin a parasolid wire or sheet body
!A	about an axis to form either a sheet or solid body.
!A
!B INSTRUCTIONS:
!B	
!B	PICK BODY TO BE SPUN: Pick the body to be spun.
!B
!B	PICK AXIS LINE: Pick the axis to be spun around.
!B
!B	ANGULAR EXTENT: Enter the angular extent of the spin.
!B
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: spin body")

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

ActivateUndo

Stat= GLPlotOn
Pick_body:!
E1=WPKPickEntity("PICK BODY TO BE SPUN")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Pick_body

Body_type= WPKBodyType(E1)
IF NOT((Body_type= WsPKWireBody)OR(Body_type= WsPKSheetBody)) THEN Pick_body

Pick_axis:Delete_axis=0
Stat=SetInputFormat("a1=",",X,Y,Z,")
Axis_line=PickEntity("PICK AXIS LINE:  X, Y, Z ", Answer$)
IF ExitScript(Destination$) THEN Leave
SELECT Answer$
CASE "X"
        Axis_line=WorkplaneAxisLine(1)
        Delete_axis=1
CASE "Y"
        Axis_line=WorkplaneAxisLine(2)
        Delete_axis=1
CASE "Z"
        Axis_line=WorkplaneAxisLine(3)
        Delete_axis=1
END SELECT
IF NOT ValidGeometry(Axis_line) THEN Pick_axis
Etype= EntityType(Axis_line)
IF Etype <> WsLineEnt THEN Pick_axis


Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(180)
Angle=GetValue("ANGULAR EXTENT",Answer$)
IF ExitScript(Destination$) THEN Leave

WPKClearErrorFlag
Pkbody=WPKSpinBody(E1,Axis_line,Angle)
IF Delete_axis THEN Stat=DeleteEntity(Axis_line)

ActivateUndo
Stat= AdvanceUndoNumber("spun body")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Pick_body

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