
! script name: pkswept.d/pkextbody2bdys
! solids: construct body by extruding a sheet body between two bodies

!A
!A NAME:
!A
!A 	Extrude Body Between Bodies
!A
!A DESCRIPTION:
!A
!A 	This script will extrude a sheet body between two bodies.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SHEET BODY TO BE EXTRUDED: Select the sheet
!B 		body to be extruded.  The sheet body must be
!B 		located between the two bodies.
!B
!B 	PICK START BOUNDING BODY: Pick the first
!B 		bounding body to be encountered in the direction
!B 		of the extrusion.
!B
!B 	PICK END BOUNDING BODY: Pick the last bounding body encountered.
!B
!B 	PICK DIRECTION LINE:  Into or Above workplane:
!B 		Either pick a line to determine the direction or 
!B 		I will extrude into the current workplane(Z-)
!B 		A will extrude above the current workplane(Z+)
!B
!C NOTES:
!C
!C	The direction must go from the start bound to the end bound.
!C
!C 	The result is a separate body from the bounding body.
!C 	If you wish to have only one body then use unite bodies.
!C
!C 	The extruded body must totally intersect the bounding bodies.
!C 	A partial intersection will result in an error.
!C
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: extrude sheet body between two bodies")

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

ActivateUndo
Stat= GLPlotOn


Pick_sheet:!
Sheet=WPKPickEntity("PICK SHEET BODY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(Sheet) THEN Pick_sheet

Body_type= WPKBodyType(Sheet)
IF (Body_type<> WsPKSheetBody) THEN Pick_sheet

Solid_body= WsTrue

Pick_body1:!
E1=WPKPickEntity("PICK START BOUNDING BODY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Pick_body1

Body_type= WPKBodyType(E1)
IF (Body_type= WsPKWireBody) THEN Pick_body1


Pick_body2:!
E2=WPKPickEntity("PICK END BOUNDING BODY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E2) THEN Pick_body2

Body_type= WPKBodyType(E2)
IF (Body_type= WsPKWireBody) THEN Pick_body2


Pick_line:! 
Stat=SetInputFormat("a1",",I,A,V,")
L1=PickEntity("PICK DIRECTION LINE, Into or Above workplane, Vector ",Answer$)
IF ExitScript(Destination$) THEN Leave
SELECT Answer$
CASE "I"
	P1= PointXYZ(0,0,0)
	P2= PointXYZ(0,0,-1)
	L1= LineTwoPoints(P1,P2)
	Stat= DeleteEntity(P1)
	Stat= DeleteEntity(P2)
CASE "A"
	P1= PointXYZ(0,0,0)
	P2= PointXYZ(0,0,1)
	L1= LineTwoPoints(P1,P2)
	Stat= DeleteEntity(P1)
	Stat= DeleteEntity(P2)
CASE "V"
	Stat=SetInputFormat("n4=","")
	Stat=SetDepthEquals(Xshift)
	Xshift=InputDepth("X SHIFT")
	IF ExitScript(Destination$) THEN Leave

	Stat=SetInputFormat("n4=","")
	Stat=SetDepthEquals(Yshift)
	Yshift=InputDepth("Y SHIFT")
	IF ExitScript(Destination$) THEN Leave

	Stat=SetInputFormat("n4=","")
	Stat=SetDepthEquals(Zshift)
	Zshift=InputDepth("Z SHIFT")
	IF ExitScript(Destination$) THEN Leave

	P1= PointXYZ(0,0,0)
	P2= PointXYZ(Xshift,Yshift,Zshift)
	L1=LineTwoPoints(P1,P2,WsTRIMMED)
	Stat= DeleteEntity(P1)
	Stat= DeleteEntity(P2)
CASE ELSE
	IF NOT ValidGeometry(L1) THEN Pick_line
	Etype= EntityType(L1)
	IF Etype<> WsLineEnt THEN Pick_body
	T= LastPickPara
	L1= CopyEntity(L1)
	IF T< .5 THEN Stat= ReverseEnt(L1)
END SELECT


WPKClearErrorFlag
Pkbody=WPKExtrudeBody(Sheet,E1,E2,L1,Solid_body)
Stat= DeleteEntity(L1)

ActivateUndo
Stat= AdvanceUndoNumber("extrude sheet body")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Pick_sheet

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