
! script name: 3dintersect.d/trimfreept
! 3dtopic: free point on a surface trim curve

!A
!A NAME:
!A
!A 	Trim Curve Free Point
!A
!A DESCRIPTION:
!A
!A 	This script makes a free point on a surface trim curve.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ON SURFACE TRIM CURVE: Pick the free point on the surface
!B 		trim curve.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: free trim curve point ")

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

ActivateUndo
Tol=NamedVarVal("3D Trimming Tol",Ws3DSystemVars,0.005)

Start:!
Intersect2:!

Stat= SetPickMask(WsPickSurfOnly)
stat= SetInputFormat("n0","")
Surface=PickEntity("PICK ON SURFACE TRIM CURVE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Surface) THEN Intersect2

UVPoint=LastUVSurfPick(Surface)
IF NOT ValidGeometry(UVPoint) THEN Start
U=XPointValue(UVPoint)
V=YPointValue(UVPoint)
TrimUV=ClosestTrimUV(Surface,U,V)
IF ValidGeometry(TrimUV) THEN 
	Pt= SurfParameterPt(Surface,TrimUV)
	Stat= DeleteEntity(TrimUV)
END IF
Stat= DeleteEntity(UVPoint)

ActivateUndo
Stat= AdvanceUndoNumber("point")
Stat= AddItemToUndo(WsUBCreateMode,Pt)

GOTO Intersect2


Leave:!
Stat= DeleteEntity(UVPoint)
Stat= DeleteEntity(EdgeUV)
stat= SetInputFormat("n4","")
Stat= SetPickMask(WsPickGeometry)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
