
! script name: parasolids.d/subtractbdys
! solids: subtract two solid bodies

!A
!A NAME:
!A
!A 	Subtract Two Bodies
!A
!A DESCRIPTION:
!A
!A 	This script subtracts two solid bodies. It removes from
!A	the first body the portion of the second body which it has in common.
!A	The second body then goes away.
!A
!A~ image location - images/pkboolean.gif
!A
!B INSTRUCTIONS:
!B
!B	PICK FIRST BODY:  Pick the first of the two bodies.
!B
!B	PICK SECOND BODY: Pick the second of the two bodies.
!B
!B
!B NOTES:
!B
!B	The resulting body will have the same parasolid tag as
!B	the first body. The resultant body will inherit the properties
!B	of the first body, for example layer and name.
!B	Faces which survive the subtraction will retain
!B	their colors and other properties. New Faces will have the 
!B	current color properties.
!B
!# see also - htdocs/help.d/parasolids.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: subtract two bodies ")

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

ActivateUndo

Stat= GLPlotOn
Body_loop:!

E1=WPKPickEntity("PICK FIRST BODY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Body_loop

E2=WPKPickEntity("PICK SECOND BODY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E2) THEN Body_loop

WPKClearErrorFlag
G1= WPKSubtractBodies(E1,E2)
Stat= DeleteEntity(G1)

ActivateUndo
Stat= AdvanceUndoNumber("subtract bodies")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

GOTO Body_loop

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