
! script name: pksolids.d/pkcontourcut
! solids: construct block from a contour

!A
!A NAME:
!A
!A 	Contour Cut
!A
!A DESCRIPTION:
!A
!A	Cuts a contour shaped opening out of a solid body. This function 
!A	is equivalent to making a contour block and subtracting it from
!A	the solid body. It may also be used to make a contour ahaped
!A	hole in a sheet body.
!A
!A~ image location - images/pkcontourcut.gif
!A
!B INSTRUCTIONS:
!B
!B	PICK BODY: Pick the body to be cut from. It may be a solid
!B 		or a sheet body.
!B
!B	PICK CONTOUR: Pick the contour to be used. If not closed it
!B 		will close automatically.
!B
!B	HEIGHT ABOVE CONTOUR: Enter the height above the contour.
!B
!B	DEPTH BELOW CONTOUR: Enter the depth below the contour. Enter a
!B 		positive number.
!B
!C NOTES:
!C
!C	The contour must be contained in a plane.
!C
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: Contour Cut")

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

ActivateUndo

Stat= GLPlotOn

Pick_body:!
Pkbody= WPKCurrentBody
IF NOT WPKIsEntity(Pkbody) THEN
        Stat=SetInputFormat("n4","")
        E1=WPKPickEntity("PICK BODY")
        IF (ExitScript(Destination$)) THEN Leave
        IF NOT WPKIsEntity(E1) THEN Pick_body
        Pkbody= WPKParentBody(E1)
END IF


Pick_contour:!
Contour=PickGroupEnt("PICK CONTOUR ")
IF (ExitScript(Destination$)) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Height1)
Height1=InputDepth("HEIGHT ABOVE CONTOUR")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Depth1)
Depth1=InputDepth("DEPTH BELOW CONTOUR")
IF ExitScript(Destination$) THEN Leave

PlotOff
WPKClearErrorFlag
Pkcutbody=WPKContourBlock(Contour,Height1,Depth1)
G1= WPKSubtractBodies(Pkbody,Pkcutbody)
Stat= DeleteEntity(G1)
PlotOn
RefineAll

ActivateUndo
Stat= AdvanceUndoNumber("contour cutout")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Pick_contour

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