
! script name: vpoints.d/entintboundary
! var_topic: create point at intersection of boundary and entity

!A
!A NAME:
!A
!A 	Entity Intersect Boundary	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script creates a point at the intersection of a boundary and an
!A 	entity.
!A
!A~ image location - images/entintcont.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR IN BOUNDARY: Pick a contour in the boundary.
!B
!B 	PICK INTERSECTING ELEMENT: Pick the element that
!B 		intersects the boundary to determine the point location.
!B

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

DIM Destination$[256]
DIM Answer$[256]
DIM Contour$[256]
DIM Boundary$[256]
DIM Name$[256]
DIM Element$[256]

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

ActivateUndo
Pick_boundary:!
Stat=SetInputFormat("n4","")
Contour=PickGroupEnt("PICK CONTOUR IN BOUNDARY")
IF (ExitScript(Destination$)) THEN Leave
Boundary1= FindBoundary(Contour)
IF (NOT ValidDependency(Boundary1)) THEN Start
Stat= EntityNameCheck(Boundary1,Boundary$)
Stat= SetSelectedFlag(Boundary1,WsTrue)
Stat= PlotEntity(Boundary1)


Pick_entity:!
Stat= SetInputFormat("a1",",N,")
E1=PickEntity("PICK INTERSECTING ELEMENT ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "N" THEN Pick_contour
IF NOT ValidDependency(E1) THEN Start
Stat=SetInputFormat("n4"," ")
Stat= EntityNameCheck(E1,Element$)
T1=LastPickPara

Stat= GenerateVarName(WsPointEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("POINT: entity intersect boundary")
Stat= SetRecDelLastExec
Selectpt= ParameterPt(Element$,T1)
Pt=EntIntBoundary(Element$,Boundary$,Selectpt)
Stat= NameEntity(Pt,Name$)
Stat=DeleteEntity(Selectpt)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Element$)
Stat= PlotEntity(Boundary$)
Stat= PlotEntity(Name$)
IF NOT ValidGeometry(Pt) THEN
	DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("intersect pt")
	Stat= AddItemToUndo(WsUBCreateMode,Pt)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Pick_entity

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

