
! script name: vruled.d/twoentruled
! var_topic: construct ruled surface between two entities

!A
!A NAME:
!A
!A 	Ruled: Two Entities	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will make a ruled surface between two entities.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ENTITY # 1: Pick the entities in order.  
!B
!B 	PICK ENTITY # 2: Pick the entities in order.  
!B
!C NOTES:
!C
!C 	A ruled surface is a linear blend between two entities.  
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: ruled surface two elements ")

DIM Answer$[256]
DIM Destination$[256]
DIM Name1$[256]
DIM Name2$[256]
DIM Name$[256]


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

ActivateUndo
Blend_loop:!

Pick_entity1: !
Stat=SetInputFormat("n0","")
Stat=SetPickMask(WsPickNoSurf)
E1=PickEntity("PICK ENTITY #1")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_entity1
Stat= EntityNameCheck(E1,Name1$)
T1= LastPickPara
Dir1= (T1<= 0.5)*WsForward+ (T1> 0.5)*WsReverse

Stat=SetPickMask(WsPickAll)

Pick_entity2: !
Stat=SetInputFormat("n0","")
Stat=SetPickMask(WsPickNoSurf)
E2=PickEntity("PICK ENTITY #2")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(E2) THEN Pick_entity2
Stat= EntityNameCheck(E2,Name2$)
T2= LastPickPara
Dir2= (T2<= 0.5)*WsForward+ (T2> 0.5)*WsReverse

Stat=SetPickMask(WsPickAll)

Stat= GenerateVarName(WsRuledSurfEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("RULED SURFACE: Two Elements")
Stat= SetRecDelLastExec
Surf1= RuledSurface(1,Name1$,Name2$,"RULED SURFACE",0,Dir1,Dir2)
Stat= NameEntity(Surf1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

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

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