Пример #1
0
	def __init__(self, width, height, position ):
		
		# #Validation
		# if width < 2*self.__frameWidth:
		# 	#return Leaf width is too small.
		# 	# vs.AlrtDialog("Leaf width is too small.")
		
		
		# if height < 2*self.__frameWidth:
		# 	#return Leaf hidth is too small.
		# 	# vs.AlrtDialog("Leaf height is too small.")
		
		upi = vs.GetPrefReal(152) / 25.4
		# self.upi = upi
		# vs.AlrtDialog(str(upi))
		
		#Frame instance parameters
		self.height 		= height
		self.width 			= width
		self.position 		= position
		
		self.hLeaf 			= vs.Handle()
		self.leafType 		= kTypeNone
		self.isGlassTrue 	= True
		self.openingAngle 	= 0
		
		
		self.__frameOverlap 			= 15*upi
		self.__frameThickness 			= self.kFrameThicknessNotUPI*upi
		self.__frameWidth 				= 50*upi
		self.__frameMainWidth			= self.__frameWidth - self.__frameOverlap
		self.__frameOverlapThickness	= 5*upi
		self.__frameInsideThinckness 	= self.__frameThickness - self.__frameOverlapThickness

		self.__glassThikness			= 2*upi
Пример #2
0
def Reset():
    width = vs.PWidth
    height = vs.PHeight
    elevation = vs.PElvInWall
    angle = vs.POpeningAngle
    leafType = vs.GetRField(gObjHandle, gObjName, 'Leaf')
    isOpened = vs.GetRField(gObjHandle, gObjName, 'OpenTheWindow')
    wallType = vs.GetTypeN(gWallHandle)

    if (wallType == 68 or wallType == 89):
        thickness = vs.WallWidth(gWallHandle)
    else:
        upi = vs.GetPrefReal(152) / 25.4
        thickness = 100 * upi

    if isOpened == "False":
        angle = 0

    frameObj = frame.Frame(width, height, thickness, elevation, leafType,
                           angle)
    frameObj.Draw()

    #draw curtain#######################

    if vs.PHasCurts:
        objLedge = Ledge.LedgeObj(height / 20, height / 40, width,
                                  height + elevation, vs.PLedgeMaterial,
                                  vs.PLedgeType, thickness)
        objLedge.DrawLedge()

        hObject = vs.LNewObj()
        if objLedge.getMaterial() == "Wood":
            #if self.__fMaterial == LedgeMaterial.Wood:
            vs.SetFillBack(hObject, Constants.kColorIndexWood)
        elif objLedge.getMaterial() == "Metal":
            #elif self.__fMaterial == LedgeMaterial.Metal:
            vs.SetFillBack(hObject, Constants.kColorIndexMetal)
        else:
            vs.SetFillBack(hObject, Constants.kColorIndexPlastic)

        curtainPieces = int(
            vs.Str2Num(vs.GetRField(gObjHandle, gObjName, "Pieces")))
        curtainStartZ = elevation + thickness / 2
        curtainStartY = thickness / 2 - objLedge.getLedgeShaftWidth(
        ) * 1.5 + objLedge.getLedgeWidth()
        curtainHeight = objLedge.getLedgeHeight(
        ) - objLedge.getLedgeShaftHeight()
        curtainWidth = width * Ledge.kLedgeOutWindow

        curtainCurvesWidth = 2
        if curtainCurvesWidth > objLedge.getLedgeShaftWidth():
            curtainCurvesWidth = objLedge.getLedgeShaftWidth()

        curtainOpacity = int(
            vs.Str2Num(vs.GetRField(gObjHandle, gObjName, 'Opacity')))
        distanceBetweenCurtainPieces = 30
        curtainCurveStep = 30
        curtainColor = vs.Str2Num(
            vs.GetRField(gObjHandle, gObjName, '__CustomColor'))
        # distanceBetweenCurtainPieces, curtainCurveStep and curtainCurveWidth are not neccessary to add in the creation of the object
        curtain = Curtain(Vector(0, -curtainStartY,
                                 curtainStartZ), curtainWidth, curtainHeight,
                          curtainColor, curtainPieces, curtainOpacity,
                          distanceBetweenCurtainPieces, curtainCurveStep,
                          curtainCurvesWidth)
        if vs.PDrawTheCurts:
            curtain.DrawCurtain()
Пример #3
0
def CheckValues():
    #We check the values each time the user enters new data in the OIP
    global winWidth
    fraction, display, format, upi, name, squareName = vs.GetUnits()

    col = vs.GetRField(gObjHandle, gObjName, 'CurtsColor')
    if col == 'White':
        vs.SetRField(gObjHandle, gObjName, '__CustomColor', 256)
    elif col == 'Black':
        vs.SetRField(gObjHandle, gObjName, '__CustomColor', 257)
    elif col == 'Custom Color' and vs.P__PrevCustomColor != 0:
        vs.SetRField(gObjHandle, gObjName, '__CustomColor',
                     vs.P__PrevCustomColor)

####################################
    val = vs.GetRField(gObjHandle, gObjName, 'IDLabel')
    val = vs.Str2Num(val)
    if val < 0:
        val = 0
        vs.SetRField(gObjHandle, gObjName, 'IDLabel', vs.Num2Str(0, val))

    ################################################
    val = vs.GetRField(gObjHandle, gObjName, 'Width')

    if (format == 2 or format == 3):
        inches = 0

        index = val.find("'")
        if index > -1:
            splitVal = val.split("'")
            inches += vs.Str2Num(splitVal[0]) * 12.0

            str = splitVal[1]
            index = str.find(name)
            if index > -1:
                str = str.replace(name, "")
                val = vs.Str2Num(str)
                inches += val

        else:
            index = val.find(name)
            if index > -1:
                val = val.replace(name, "")
                val = vs.Str2Num(val)
                inches += val

        if inches < 0:
            inches = 1

        val = vs.Num2Str(2, inches)
        val = val + name
    else:
        val = CheckField(val, name)

    vs.SetRField(gObjHandle, gObjName, 'Width', val)

    val = val.replace(name, "")
    val = vs.Str2Num(val)
    winWidth = val

    ################################################
    val = vs.GetRField(gObjHandle, gObjName, 'Height')
    if (format == 2 or format == 3):
        inches = 0

        index = val.find("'")
        if index > -1:
            splitVal = val.split("'")
            inches += vs.Str2Num(splitVal[0]) * 12.0

            str = splitVal[1]
            index = str.find(name)
            if index > -1:
                str = str.replace(name, "")
                val = vs.Str2Num(str)
                inches += val

        else:
            index = val.find(name)
            if index > -1:
                val = val.replace(name, "")
                val = vs.Str2Num(val)
                inches += val

        if inches < 0:
            inches = 1

        val = vs.Num2Str(2, inches)
        val = val + name
    else:
        val = CheckField(val, name)

    vs.SetRField(gObjHandle, gObjName, 'Height', val)

    ################################################
    val = vs.GetRField(gObjHandle, gObjName, 'ElvInWall')
    if (format == 2 or format == 3):
        inches = 0

        index = val.find("'")
        if index > -1:
            splitVal = val.split("'")
            inches += vs.Str2Num(splitVal[0]) * 12.0

            str = splitVal[1]
            index = str.find(name)
            if index > -1:
                str = str.replace(name, "")
                val = vs.Str2Num(str)
                inches += val

        else:
            index = val.find(name)
            if index > -1:
                val = val.replace(name, "")
                val = vs.Str2Num(val)
                inches += val

        if inches < 0:
            inches = 1

        val = vs.Num2Str(2, inches)
        val = val + name
    else:
        val = CheckField(val, name)

    vs.SetRField(gObjHandle, gObjName, 'ElvInWall', val)

    ##########################################################
    val = vs.GetRField(gObjHandle, gObjName, 'OpeningAngle')
    val = vs.Str2Num(val)
    if val < 0:
        val = 0
    elif val > 90:
        val = 90

    vs.SetRField(gObjHandle, gObjName, 'OpeningAngle', vs.Num2Str(2, val))

    ################################################
    #In inches: maxPieces = winWidth(in inches) // (floor division) Max width of a pice
    inchesPerUnit = 1 / upi
    winWidth = inchesPerUnit * winWidth
    maxPieces = winWidth // Constants.kMaxWidthOfPieceInInches

    val = vs.GetRField(gObjHandle, gObjName, 'Pieces')
    val = vs.Str2Num(val)

    if val > maxPieces:
        val = maxPieces
        vs.SetRField(gObjHandle, gObjName, 'Pieces', vs.Num2Str(0, val))

    ##############################################################
    val = vs.GetRField(gObjHandle, gObjName, 'Opacity')
    val = vs.Str2Num(val)
    if val > 100:
        val = 100
    elif val < 0:
        val = 0

    vs.SetRField(gObjHandle, gObjName, 'Opacity', vs.Num2Str(0, val))

    width = vs.PWidth
    height = vs.PHeight

    upi = vs.GetPrefReal(152) / 25.4

    wallType = vs.GetTypeN(gWallHandle)
    if (wallType == 68 or wallType == 89):
        thickness = vs.WallWidth(gWallHandle)
    else:
        thickness = 100 * upi

    leafType = vs.GetRField(gObjHandle, gObjName, 'Leaf')
    if (leafType == 'None'):
        twoWings = False
    elif (leafType == '1(no glass)'):
        twoWings = False
    elif (leafType == '1(glass)'):
        twoWings = False
    elif (leafType == '2(no glass)'):
        twoWings = True
    elif (leafType == '2(glass)'):
        twoWings = True

    if (width / 3 <= thickness and twoWings == True):
        width = 3 * thickness + 10 * upi
        vs.SetRField(gObjHandle, gObjName, 'Width', width)
    if (thickness >= height / 2):
        height = 2 * thickness + 10 * upi
        vs.SetRField(gObjHandle, gObjName, 'Height', height)
    if (thickness >= width / 2):
        width = thickness * 2 + 10 * upi
        vs.SetRField(gObjHandle, gObjName, 'Width', width)
Пример #4
0
    def Draw(self):
        vs.BeginXtrd(0,self.thickness)
        vs.Rect(-self.width/2.0, self.height/2.0, self.width/2.0, self.height/2.0-self.thickness)
        r1 = vs.LNewObj()
        vs.Rect(-self.width/2.0, self.height/2.0-self.thickness, -self.width/2.0+self.thickness, -self.height/2.0+self.thickness)
        r2 = vs.LNewObj()
        r2 = vs.AddSurface(r1, r2)
        vs.Rect(self.width/2.0-self.thickness, self.height/2.0-self.thickness, self.width/2.0, -self.height/2.0+self.thickness)
        r3 = vs.LNewObj()
        r3 = vs.AddSurface(r2,r3)
        vs.Rect(-self.width/2.0, -self.height/2.0+self.thickness, self.width/2.0, -self.height/2.0)
        r4 = vs.LNewObj()
        r4 = vs.AddSurface(r3,r4)
        if (self.wingsNum == 2):
            vs.Rect(-self.thickness/2.0, self.height/2.0-self.thickness, self.thickness/2.0, -self.height/2.0+self.thickness)
            r5 = vs.LNewObj()
            r4 = vs.AddSurface(r4,r5)
        vs.EndXtrd()
        vs.SetRot3D(vs.LNewObj(), 90, 0, 0, 0, -self.height/2.0, 0)
        vs.Move3DObj(vs.LNewObj(), 0, self.height/2.0+self.thickness/2.0, 0)
        vs.Move3DObj(vs.LNewObj(), 0, 0, self.elevation)

        #instert leafs

        upi = vs.GetPrefReal(152) / 25.4

        leafPosOffsetY = self.thickness - leaf.Leaf.kFrameThicknessNotUPI*upi
        posFirstLeaf = (-self.width/2.0+self.thickness,
                        -self.thickness/2.0+leafPosOffsetY,
                         self.elevation+self.thickness  )

        if self.wingsNum == 0:

            wingsWidth  = self.width  - 2.0*self.thickness
            wingsHeight = self.height - 2.0*self.thickness

            firstLeaf = leaf.Leaf(wingsWidth, wingsHeight, posFirstLeaf)
            firstLeaf.SetType(leaf.kTypeNone, self.isGlass)
            firstLeaf.Draw()

        elif self.wingsNum == 1:

            wingsWidth  = self.width  - 2.0*self.thickness
            wingsHeight = self.height - 2.0*self.thickness

            firstLeaf = leaf.Leaf(wingsWidth, wingsHeight, posFirstLeaf)
            firstLeaf.SetType(leaf.kTypeLeft, self.isGlass)
            firstLeaf.Draw()
            firstLeaf.SetOpening(self.openingAngle)

        elif self.wingsNum == 2:

            wingsWidth  = (self.width  - 3.0*self.thickness)/2.0
            wingsHeight =  self.height - 2.0*self.thickness

            firstLeaf  = leaf.Leaf(wingsWidth, wingsHeight, posFirstLeaf)
            firstLeaf.SetType(leaf.kTypeLeft, self.isGlass)
            firstLeaf.Draw()
            firstLeaf.SetOpening(self.openingAngle)
            
            posSecondLeaf = (self.thickness/2.0, -self.thickness/2.0+leafPosOffsetY, self.elevation+self.thickness)
            
            secondLeaf = leaf.Leaf(wingsWidth, wingsHeight, posSecondLeaf)
            secondLeaf.SetType(leaf.kTypeRight, self.isGlass)
            secondLeaf.Draw()
            secondLeaf.SetOpening(self.openingAngle)
Пример #5
0
 def __get_volume_units_per_cubic_inch() -> float:
     return vs.GetPrefReal(180)
Пример #6
0
 def __get_area_units_per_square_inch() -> float:
     return vs.GetPrefReal(176)
Пример #7
0
 def __get_length_units_per_inch() -> float:
     return vs.GetPrefReal(152)
Пример #8
0
 def text_size(self) -> float:
     """Text size in points
     """
     return vs.GetPrefReal(57) / 42.42424