
! script name: 3druled.d/ruledsurface
! 3dtopic: construct ruled surface between two equal element contours

!A
!A NAME:
!A
!A 	Ruled: Equal Element
!A
!A DESCRIPTION:
!A
!A 	This script will make a ruled surface.  There must be the same number
!A 	of elements on each section.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR # 1: Pick the contours in order.  
!B
!B 	PICK CONTOUR # 2: Pick the contours in order.  
!B
!C NOTES:
!C
!C 	A ruled surface is a linear blend between two contours.  This variety
!C 	blends each contour element by element.  The ruled surface retains the
!C 	individual character of each of the blending elements.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: ruled surface equal element ")

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

ActivateUndo
Active_workplane=0
Work=CurrentWorkplane
IF ValidGeometry(Work) THEN Active_workplane=1

Blend_loop:!
StdWorkplane

Pick_contour1: !
Stat=SetInputFormat("a1",",P,")
Stat=SetPickMask(WsPickNoSurf)
Contour1=PickGroupEnt("PICK CONTOUR #1",0)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Contour1) THEN Pick_loop

Stat=SetPickMask(WsPickAll)
Stat=Highlight(Contour1,WsPickPen,WsDirArrowOff)

Pick_contour2: !
Stat=SetInputFormat("a1",",P,")
Stat=SetPickMask(WsPickNoSurf)
Contour2=PickGroupEnt("PICK CONTOUR #2",0)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Contour2) THEN Pick_loop

Stat=SetPickMask(WsPickAll)
Stat=Highlight(Contour2,WsPickPen,WsDirArrowOff)

!  WsEqualElementSurf
Ruled_type=1   
Surf1=RuledSurface(Ruled_type,contour1,contour2,"RULED SURFACE")

ActivateUndo
Stat= AdvanceUndoNumber("ruled surf")
Stat= AddItemToUndo(WsUBCreateMode,Surf1)
GOTO Blend_loop

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