
! script name: 3dtrim.d/curveonpart
! 3dtopic: return the UV curves on the part from XYZ curve

!A
!A NAME:
!A
!A 	Curve On Part
!A
!A DESCRIPTION:
!A
!A 	This script will take a XYZ curve and return the corresponding UV
!A 	curves on the surfaces in the part.  The XYZ curve must lie along
!A 	the surface on the part.  This feature applies to 3D surfaces only.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE GROUP #1: Pick the surface group (part) to be used for
!B 		generating the UV curves.
!B
!B 	PICK CONTOUR: Pick the contour on the part to be used to generate the
!B 		UV curves on the surfaces in the part.  The XYZ curve must lie
!B 		along the surfaces 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("n4","")
Part_group=PickGroupEnt("PICK SURFACE GROUP #1 ",WsSurfaceGroup)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Part_group) THEN Intersect2

Stat=Highlight(Part_group,WsPickPen,WsDirArrowOff)

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=CurveOnPart(Curve,Part_group,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
