
! script name: vpkintersect.d/vfaceentintersect
! var_solids: find the intersection between a face and an entity

!A
!A NAME:
!A
!A 	Face with Entity  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script finds the intersect points between an entity and a face.
!A
!B INSTRUCTIONS:
!B
!B 	PICK FACE: Pick the target face.
!B
!B 	PICK ENTITY: Pick a synergy entity.
!B
!# see also - htdocs/help.d/parasolids.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: face entity intersect ")

DIM Destination$[256]
DIM Answer$[256]
DIM Elsment$[256]
DIM Face$[256]
DIM Name$[256]

ActivateUndo
Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave


Stat= GLPlotOn
Face_loop:!
E1=WPKPickEntity("PICK FACE",WsPKPickFace)
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Face_loop
Stat= EntityNameCheck(E1,Face$)

Pick_entity:!
E2=PickEntity("PICK ENTITY ")
IF (ExitScript(Destination$)) THEN Leave
Stat= EntityNameCheck(E2,Elsment$)


WPKClearErrorFlag
Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("POINTS: face intersect entity")
G1= WPKFaceCurveInter(Face$,Elsment$)
Stat= AutoNameGroup(G1,Name$)
RecordFunctionOff
IF ValidGeometry(G1) THEN
        ActivateUndo
        Stat= AdvanceUndoNumber("face intersect entity")
        Stat= AddGroupToUndo(WsUBCreateMode,G1,0,WsTrue)
        Make_record=1
ELSE
        Make_record=0
END IF
RecordFunctionOn
Stat= DeleteEntity(G1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

IF Make_record THEN
        Stat= WPKSolidRecordOn(Curr_record)
        ActivateUndo
        Stat= AddItemToUndo(WsUBPKSessionMark)
        Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
ELSE
        DelLastVarRecord
END IF
WPKErrorCheck
GOTO Face_loop

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