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

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

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

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

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

ActivateUndo
Pick_contour:!
Stat= SetInputFormat("n4","")
Contour=PickGroupEnt("PICK CONTOUR ")
IF (ExitScript(Destination$)) THEN Leave
IF (NOT ValidDependency(Contour)) THEN Pick_contour
Stat= EntityNameCheck(Contour,Contour$)

Stat=Highlight(Contour,WsPickPen,WsDirArrowOff)

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 contour")
Stat= SetRecDelLastExec
Selectpt= ParameterPt(Element$,T1)
Pt=EntIntCont(Element$,Contour$,Selectpt)
Stat= NameEntity(Pt,Name$)
Stat=DeleteEntity(Selectpt)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Element$)
Stat= PlotEntity(Contour$)
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=DeleteEntity(Selectpt)
Stat= SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

