
! script name: vstretch.d/xboxstretch
! var_topic: stretch elements along the x axis

!A
!A NAME:
!A
!A 	X Stretch          VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will stretch elements along the x axis.
!A
!B INSTRUCTIONS:
!B
!B 	PICK FIRST CORNER OF PICK ZONE: Pick a
!B 		corner of the box to be used.
!B
!B 	PICK SECOND CORNER OF PICK ZONE: Pick
!B 		the other corner of the box.
!B
!B 	ORIGIN POINT ABS X,Y: Pick or input
!B 		the X,Y coordinates of the origin point.
!B
!B 	DESTINATION POINT ABS X,Y: Pick or input
!B 		the X,Y coordinates of the destination point.
!B 		The distance between the origin and the destination
!B 		points will determine the amount of stretch.
!B
!C NOTES:
!C
!C 	Stretching does not work with Types Geometry, nor will it work properly
!C 	with trimmed spline entities.
!C
!C 	Stretching currently is only active on wire frame 3D elements; it does
!C 	not function with surfaces.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: stretch along x ")

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

Stat=SetInputFormat("n4","")

DeActivateUndo
Pick_loop: !
Stat=SetInputFormat("n4","")
Vnum=PickView("SELECT VIEW FOR SELECTION BOX")
IF ExitScript(Destination$) THEN Leave

L1=WorkplaneBox(Vnum)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(L1) THEN Pick_loop

Pt1=ParameterPt(L1,0.0)
Pt2=ParameterPt(L1,1.0)

Dist=DistTwoPts(Pt1,Pt2)
IF Dist<0.0001 THEN Pick_loop

P1=XyzInput("ORIGIN POINT",WsXyOnly)
IF ExitScript(Destination$) THEN Leave

P2=XyzInput("DESTINATION POINT",WsXyOnly)
IF ExitScript(Destination$) THEN Leave

X1=XpointValue(P1)
X2=XpointValue(P2)
Move_vector=PointXYZ(X2-X1,0.0,0.0)
Stat=BoxMoveEntities(pt1,pt2,Move_vector,WsXyOnly)

Stat=DeleteEntity(Pt1)
Stat=DeleteEntity(Pt2)
Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)
Stat=DeleteEntity(L1)
Stat=DeleteEntity(Move_vector)

Stat=LineNumberIncr(1)
Output_script=0
Start_obj=0
Stat= DisplayMessage("CALCULATING CHANGES")
Stat=OutputAllObjects("tempscript","vstretch.d/xboxstretch",Start_obj,Output_script)
IF Stat=1 THEN Pick_loop

LOAD "tempscript"

GOTO Pick_loop

Leave:!
Stat=DeleteEntity(Pt1)
Stat=DeleteEntity(Pt2)
Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)
Stat=DeleteEntity(L1)
Stat=DeleteEntity(Move_vector)
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END

