
! script name: lines.d/developshape
! topic: develops a contour shape wrapped on a cylinder.

!A
!A NAME:
!A
!A 	Develop Shape
!A
!A DESCRIPTION:
!A
!A	This function will develop or roll out a shape described by wrapping
!A	a contour around a cylinder along the Y axis and giving in radial
!A	thickness.
!A
!A~ image location - images/developshape.jpg
!B INSTRUCTIONS:
!B
!B	RADIUS OF CYLINDER: Radius of the wrapping cylinder.
!B
!B	THICKNESS: Radial thickness.
!B
!B	PICK CONTOUR: Contour to be wrapped and developed.
!B
!B	STEP DISTANCE: Approximation step distance.
!B
!B	PLACEMENT POINT: Location point of the developed curves.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: develop shape ")

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

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

ActivateUndo
stat= SetInputFormat("n4","")
Dist= 0.020
Thickness= 0.375
Astart= 0.0
Taper= 0.0
Tol= 0.0005

Ask_radius:!
Radius=InputRadius("RADIUS OF CYLINDER")
IF ExitScript(Destination$) THEN Leave

stat= SetInputFormat("n4=","")
Stat= SetEqualsValue(Thickness)
Thickness=GetValue("THICKNESS",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Pick_contours:!
Contour1=PickGroupEnt("PICK CONTOUR ")
IF (ExitScript(Destination$)) THEN Leave


stat= SetInputFormat("n4=","")
Stat= SetEqualsValue(Dist)
Dist=GetValue("STEP DISTANCE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Pick_point:Stat=SetInputFormat("n4","")
Pc=XyzInput("PLACEMENT POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pc) THEN Pick_point

PlotOff
Move_vector= PointXYZ(0.0,0.0,-Thickness)
Contour2= VectorCopyGroup(Contour1,Move_vector,1)
Wrap1=WrapEntity(Contour1,Radius,Astart,Taper,Tol,0.0,0.0)
Wrap2=WrapEntity(Contour2,Radius,Astart,Taper,Tol,0.0,0.0)
Group= DevelopContours(Pc,Wrap1,Wrap2,Dist,WsLeft,4)
Stat= DeleteGroup(Wrap1,WsTrue)
Stat= DeleteGroup(Wrap2,WsTrue)
Stat= DeleteGroup(Contour2,WsTrue)
Stat= DeleteEntity(Move_vector)
PlotOn

PlotAll
Top_curve= GroupElement(Group,1)
Bot_curve= GroupElement(Group,2)

Rungs= GroupElement(Group,3)
Stat= NameEntity(Rungs,"rungs")
Stat= DeleteEntity(Group)
Stat= DeleteEntity(Pc)

Stat= AutoNumberCont(Top_curve)
Stat= AutoNumberCont(Bot_curve)

ActivateUndo
Stat= AdvanceUndoNumber("develop shape")
Stat= AddGroupToUndo(WsUBCreateMode,Top_curve,1,WsTrue)
Stat= AddGroupToUndo(WsUBCreateMode,Bot_curve,1,WsTrue)
Stat= AddGroupToUndo(WsUBCreateMode,Rungs,1,WsTrue)


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