
! script name: lines.d/developruled
! topic: develop or roll out a ruled surface or cylinder or cone.

!A
!A NAME:
!A
!A 	Develop ruled surface
!A
!A DESCRIPTION:
!A
!A	This function will develop or roll out a ruled surface or cylinder
!A	or cone. If the ruled surface is trimmed the trim curves will be
!A	developed as well.
!A
!A~ image location - images/developruled.jpg
!A~ image location - images/developcone.jpg
!B INSTRUCTIONS:
!B
!B	PICK SURFACE: Pick the ruled surface or cylinder or cone (no solids).
!B
!B      STEP DISTANCE: Approximation step distance.
!B
!B      PLACEMENT POINT: Location point of the developed curves.
!B
!B

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

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

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

ActivateUndo
stat= SetInputFormat("n4","")
Dist= 0.020
Tol= 0.0005

Pick_ruled:!
Stat=SetPickMask(WsPickSurfOnly)
Ruled_surf=PickEntity("PICK SURFACE")
Stat=SetPickMask(WsPickGeometry)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Ruled_surf) THEN Sloop


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

Group= DevelopRuled(Pc,Ruled_surf,Dist,WsLeft)

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

Rungs= GroupElement(Group,3)
IF GroupCount(Group)=4 THEN
	Ruled_surf= GroupElement(Group,4)
END IF
Stat= NameEntity(Rungs,"rungs")
Stat= DeleteEntity(Pc)

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

ActivateUndo
Stat= AdvanceUndoNumber("develop ruled")
Stat= AddGroupToUndo(WsUBCreateMode,Top_curve,1,WsTrue)
Stat= AddGroupToUndo(WsUBCreateMode,Bot_curve,1,WsTrue)
Stat= AddGroupToUndo(WsUBCreateMode,Rungs,1,WsTrue)
IF GroupCount(Group)=4 THEN
	Stat= AddItemToUndo(WsUBCreateMode,Ruled_surf)
END IF

Stat= DeleteEntity(Group)

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