
! script name: pkgroups.d/pkdeletesimilar
! solids: delete similar holes in a solid model

!A
!A NAME:
!A
!A 	Delete Similar Holes in a Solid: 
!A
!A DESCRIPTION:
!A
!A	This script deletes similar holes in a solid body. Similar
!A	holes are those which have the same components with the
!A	same dimensions.
!A
!B INSTRUCTIONS:
!B
!B	PICK ENTITY IN HOLE: Pick an entity in the hole to be
!B				deleted. Either a face or an edge.
!B
!B
!C NOTES:
!C
!C	This script may be applied to any solid body.
!C
!C	To be deleted a hole must be recognizable as a cylindrical
!C	hole by the parasolids kernel. Non-cylindrical holes
!C	are not recognized and are not deleted.
!C
!C
!C      Not every hole may be deleted. Exceptions are as follows:
!C
!C              When the geometry of the hole is removed, the solids
!C              kernel was unable to repair the modified body.
!C              This may happen if the hole is made in a curved face or
!C              lies on the boundary between two faces. It may also
!C              occur in the case of a hole within a hole.
!C
!C              The hole is not recognized as a cylindrical hole.
!C              This may happen if the hole is imported from another
!C              system which does not use cylinders and cones.
!C              This may happen if the geometry contained in the hole
!C              is too complicated. An example might be where two or more
!C              intersect.
!C
!C              Sometimes repeated application of this script will eventually
!C              remove the hole.
!C
!# see also - htdocs/help.d/pkholes.htm
!# see also - htdocs/help.d/pkgroups.htm
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: delete similar holes ")

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

ActivateUndo

Stat= GLPlotOn
Units= CurrentUnits
IF Units= WsMetric THEN
        Radius= 25000
ELSE
        Radius= 1000
END IF

Stat= GLPlotOn
Start:!
Stat=SetInputFormat("a1",",D,C,DW,CW,")
Stat=GetValue("SIMILAR:  Diameter, Configuration ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "D"
        Similar=2
CASE "C"
        Similar=1
CASE "DW"
        Similar=12
CASE "CW"
        Similar=11
END SELECT


Pick_hole:!
E1=WPKPickEntity("PICK ENTITY IN HOLE")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Pick_hole

Pkbody= WPKParentBody(E1)

WPKClearErrorFlag
E1= WPKDeleteHoles(Pkbody,Radius,E1,Similar)

ActivateUndo
Stat= AdvanceUndoNumber("delete holes in solid")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

GOTO Pick_hole

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