
! script name: vcontours.d/projectonaxiscyl
! var_topic: projects a contour on a cylinder

!A
!A NAME:
!A
!A 	Project Contour Onto Axis Cylinder	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script project a contour onto a cylinder.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE PROJECTED: Pick an element on the contour to be
!B 		projected.
!B
!B
!C NOTES:
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: project onto cylinder")

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

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

ActivateUndo

Tol=NamedVarVal("3D Cutting Tol",Ws3DSystemVars,0.005)
Which_axis=1

Radius_ques:Stat=SetInputFormat("n4=","")
Radius=InputRadius("CYLINDER RADIUS")
IF (ExitScript(Destination$)) THEN Leave
No_radius_var= LastVariableInput(Radius_var$)
C1= LastPickEnt
IF ValidGeometry(C1) THEN
        IF NOT ValidDependency(C1) THEN Radius_ques
        No_radius_var=0
        Stat= EntityNameCheck(C1,Radius_var$)
END IF



Pick_contour:!
Contour=PickGroupEnt("PICK CONTOUR TO BE PROJECTED")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Contour) THEN Pick_contour
Stat=EntityNameCheck(Contour,Contour$)


Stat=GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat=RecordDescr("CONTOUR: project on cylinder")
V2=FreeParameter("Tolerance",Tol)
V4=FreeParameter("Cylinder axis",Which_axis)
IF No_radius_var THEN
        V1= FreeParameter("Radius",Radius)
        C1=ProjectOnAxisCyl(V1,Contour$,V4,V2,WsBSplineEnt)
ELSE
        C1=ProjectOnAxisCyl(Radius_var$,Contour$,V4,V2,WsBSplineEnt)
END IF
Stat=AutoNameGroup(C1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= AdvanceUndoNumber("project on cylinder")
IF NOT ValidGeometry(C1) THEN
	DelLastVarRecord
ELSE
	Stat= AddGroupToUndo(WsUBCreateMode,C1,1,WsTrue)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Pick_contour

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

