
! script name: 3druled.d/rtranslation
! 3dtopic: generate ruled surface translation by moving a contour in XYZ

!A
!A NAME:
!A
!A 	Dynamic Ruled Translation
!A
!A DESCRIPTION:
!A
!A 	This script generates a ruled surface translation.  This surface is 
!A	generated by taking a contour and moving it in XYZ.  
!A	Every point of the contour is moved simultaneously 
!A	in the same direction.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR: Pick the contour to be used to generate a	translation.
!B
!B 	X SHIFT: Enter the amount the contour is to be shifted in X relative
!B 		to the workplane.
!B
!B 	Y SHIFT: Enter the amount the contour is to be shifted in Y relative
!B 		to the workplane.
!B
!B 	Z SHIFT: Enter the amount the contour is to be shifted in Z relative
!B 		to the workplane.
!B
!C NOTES:
!C
!C 	If the contour is in another workplane, the workplane must be
!C 	established before doing the translation.  The shift questions are
!C 	relative to that workplane.
!C
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: ruled translation ")

DIM Destination$[256]
DIM Answer$[256]
REAL Params(0:10)

ActivateUndo
Stat= GLPlotOn
Start:!
Stat=SetInputFormat("n4","")
Stat=SetPickMask(WsPickNoSurf)
Contour=PickGroupEnt("PICK CONTOUR ")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Contour) THEN Start

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


PlotOff
length1= 1.0
P1= ContStartPt(Contour)
X1= XPointValue(P1)
Y1= YPointValue(P1)
Stat= DeleteEntity(P1)
Ps= PointXYZ(X1,Y1,0.0)
Pe= PtIncrXyz(Ps,Length1,0.0,0.0)
C1=RuledTranslation(Contour,Length1,0.0,0.0)
Stat= MakeInvisible(C1)
Stat= HideEntity(C1)
Stat= MakeInvisible(Pe)
PlotOn
Stat= PlotEntity(Ps)
Stat= SetLastPoint(Ps)

Vnum= LastPickView
Params(0)= 0.0
Num_params=1
Stat=SetInputFormat("n4b","")
Stat=DynamicEntity(Vnum,C1,Ps,Pe,WsDynRuledTrans,"PICK ENDPOINT ",Params,Num_params,Contour,WsTrue,WsFalse)
IF (ExitScript(Destination$)) THEN
        Stat=DeleteEntity(C1)
        GOTO Leave
END IF
Stat= MakeVisible(Ps)
Stat= MakeVisible(Pe)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)

WPKClearErrorFlag
C2=WPKMakeRuled(C1,WsTrue)
Stat=DeleteEntity(C1)

ActivateUndo
Stat= AdvanceUndoNumber("ruled translation")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Start

Leave:!
Stat=SetInputFormat("n4","")
Stat=SetPickMask(WsPickAll)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
IF NOT LEN(Destination$) THEN
        LOAD "typecontrol"
ELSE
        IF Destination$= "SCRIPTSTART" THEN Start
        IF Destination$= "BACKUP" THEN Start
        LOAD Destination$
END IF
END
