
! script name: parasolids.d/pkresolvefaces
! solids: resolve redundant faces on a solid body

!A
!A NAME:
!A
!A 	Resolve Body Faces
!A
!A DESCRIPTION:
!A
!A 	This script tries to resolve redundant faces on a body.
!A
!B INSTRUCTIONS:
!B
!B 	PICK BODY: Pick the body to be resolved.
!B
!B OPTIONS:
!B	
!B      Redundant faces occur when operations such as unite are done
!B      on solid bodies. Situations are created when a face such as a plane
!B      is broken into two faces, but is still one geometric plane.
!B      It can be very important to remove the unnecessary split
!B      because operations such as machining are easier when dealing
!B      with optimum geometry.
!B	
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: resolve body faces ")

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

ActivateUndo

Stat= GLPlotOn
Pick_loop:!

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

WPKClearErrorFlag
Stat= WPKResolveRedundant(E1,WsTrue,WsFalse,WsFalse)

ActivateUndo
Stat= AdvanceUndoNumber("resolve redundant planes")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

WPKClearErrorFlag
Stat= WPKResolveRedundant(E1,WsFalse,WsTrue,WsFalse)

ActivateUndo
Stat= AdvanceUndoNumber("resolve redundant cylinders")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

WPKClearErrorFlag
Stat= WPKResolveRedundant(E1,WsFalse,WsFalse,WsTrue)

ActivateUndo
Stat= AdvanceUndoNumber("resolve redundant cones")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

GOTO Pick_loop

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