'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright by Weinmann Holzbausystemtechnik GmbH (c) 2004
'
' Filename:
'
' Description:
'
' Author:                tb32sot
'
' Date:                  20040121
'
' Version:                V0.01
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

SUB MAIN

 CONST BOHRDURCHMESSER = 10
 const MACROTITLE = "Macro"

 DIM dPX(16)
 DIM i
 DIM sIni
 DIM Title
 DIM SLOPE_DEFAULT

 SLOPE_DEFAULT = 30

 DIM BALKEN_LAENGE
 DIM BALKEN_BREITE
 DIM BALKEN_HOEHE


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

' ==========================================================================

	IF NOT FINDFIRSTSELECTED THEN
		DIM BEAMCOUNTER

		BEAMCOUNTER = GETCOUNTTYPE(CalcType("LS"))
		BEAMCOUNTER = BEAMCOUNTER + GETCOUNTTYPE(CalcType("QS"))
		BEAMCOUNTER = BEAMCOUNTER + GETCOUNTTYPE(CalcType("BT4"))
		BEAMCOUNTER = BEAMCOUNTER + GETCOUNTTYPE(CalcType("BT6"))

		IF BEAMCOUNTER = 1 THEN
			IF GETCOUNTTYPE(CalcType("LS")) = 1 THEN
				FINDFIRSTTYPE(CalcType("LS"))
			END IF
			IF GETCOUNTTYPE(CalcType("QS")) = 1 THEN
				FINDFIRSTTYPE(CalcType("QS"))
			END IF
			IF GETCOUNTTYPE(CalcType("BT4")) = 1 THEN
				FINDFIRSTTYPE(CalcType("BT4"))
			END IF
			IF GETCOUNTTYPE(CalcType("BT6")) = 1 THEN
				FINDFIRSTTYPE(CalcType("BT6"))
			END IF
		ELSE
		  MsgBox GETPRIVATEPROFILESTRING("Fehler", "F1", " ", sIni),vbOkOnly+vbCritical+vbSystemModal,MACROTITLE
		  exit sub
		END IF
	END IF

	IF NOT (ISBEAM OR (ISBEAMPROCESSING AND SELECTPARENTBEAM())) THEN
	  MsgBox GETPRIVATEPROFILESTRING("Fehler", "F2", " ", sIni),vbOkOnly+vbCritical+vbSystemModal,MACROTITLE
	  exit sub
	END IF

' ==========================================================================

 FOR i = LBOUND(dPX) TO UBOUND(dPX)
    dPX(i) = 0.0
 NEXT

 dPX(6) = 90 ' always perpendicular
 dPX(16) = 3 ' fixed to ende

 BALKEN_LAENGE = GETPARAM(1)
 BALKEN_BREITE = GETPARAM(2)
 BALKEN_HOEHE = GETPARAM(3)


	'IF MsgBox(GETPRIVATEPROFILESTRING("Anfang/Ende_orientiert", "T1", " ", sIni) & vbCrLf & vbCrLf & _
	'   GETPRIVATEPROFILESTRING("Anfang/Ende_orientiert", "T2", " ", sIni), _
	'   vbYesNo + vbQuestion, _
	'   GETPRIVATEPROFILESTRING("Anfang/Ende_orientiert", "T0", " ", sIni)) = vbYes THEN
	'   dPX(16) = 3       ' anfgang (links)
	'ELSE
	'    dPX(16) = 4        ' ende (rechts)
	'END IF

	'Title = GETPRIVATEPROFILESTRING("MACROTITLE", "T0", " ", sIni)

	'DO
	'
	'  dPX(0) = InputBoxI( _
	'  GETPRIVATEPROFILESTRING("Ebene", "T1", " ", sIni) & vbCrLf & vbCrLf & _
	'  GETPRIVATEPROFILESTRING("Ebene", "T2", " ", sIni) & vbCrLf & vbCrLf & _
	'  GETPRIVATEPROFILESTRING("Ebene", "T3", " ", sIni) & vbCrLf & _
	'  GETPRIVATEPROFILESTRING("Ebene", "T4", " ", sIni) & vbCrLf & _
	'  GETPRIVATEPROFILESTRING("Ebene", "T5", " ", sIni) & vbCrLf & _
	'  GETPRIVATEPROFILESTRING("Ebene", "T6", " ", sIni) & vbCrLf & vbCrLf, _
	'  Title, 3)

	'  IF bInputBoxCancel = 1 THEN
	'    EXIT SUB
	'  END IF

	'  IF (1 <= dPX(0)) and (dPX(0) <= 4)  THEN
	'      EXIT DO
	'  ELSE
	'      F_Title = GETPRIVATEPROFILESTRING("Fehler", "F3", " ", sIni)
	'          MsgBox F_Title,vbOkOnly + vbCritical + vbSystemModal,"Error"
	'  END IF
	'LOOP

	'Ebene setzten
	dPX(0) = 1

	' --- X_POSITION Obholz ---
	 DO
		dPX(1) = InputBoxFLoc("P1:",MACROTITLE,100)
		IF bInputBoxCancel = 1 THEN
			EXIT SUB
		END IF
		IF (dPX(1) > 0) and (dPX(1) < BALKEN_LAENGE)  THEN
			EXIT DO
		ELSE
			F_Title = GETPRIVATEPROFILESTRING("Fehler", "F6", " ", sIni)
			MsgBox F_Title,vbOkOnly + vbCritical + vbSystemModal,"Error"
		END IF
	 LOOP
	' ----------------

	' --- Dachneigung Global ---
	 DO
		dPX(7) = GetTempParam(0)
		IF dPX(7) = 0 THEN
			dPX(7) = SLOPE_DEFAULT
		END IF

		dPX(7) = InputBoxFLoc("P100:",MACROTITLE,dPX(7))
		IF bInputBoxCancel = 1 THEN
			EXIT SUB
		END IF
		IF (dPX(7) > 0) and (dPX(7) < 90)  THEN
			EXIT DO
		ELSE
			F_Title = GETPRIVATEPROFILESTRING("Fehler", "F6", " ", sIni)
			MsgBox F_Title,vbOkOnly + vbCritical + vbSystemModal,"Error"
		END IF
		SetTempParam 0,dPX(7)
	 LOOP
	' ----------------

	 dPX(8) = 90.0 + dPX(7)

	' --- Tiefe ---
	 DO
		dPX(11) = InputBoxFLoc("P11:",MACROTITLE,30)
		IF bInputBoxCancel = 1 THEN
			EXIT SUB
		END IF
		IF (dPX(11) > 0) and (dPX(11) < BALKEN_BREITE)  THEN
			EXIT DO
		ELSE
			F_Title = GETPRIVATEPROFILESTRING("Fehler", "F6", " ", sIni)
			MsgBox F_Title,vbOkOnly + vbCritical + vbSystemModal,"Error"
		END IF
	 LOOP
	' ----------------

	dPX(12) = dPX(11)

	IF bInputBoxCancel = 1 THEN
			EXIT SUB
	END IF

	DIM DRILLDEPTH

	IF dPX(0) = 1 OR dPX(0) = 3 THEN
			dPX(13) = GETPARAM(3) ' top or bottom ebene -> assign balken width
			DRILLDEPTH = GETPARAM(2)
			dPX(1) = dPX(1) + ( GETPARAM(2) - dPX(11) ) * TAN (  ( dPX(7) * PI ) / 180 )
	ELSE
			dPX(13) = GETPARAM(2) ' otherwise assign balken height
			DRILLDEPTH = GETPARAM(3)
			dPX(1) = dPX(1) + ( GETPARAM(3) - dPX(11) ) * TAN (  ( dPX(7) * PI ) / 180 )
	END IF

	DIM RETVAL
	RETVAL = BTLFUNCTION(dPX(16),20,dPX(0),dPX(1),dPX(2),dPX(3),dPX(4),dPX(5),dPX(6),dPX(7),dPX(8),dPX(9),dPX(10),dPX(11),dPX(12),dPX(13),dPX(14),dPX(15))

	IF NOT RETVAL THEN
			MsgBox GETLASTERROR,vbOkOnly + vbCritical + vbSystemModal,"Error"
	END IF


	RETVAL = MsgBox(GETPRIVATEPROFILESTRING("Kerve", "P16", "", sIni), vbYesNo + vbQuestion + vbSystemModal,"")

	DIM OFFSET
	OFFSET = 45.0 - dPX(7)


	IF RETVAL = vbYes THEN
		PAF dPX(0)
		MP dPX(1) - OFFSET, dPX(13) / 2.0, BOHRDURCHMESSER / 2.0, -DRILLDEPTH, 211, 0
	END IF

END SUB
MAIN
