
! script name: macros.d/connectrod
! EXAMPLE: construct connecting rod

!A
!A NAME:
!A
!A 	Connecting Rod
!A
!A DESCRIPTION:
!A
!A 	This script uses two TYPE 7's to make a connecting rod.
!A
!B INSTRUCTIONS:
!B
!B 	CENTER ABS X,Y: Enter the X,Y coordinates of the center of the
!B 		connecting rod.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	DIST BETWEEN CENTERS: Enter the distance between the centers of
!B 		the end circles.
!B
!B 	START RADIUS: Enter the radius of the circle on one end of the
!B 		connecting rod.
!B
!B 	END RADIUS: Enter the radius of the circle at the other end of
!B 		the connecting rod.
!B
!B 	CORNER RADIUS: Enter the radius to be used in all the corners.
!B
!B 	PERPENDICULAR DISTANCE: Enter the distance between the parallel
!B 		lines of the connecting rod.
!B
!B 	ANGLE: Enter the orientation angle of the connecting rod.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: connecting rod ")

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

DeActivateUndo
Rect_loop:!

Stat=SetInputFormat("n4=","")
Ps=XyzInput("CENTER ",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave

Length=GetValue("DIST BETWEEN CENTERS",Answer$)
IF (ExitScript(Destination$)) THEN Leave

R1=InputRadius("START RADIUS")
IF (ExitScript(Destination$)) THEN Leave

R4=InputRadius("END RADIUS")
IF (ExitScript(Destination$)) THEN Leave

Corner=InputRadius("CORNER RADIUS")
IF (ExitScript(Destination$)) THEN Leave

Dist=GetValue("PERPENDICULAR DISTANCE ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Angle=InputAngle("ANGLE")
IF (ExitScript(Destination$)) THEN Leave


X1=XPointValue(Ps)
Y1=YPointValue(Ps)
X2=X1+Length
Y2=Y1
R2=-Corner
R3=-Corner


T1=Type7(7,X1,Y1,X2,Y2,R1,R2,R3,R4,Angle,Dist,WsLeft,WsPerpR1)
IF (NOT ValidGeometry(T1)) THEN Leave

Angle2=180-Angle

T2=Type7(7,X2,Y2,X1,Y1,R4,R3,R2,R1,Angle2,Dist,WsRight,WsPerpR4)
IF (NOT ValidGeometry(T2)) THEN Leave

Stat=JoinTypes(T1,T2)
Stat=CloseType(T2)
Contour=TypesContour(T2,1)


Stat=DeleteEntity(Ps)

GOTO Rect_loop

Leave:!
Stat=DeleteEntity(Ps)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
