Ejemplo n.º 1
0
def UpdateParams():
    #Set the visibilities
    leafTypeField = vs.GetRField(gObjHandle, gObjName, 'Leaf')
    hasLeaf = not (leafTypeField == 'None')

    vs.vsoWidgetSetEnable(Constants.kParamWidget_OpenTheWindow, hasLeaf)

    wdwOpenEnable = vs.GetRField(gObjHandle, gObjName, 'OpenTheWindow')
    openTheWindow = (wdwOpenEnable == 'True')

    vs.vsoWidgetSetEnable(Constants.kParamWidget_OpeningAngle, openTheWindow
                          and hasLeaf)

    wdwHasCurts = vs.GetRField(gObjHandle, gObjName, 'HasCurts')
    hasCurts = (wdwHasCurts == 'True')

    vs.vsoWidgetSetEnable(Constants.kParamWidget_LedgeType, hasCurts)
    vs.vsoWidgetSetEnable(Constants.kParamWidget_LedgeMaterial, hasCurts)
    vs.vsoWidgetSetEnable(Constants.kParamWidget_DrawTheCurts, hasCurts)

    drwTheCurts = vs.GetRField(gObjHandle, gObjName, 'DrawTheCurts')
    drawTheCurts = (drwTheCurts == 'True')

    vs.vsoWidgetSetEnable(Constants.kParamWidget_CurtsColor, hasCurts
                          and drawTheCurts)
    vs.vsoWidgetSetEnable(Constants.kParamWidget_Pieces, hasCurts
                          and drawTheCurts)
    vs.vsoWidgetSetEnable(Constants.kParamWidget_Opacity, hasCurts
                          and drawTheCurts)
Ejemplo n.º 2
0
 def value(self):
     """:rtype: str | int | bool | float"""
     return {
         True: {
             PioFieldTypeEnum.INTEGER: self.__to_int,
             PioFieldTypeEnum.BOOLEAN: self.__to_bool,
             PioFieldTypeEnum.REAL: self.__to_float,
             PioFieldTypeEnum.REAL_DIMENSION: self.__to_float,
             PioFieldTypeEnum.REAL_X_COORDINATE: self.__to_float,
             PioFieldTypeEnum.REAL_Y_COORDINATE: self.__to_float
         },
         False: {
             DataFieldTypeEnum.INTEGER: self.__to_int,
             DataFieldTypeEnum.BOOLEAN: self.__to_bool,
             DataFieldTypeEnum.NUMBER_GENERAL: self.__to_float,
             DataFieldTypeEnum.NUMBER_DECIMAL: self.__to_float,
             DataFieldTypeEnum.NUMBER_PERCENTAGE: self.__to_float,
             DataFieldTypeEnum.NUMBER_SCIENTIFIC: self.__to_float,
             DataFieldTypeEnum.NUMBER_FRACTIONAL: self.__to_float,
             DataFieldTypeEnum.NUMBER_DIMENSION: self.__to_float,
             DataFieldTypeEnum.NUMBER_DIMENSION_AREA: self.__to_float_from_area,
             DataFieldTypeEnum.NUMBER_DIMENSION_VOLUME: self.__to_float_from_volume,
             DataFieldTypeEnum.NUMBER_ANGLE: self.__to_float_from_angle
         }
     }.get(self.__parametric).get(self.type, self.__to_str)(
         vs.GetRField(self.__object_handle, self.__record_name, self.name))
Ejemplo n.º 3
0
 def __SetCurtainStyle( self ):
     isSuccessful, objName, objHand, recHand, wallHand = vs.GetCustomObjectInfo()
     if isSuccessful:
         if vs.IsNewCustomObject( objName ):
             refNum = -1
         else:
             refNum = vs.Name2Index( vs.GetRField( objHand, objName, "__CurtainTexture" ) )
         
         textureObj = Texture( vs.GetPluginString( 4020 ), refNum, self.__fColor, self.__fOpacity )
         textureIndex, textureName = textureObj.GetTexture()
             
         for pieceH in self.__fPiecesHandles:
             if pieceH:
                 vs.SetTextureRef( pieceH, textureIndex, 0 )
                 
         vs.SetRField( objHand, objName, "__CurtainTexture", textureName )
Ejemplo n.º 4
0
def do_it(h):
    # get fixture record data
    inst_type = vs.GetRField(h, 'Lighting Device', 'Inst Type')
    fixture_mode = vs.GetRField(h, 'Lighting Device', 'Fixture Mode')
    channel = vs.GetRField(h, 'Lighting Device', number_field)
    universe = vs.GetRField(h, 'Lighting Device', universe_field)
    address = vs.GetRField(h, 'Lighting Device', address_field)
    purpose = vs.GetRField(h, 'Lighting Device', name_field)
    uid = vs.GetRField(h, 'Lighting Device', 'UID')

    # prepare patch list data for write
    fixture_type = fixture_mode.split('.')[0] if fixture_mode else inst_type
    user_id = channel if channel else uid.split('.')[0]
    dmx_universe = universe if is_number(universe) else ''
    dmx_address = address if (is_number(universe)
                              and is_number(address)) else ''
    name = purpose if purpose else uid.split('.')[0]

    # write patch list data
    file.write(user_id + ',' + dmx_universe + ':' + dmx_address + ',' +
               fixture_type + ',' + name + '\n\r')
def add_to_list(h):
    symbol_name = vs.GetRField(h, 'Lighting Device', 'Symbol Name')
    symbol_list.add(vs.GetObject(symbol_name))
Ejemplo n.º 6
0
def SetupDialog():
    for i in range(1,6):
        vs.AddChoice(Constants.dialogId,kLeaf,vs.GetPluginString(4000+i),i-1)
        
    vs.AddChoice(Constants.dialogId,kLedgeType,vs.GetPluginString(4006),0)
    vs.AddChoice(Constants.dialogId,kLedgeType,vs.GetPluginString(4007),1)
    
    vs.AddChoice(Constants.dialogId,kLedgeMaterial,vs.GetPluginString(4008),0)
    vs.AddChoice(Constants.dialogId,kLedgeMaterial,vs.GetPluginString(4009),1)
    vs.AddChoice(Constants.dialogId,kLedgeMaterial,vs.GetPluginString(4010),2)
    
    fraction, display, format, upi, name, squareName = vs.GetUnits()
    
    #######################################################
    value = vs.GetRField(Constants.h,kPluginName,'IDLabel')
    vs.SetEditInteger(Constants.dialogId, kIDLabel, vs.Str2Num(value))
    #######################################################    
    value = vs.GetRField(Constants.h,kPluginName,'Width')
    
    inches = 0
    if(format == 2 or format == 3):
         
        index = value.find("'")
        if index > -1:
            splitVal = value.split("'")
            inches += vs.Str2Num(splitVal[0])*12.0
             
            str = splitVal[1]
            index = str.find(name)
            if index > -1:
                str = str.replace(name, "")
                value = vs.Str2Num(str)
                inches += value
         
        else:
            index = value.find(name)
            if index > -1:
                value = value.replace(name,"")
                value = vs.Str2Num(value)
                inches += value
    else:
        index = value.find(name)
        if index > -1:
            value = value.replace(name, "")
            
        inches = vs.Str2Num(value)
    
    vs.SetEditReal(Constants.dialogId,kWidth,kEditRealDim,inches)
    #######################################################    
    value = vs.GetRField(Constants.h,kPluginName,'Height')
    
    inches = 0
    if(format == 2 or format == 3):
         
        index = value.find("'")
        if index > -1:
            splitVal = value.split("'")
            inches += vs.Str2Num(splitVal[0])*12.0
             
            str = splitVal[1]
            index = str.find(name)
            if index > -1:
                str = str.replace(name, "")
                value = vs.Str2Num(str)
                inches += value
         
        else:
            index = value.find(name)
            if index > -1:
                value = value.replace(name,"")
                value = vs.Str2Num(value)
                inches += value
    else:
        index = value.find(name)
        if index > -1:
            value = value.replace(name, "")
            
        inches = vs.Str2Num(value)
    
    vs.SetEditReal(Constants.dialogId,kHeight,kEditRealDim,inches)
    #######################################################    
    value = vs.GetRField(Constants.h,kPluginName,'ElvInWall')
    
    inches = 0
    if(format == 2 or format == 3):
         
        index = value.find("'")
        if index > -1:
            splitVal = value.split("'")
            inches += vs.Str2Num(splitVal[0])*12.0
             
            str = splitVal[1]
            index = str.find(name)
            if index > -1:
                str = str.replace(name, "")
                value = vs.Str2Num(str)
                inches += value
         
        else:
            index = value.find(name)
            if index > -1:
                value = value.replace(name,"")
                value = vs.Str2Num(value)
                inches += value
    else:
        index = value.find(name)
        if index > -1:
            value = value.replace(name, "")
            
        inches = vs.Str2Num(value)
    
    vs.SetEditReal(Constants.dialogId,kElevationInWall,kEditRealDim,inches)
    #######################################################    
    value = vs.GetRField(Constants.h, kPluginName, 'OpenTheWindow')
    vs.SetBooleanItem(Constants.dialogId, kOpenTheWindow   ,value =='True')
    #######################################################    
    value = vs.GetRField(Constants.h,kPluginName,'OpeningAngle')
    newNumber = vs.Str2Num(value)
    vs.SetEditReal(Constants.dialogId, kOpeningAngle, kEditRealAng,newNumber)  
    #######################################################    
    leafType = vs.GetRField(Constants.h,kPluginName,'Leaf')
    if leafType == 'None':
        vs.SelectChoice(Constants.dialogId, kLeaf, 0, True)
    elif leafType == '1(no glass)':
        vs.SelectChoice(Constants.dialogId, kLeaf, 1, True)
    elif leafType == '1(glass)':
        vs.SelectChoice(Constants.dialogId, kLeaf, 2, True)
    elif leafType == '2(no glass)':
        vs.SelectChoice(Constants.dialogId, kLeaf, 3, True)
    else:
        vs.SelectChoice(Constants.dialogId, kLeaf, 4, True)
    #######################################################        
    value = vs.GetRField(Constants.h,kPluginName,'HasCurts')
    vs.SetBooleanItem(Constants.dialogId, kHasCurtains, value =='True')
    #######################################################    
    ledgeType = vs.GetRField(Constants.h,kPluginName,'LedgeType')
    if ledgeType == 'Attach to wall':
        vs.SelectChoice(Constants.dialogId,kLedgeType,0,True)
    else:
        vs.SelectChoice(Constants.dialogId,kLedgeType,1,True)
    #######################################################              
    ledgeMaterial = vs.GetRField(Constants.h,kPluginName,'LedgeMaterial')
    if ledgeMaterial == 'Wood':
        vs.SelectChoice(Constants.dialogId,kLedgeMaterial,0,True)
    elif ledgeMaterial == 'Plastic':
        vs.SelectChoice(Constants.dialogId,kLedgeMaterial,1,True)
    else:
        vs.SelectChoice(Constants.dialogId,kLedgeMaterial,2,True)
    #######################################################        
    value = vs.GetRField(Constants.h,kPluginName,'DrawTheCurts')
    vs.SetBooleanItem(Constants.dialogId,kDrawTheCurts,value == 'True')
    #######################################################    
    colorIndex = vs.GetRField(Constants.h, kPluginName, '__CustomColor')
    vs.SetColorChoice(Constants.dialogId,kCurtsColor,vs.Str2Num(colorIndex))
    #######################################################    
    value = vs.GetRField(Constants.h,kPluginName,'Pieces')
    newNumber = vs.Str2Num(value)
    vs.SetEditInteger(Constants.dialogId, kPieces, newNumber)
    #######################################################    
    opacityText = vs.GetRField(Constants.h,kPluginName,'Opacity')
    vs.SetControlData(Constants.dialogId,kOpacitySlider,vs.Str2Num(opacityText))
    #######################################################    
    text = vs.GetPluginString(3054)
    text += ' ('
    text += opacityText
    text +='%): '
        
    vs.SetItemText(Constants.dialogId,kOpacityText,text)
    
    #######################################################
    hasCurtain = vs.GetBooleanItem(Constants.dialogId,kHasCurtains)
    drawTheCurtain = vs.GetBooleanItem(Constants.dialogId,kDrawTheCurts)
    
    index = vs.GetSelectedChoiceIndex(Constants.dialogId, kLeaf, 0)
    hasLeaf = not(index == 0)
    
    EnableItems(hasLeaf, vs.GetBooleanItem(Constants.dialogId,kOpenTheWindow), hasCurtain, drawTheCurtain)
    vs.SetSliderLiveUpdate(Constants.dialogId, kOpacitySlider, True)
Ejemplo n.º 7
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()
Ejemplo n.º 8
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)