'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright by Weinmann Holzbausystemtechnik GmbH (c) 2005
'
' Filename:                Makro_8.WMK
'
' Description:        Bau Vila Makrodefinition, Makro 8
'
' Author:                Mikan
'
' Date:                        20050510
'
' Version:                V0.01
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

const MACROTITLE = "Macro"

SUB MAIN

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
DIM sIni
DIM F_Title
DIM BALKEN_WIDTH
DIM EBENE
DIM DEPTH_RESERVE
DIM KORREKTUR
DIM WINKEL_ALPHA
DIM WINKEL_GAMMA
DIM WINKEL_STEIGUNG
DIM WINKEL_SEMA

DIM CUT_START_X
DIM CUT_END_Y
DIM CUT_DEPTH
DIM WINKEL ' dachneigung

'INITIALISIERUNG DER KONSTANTEN
EBENE = 1        'Bezugsebene
DEPTH_RESERVE = 0 '50 mm ausfahren
KORREKTUR = 2    'keine korrektur
WINKEL_ALPHA = 90    '
WINKEL_STEIGUNG = 0    ' gilotina
WINKEL_SEMA = 0          ' do not convert
CUT_END_Y = 15
WINKEL = 30

'Holen Parameterbezeichnungen abhaengig von der Landessprache
sIni = "BV_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

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

BALKEN_WIDTH = GETPARAM(2)

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

IF NOT GetDimension("Y1:", sIni, CUT_END_Y, CUT_END_Y) THEN EXIT SUB
IF (CUT_END_Y < 0) OR (CUT_END_Y > BALKEN_WIDTH) THEN
    MsgBox GETPRIVATEPROFILESTRING("Fehler", "F5", " ", sIni),vbOkOnly+vbCritical+vbSystemModal,MACROTITLE
    EXIT SUB
END IF

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

IF NOT GetFloat("P100:", sIni, WINKEL, WINKEL) THEN EXIT SUB

CUT_DEPTH = BALKEN_WIDTH - CUT_END_Y + DEPTH_RESERVE
CUT_START_X = (BALKEN_WIDTH - CUT_END_Y) / TAN( DegToRad(WINKEL) )
WINKEL_GAMMA = 180 - WINKEL
SG CUT_START_X, BALKEN_WIDTH, 0, WINKEL_ALPHA, WINKEL_GAMMA, CUT_DEPTH, EBENE, KORREKTUR, WINKEL_STEIGUNG, WINKEL_SEMA

END SUB

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

PRIVATE FUNCTION GetDimension(DimName, IniFile, DimVal, MaxVal)
DO
  DimVal = InputBoxFLoc(DimName, MACROTITLE, DimVal)

  IF bInputBoxCancel = 1 THEN
     GetDimension = False
     EXIT FUNCTION
  END IF

  IF (0 <= DimVal) and (DimVal <= MaxVal) THEN
    GetDimension = true
    EXIT FUNCTION
  ELSE
  MsgBox GETPRIVATEPROFILESTRING("Fehler", "F5", " ", IniFile),vbOkOnly+vbCritical+ vbSystemModal,MACROTITLE
  END IF
LOOP
END FUNCTION


PRIVATE FUNCTION GetFloat(DimName, IniFile, DimVal, MaxVal)
DO
  DimVal = InputBoxF(DimName, MACROTITLE, DimVal)

  IF bInputBoxCancel = 1 THEN
     GetFloat = False
     EXIT FUNCTION
  END IF

  IF (0 <= DimVal) and (DimVal <= MaxVal) THEN
    GetFloat = true
    EXIT FUNCTION
  ELSE
  MsgBox GETPRIVATEPROFILESTRING("Fehler", "F5", " ", IniFile),vbOkOnly+vbCritical+ vbSystemModal,MACROTITLE
  END IF
LOOP
END FUNCTION

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

PRIVATE FUNCTION DegToRad(Degrees)

        DegToRad = (Degrees * PI) / 180

END FUNCTION

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

MAIN
