
! script name: 3druled.d/joinruled
! 3dtopic: join connecting ruled surfaces

!A
!A NAME:
!A
!A	Join Ruled
!A
!A DESCRIPTION:
!A
!A 	This script allows two adjacent ruled surfaces to be connected.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE # : Pick the surfaces to be joined in order.
!B
!C NOTE:
!C
!C 	The ruled surfaces must have been built in the same
!C 	direction and must connect end to start.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: join ruled surfaces ")

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

ActivateUndo
Start:!

Group=CreateGroup("TEMP")

Ploop:!

Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("a1",",P,")
N1=GroupCount(Group)
Surf=PickEntity("PICK SURFACE #"&VAL$(N1+1)&",  Proceed",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="P" THEN Make_surface
IF NOT ValidGeometry(Surf) THEN Ploop

Stat=AddToGroup(Group,Surf)

GOTO Ploop

Make_surface:!

Stat=SetPickMask(WsPickGeometry)
Surf2=ConnectRuledSurfs(Group)
Stat=DeleteEntity(Group)

ActivateUndo
Stat= AdvanceUndoNumber("ruled")
Stat= AddItemToUndo(WsUBCreateMode,Surf2)

GOTO Start

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