'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright by Weinmann Holzbausystemtechnik GmbH (c) 2003
'
' Filename:		BT6.WMK
'
' Description:	Macro used to create a beam
'
' Author:		tb32???
'
' Date:			20030521
'
' Version:		V0.01
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Author:		tb32JAR
'
' Date:			20041213
'
' Version:		V0.02
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

SUB MAIN

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' variables and their initializing

DIM BT6_LENGTH			' Laenge des BT6 in X
    BT6_LENGTH = 1000
DIM BT6_WIDTH			' Breite des BT6 in Y
    BT6_WIDTH = 140
DIM BT6_HEIGHT			' Hoehe des BT6 in Z
    BT6_HEIGHT = 38
DIM BT6_XLU			' Punkt links unten in X
    BT6_XLU = 50
DIM BT6_YLU			' Punkt links unten in Y
    BT6_YLU = 120
DIM BT6_XMU			' Punkt mitte unten in X
    BT6_XMU = 0
DIM BT6_YMU			' Punkt mitte unten in Y
    BT6_YMU = 60
DIM BT6_XRU			' Punkt rechts unten in X
    BT6_XRU = 60
DIM BT6_YRU			' Punkt rechts unten in Y
    BT6_YRU = 0
DIM BT6_XRO			' Punkt rechts oben in X
    BT6_XRO = 260
DIM BT6_YRO			' Punkt rechts oben in Y
    BT6_YRO = 0
DIM BT6_XMO			' Punkt mitte unten in X
    BT6_XMO = 300
DIM BT6_YMO			' Punkt mitte unten in Y
    BT6_YMO = 40
DIM BT6_XLO			' Punkt links oben in X
    BT6_XLO = 280
DIM BT6_YLO			' Punkt links oben in Y
    BT6_YLO = 120
DIM BT6_INDEX			' Index des BT6
    BT6_INDEX = 0
DIM BT6_NAME			' Name BT6
    BT6_NAME = "BT6"
DIM BT6_COUNT			' Stueckzahl BT6
    BT6_COUNT = 1
DIM BT6_ANGLE_VO		' Winkel vorne oben (naeher X0)
    BT6_ANGLE_VO = 45.0
DIM BT6_ANGLE_VU		' Winkel vorne unten (naeher X0)
    BT6_ANGLE_VU = 45.0
DIM BT6_ANGLE_HU		' Winkel hinten unten (naeher X Ende)
    BT6_ANGLE_HU = 45.0
DIM BT6_ANGLE_HO		' Winkel hinten oben (naeher X Ende)
    BT6_ANGLE_HO = 45.0
DIM BT6_TAN_VO
    BT6_TAN_VO = 1.0
DIM BT6_TAN_VU
    BT6_TAN_VU = 1.0
DIM BT6_TAN_HU
    BT6_TAN_HU = 1.0
DIM BT6_TAN_HO
    BT6_TAN_HO = 1.0
DIM BT6_OFFSET_U
    BT6_OFFSET_U = 0
DIM BT6_OFFSET_O
    BT6_OFFSET_O = 0
DIM sIni
DIM P0_Title
DIM Offset_Y
Offset_Y = 0

const MACROTITLE = "Macro"

'Holen Parameterbezeichnungen abhaengig von der Landessprache
sIni = "l" + GETACTUALLANGUAGE() + ".ini"

P0_Title = GETPRIVATEPROFILESTRING("GENERAL", "P0", " ", sIni)

BT6_LENGTH = InputBoxF("P1:",MACROTITLE,BT6_LENGTH)
IF bInputBoxCancel = 1 THEN
	EXIT SUB	'	WScript.Quit 1
END IF

BT6_WIDTH = InputBoxF("P2:",MACROTITLE,BT6_WIDTH)
IF bInputBoxCancel = 1 THEN
	EXIT SUB	'	WScript.Quit 1
END IF

BT6_HEIGHT = InputBoxF("P3:",MACROTITLE,BT6_HEIGHT)
IF bInputBoxCancel = 1 THEN
	EXIT SUB	'	WScript.Quit 1
END IF






BT6_ANGLE_VO = InputBoxF("P4:",MACROTITLE,BT6_ANGLE_VO)
IF bInputBoxCancel = 1 THEN
	EXIT SUB	'	WScript.Quit 1
END IF
IF BT6_ANGLE_VO > 0 AND BT6_ANGLE_VO < 180 THEN
	BT6_ANGLE_VO = BT6_ANGLE_VO
ELSE
	BT6_ANGLE_VO = 90
END IF

BT6_YMU = BT6_WIDTH/2
BT6_YMU = InputBoxF("P9:",MACROTITLE,BT6_YMU)
IF bInputBoxCancel = 1 THEN
	EXIT SUB	'	WScript.Quit 1
END IF

IF BT6_YMU > 0 THEN
	BT6_ANGLE_VU = InputBoxF("P5:",MACROTITLE,BT6_ANGLE_VU)
	IF bInputBoxCancel = 1 THEN
		EXIT SUB	'	WScript.Quit 1
	END IF
ELSE
	BT6_ANGLE_VU = 90
END IF
IF BT6_ANGLE_VU > 0 AND BT6_ANGLE_VU < 180 THEN
	BT6_ANGLE_VU = BT6_ANGLE_VU
ELSE
	BT6_ANGLE_VU = 90
END IF
IF BT6_YMU = BT6_WIDTH THEN
	BT6_ANGLE_VO = 180 -  BT6_ANGLE_VU
END IF




BT6_ANGLE_HU = InputBoxF("P6 :",MACROTITLE,BT6_ANGLE_HU)
IF bInputBoxCancel = 1 THEN
	EXIT SUB	'	WScript.Quit 1
END IF
IF BT6_ANGLE_HU > 0 AND BT6_ANGLE_HU < 180 THEN
	BT6_ANGLE_HU = BT6_ANGLE_HU
ELSE
	BT6_ANGLE_HU = 90
END IF

BT6_YMO = BT6_WIDTH/2
BT6_YMO = InputBoxF("P10:",MACROTITLE,BT6_YMO)
IF bInputBoxCancel = 1 THEN
	EXIT SUB	'	WScript.Quit 1
END IF

IF BT6_YMO < BT6_WIDTH THEN
	BT6_ANGLE_HO = InputBoxF("P7:",MACROTITLE,BT6_ANGLE_HO)
	IF bInputBoxCancel = 1 THEN
		EXIT SUB	'	WScript.Quit 1
	END IF
ELSE
	BT6_ANGLE_HO = 90
END IF
IF BT6_ANGLE_HO > 0 AND BT6_ANGLE_HO < 180 THEN
	BT6_ANGLE_HO = BT6_ANGLE_HO
ELSE
	BT6_ANGLE_HO = 90
END IF
IF BT6_YMO = 0 THEN
	BT6_ANGLE_HU = 180 -  BT6_ANGLE_HO
END IF






BT6_COUNT = InputBoxI(P0_Title,MACROTITLE,BT6_COUNT)
IF bInputBoxCancel = 1 THEN
	EXIT SUB	'	WScript.Quit 1
END IF


BT6_TAN_VO = TAN(BT6_ANGLE_VO*PI/180)
BT6_TAN_VU = TAN(BT6_ANGLE_VU*PI/180)
BT6_TAN_HU = TAN(BT6_ANGLE_HU*PI/180)
BT6_TAN_HO = TAN(BT6_ANGLE_HO*PI/180)

'MU
BT6_XMU = 0
IF (BT6_ANGLE_VU = (180-BT6_ANGLE_VO)) THEN
	IF (BT6_ANGLE_VU >= 90) THEN
		BT6_YMU = BT6_WIDTH
	END IF
	IF (BT6_ANGLE_VU <= 90) THEN
		BT6_YMU = 0
	END IF
END IF

'LU
IF (BT6_ANGLE_VO <> 90) THEN
	BT6_XLU = ((BT6_WIDTH-BT6_YMU)/BT6_TAN_VO)
ELSE
	BT6_XLU = 0
END IF
BT6_YLU = BT6_WIDTH

'RU
IF (BT6_ANGLE_VU <> 90) THEN
	BT6_XRU = (BT6_YMU/BT6_TAN_VU)
ELSE
	BT6_XRU = 0
END IF
BT6_YRU = 0


'MO
BT6_XMO = BT6_LENGTH
IF (BT6_ANGLE_HO = (180-BT6_ANGLE_HU)) THEN
	IF (BT6_ANGLE_HO >= 90) THEN
		BT6_YMO = 0
	END IF
	IF (BT6_ANGLE_HO <= 90) THEN
		BT6_YMO = BT6_WIDTH
	END IF
END IF

'RO
IF (BT6_ANGLE_HU <> 90) THEN
	BT6_XRO = BT6_LENGTH - (BT6_YMO/BT6_TAN_HU)
ELSE
	BT6_XRO = BT6_LENGTH
END IF
BT6_YRO = 0

'LO
IF (BT6_ANGLE_HO <> 90) THEN
	BT6_XLO = BT6_LENGTH - ((BT6_WIDTH-BT6_YMO)/BT6_TAN_HO)
ELSE
	BT6_XLO = BT6_LENGTH
END IF
BT6_YLO = BT6_WIDTH


'X Korrektur unten
	IF BT6_XLU < 0 THEN
		BT6_OFFSET_U = ABS(BT6_XLU)
	END IF

	IF ((BT6_XRU < 0) AND (BT6_XRU < BT6_XLU)) THEN
		BT6_OFFSET_U = ABS(BT6_XRU)
	END IF

	BT6_XLU = BT6_XLU + BT6_OFFSET_U
	BT6_XMU = BT6_XMU + BT6_OFFSET_U
	BT6_XRU = BT6_XRU + BT6_OFFSET_U

'X Korrektur oben
	IF BT6_XRO > BT6_LENGTH THEN
		BT6_OFFSET_O = ABS(BT6_XRO-BT6_LENGTH)
	END IF

	IF ((BT6_XLO > BT6_LENGTH) AND (BT6_XLO > BT6_XRO)) THEN
		BT6_OFFSET_O = ABS(BT6_XLO-BT6_LENGTH)
	END IF

	BT6_XLO = BT6_XLO - BT6_OFFSET_O
	BT6_XMO = BT6_XMO - BT6_OFFSET_O
	BT6_XRO = BT6_XRO - BT6_OFFSET_O


'Ausgabe
	DIM I
	FOR I = 1 TO BT6_COUNT
		BT6 BT6_LENGTH, BT6_WIDTH, BT6_HEIGHT, BT6_XLU, BT6_YLU+Offset_Y, BT6_XMU, BT6_YMU+Offset_Y, BT6_XRU, BT6_YRU+Offset_Y, BT6_XRO, BT6_YRO+Offset_Y, BT6_XMO, BT6_YMO+Offset_Y, BT6_XLO, BT6_YLO+Offset_Y, BT6_INDEX, BT6_NAME, 0
		Offset_Y = I*(BT6_WIDTH+50)
	NEXT

END SUB

MAIN
