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

const MACROTITLE = "Macro"

SUB MAIN

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
DIM sIni
DIM BALKEN_WIDTH
DIM BALKEN_HEIGHT
DIM RADIUS
DIM MILL_DEPTH

DIM MILL_WIDTH
DIM MILL_OVERHANG
DIM MILL_HEIGHT
' input values
DIM INDEX_TOP
DIM EBENE_TOP
DIM INDEX_FRONT
DIM EBENE_FRONT
DIM INDEX_CURVE
DIM EBENE_CURVE
DIM X2
DIM Y1
DIM Y3
DIM ANGLE
DIM ANGLE_TYPE
'INITIALISIERUNG DER KONSTANTEN
MILL_WIDTH = 50 ' width of the groove
                ' (also extent of the start position for curve milling)
MILL_OVERHANG = 0 ' extend position in height-axis movement
MILL_HEIGHT = 0 ' z-coordinate of the PP element

INDEX_FRONT = 211 ' default values
EBENE_FRONT = 5
INDEX_TOP = 111
EBENE_TOP = 1
INDEX_CURVE = 211
EBENE_CURVE = 2
X2 = 10
Y1 = 25
Y3 = 10
ANGLE = 0.0
ANGLE_TYPE = "Acc"

'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)
BALKEN_HEIGHT = GETPARAM(3)
IF NOT GetDimension("X2:", sIni, X2, BALKEN_WIDTH) THEN EXIT SUB
IF NOT GetDimension("Y1:", sIni, Y1, BALKEN_WIDTH) THEN EXIT SUB
IF NOT GetDimension("Y3:", sIni, Y3, BALKEN_WIDTH-Y1) THEN EXIT SUB
RADIUS = BALKEN_WIDTH - Y1 - Y3

' ==========================================================================
' front groove
MILL_DEPTH = -(MILL_HEIGHT + X2)
PAF EBENE_FRONT
PP BALKEN_HEIGHT+MILL_OVERHANG, Y1, MILL_DEPTH, INDEX_FRONT, ANGLE, MILL_HEIGHT
PP -MILL_OVERHANG, Y1, MILL_DEPTH, INDEX_FRONT, ANGLE, MILL_HEIGHT
PP -MILL_OVERHANG, Y1+MILL_WIDTH, MILL_DEPTH, INDEX_FRONT, ANGLE, MILL_HEIGHT
PP BALKEN_HEIGHT+MILL_OVERHANG, Y1+MILL_WIDTH, MILL_DEPTH, INDEX_FRONT, ANGLE, MILL_HEIGHT
PP BALKEN_HEIGHT+MILL_OVERHANG, Y1, MILL_DEPTH, INDEX_FRONT, ANGLE, MILL_HEIGHT
' top groove
MILL_DEPTH = -(MILL_HEIGHT + Y3)
PAF EBENE_TOP
PP X2+RADIUS, BALKEN_HEIGHT+MILL_OVERHANG, MILL_DEPTH, INDEX_TOP, ANGLE, MILL_HEIGHT
PP X2+RADIUS-MILL_WIDTH, BALKEN_HEIGHT+MILL_OVERHANG, MILL_DEPTH, INDEX_TOP, ANGLE, MILL_HEIGHT
PP X2+RADIUS-MILL_WIDTH, -MILL_OVERHANG, MILL_DEPTH, INDEX_TOP, ANGLE, MILL_HEIGHT
PP X2+RADIUS, -MILL_OVERHANG, MILL_DEPTH, INDEX_TOP, ANGLE, MILL_HEIGHT
PP X2+RADIUS, BALKEN_HEIGHT+MILL_OVERHANG, MILL_DEPTH, INDEX_TOP, ANGLE, MILL_HEIGHT
' curve milling
PAF EBENE_CURVE
MILL_DEPTH = -(MILL_HEIGHT+BALKEN_HEIGHT)
PP X2+RADIUS, BALKEN_WIDTH+MILL_WIDTH, MILL_DEPTH, INDEX_CURVE, ANGLE, MILL_HEIGHT
PP X2+RADIUS, BALKEN_WIDTH-Y3, MILL_DEPTH, INDEX_CURVE, ANGLE, MILL_HEIGHT
KB X2, Y1, RADIUS, ANGLE_TYPE, MILL_DEPTH, INDEX_CURVE, ANGLE, MILL_HEIGHT
PP -MILL_WIDTH, Y1, MILL_DEPTH, INDEX_CURVE, ANGLE, MILL_HEIGHT
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

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

MAIN