
! script name: 3dtrim.d/curveonsurf
! 3dtopic: return the UV curve on a surface from the XYZ curve

!A
!A NAME:
!A
!A 	Curve On Surface
!A
!A DESCRIPTION:
!A
!A 	This script will take a XYZ curve on a single surface and return the
!A 	corresponding UV curves on the surface.  The XYZ curve must lie along
!A 	the surface on the part.  This feature applies to 3D surfaces only.
!A
!B INSTRUCTIONS:
!B
!B 	TOLERANCE: Enter the amount of variation allowed.
!B
!B 	PICK SURFACE: Pick the surface to be used for generating the UV curves.
!B
!B 	PICK CONTOUR: Pick the contour on the surface to be used to generate
!B 		the UV curves on the surface.  The XYZ curve must lie along
!B 		the surface on the part.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: curve on surface ")

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

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

ActivateUndo
Start:!
Intersect2:StdWorkplane

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

Stat=SetPickMask(WsPickNoSurf)

Pick_loop:Stat=SetInputFormat("a1",",P,")
Curve=PickGroupEnt("PICK CONTOUR ",0)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Curve) THEN Pick_loop

Stat=Highlight(Curve,WsPickPen,WsDirArrowOff)

UVcurve=CurveOnSurface(Curve,Surface,Tol)

ActivateUndo
Stat= AdvanceUndoNumber("uv curve")
Stat= AddItemToUndo(WsUBCreateMode,UVcurve)
GOTO Intersect2

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