def __SetColor(self): red, green, blue = vs.ColorIndexToRGB(self.__fColor) vs.SetRField(self.__fTextureHand, 'NNAMaxon Plain Color', 'Color', vs.Num2Str(0, red)) vs.SetRField(self.__fTextureHand, 'NNAMaxon Plain Color', 'Color G', vs.Num2Str(0, green)) vs.SetRField(self.__fTextureHand, 'NNAMaxon Plain Color', 'Color B', vs.Num2Str(0, blue))
def set_parameter(self, name: str, value): """Sets the parameter to the given value, type depends on the plugin parameter. """ self.__parameters[name] = value value = str(value) if not isinstance(value, float) else vs.Num2Str( -2, value) vs.SetRField(ActivePlugin().handle, ActivePlugin().name, name, value)
def CheckField(val, name): index = val.find(name) if index > -1: val = val.replace(name, "") val = vs.Str2Num(val) if val <= 0: val = 1 val = vs.Num2Str(2, val) if index > -1: val = val + name return val
def __CreateTexture( self ): counter = 1 textureName = self.__fDefaultName while vs.GetObject( textureName ) != vs.Handle(): textureName = self.__fDefaultName + '-' + vs.Num2Str( 0, counter ) counter += 1 curtainTexture = vs.CreateTexture() vs.CreateShaderRecord( curtainTexture, kColorFamilyIndex, kPlainColorIndex ) recHand = vs.CreateShaderRecord( curtainTexture, kTransparencyFamilyIndex, kPlainTransparencyIndex ) vs.SetName( curtainTexture, textureName ) self.__fTextureHand = curtainTexture self.__SetColor() self.__SetOpacity( recHand ) self.__fRefNum = vs.Name2Index( textureName ) return textureName
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)
def __SetOpacity(self, recHand): vs.SetRField(self.__fTextureHand, 'NNAMaxon Plain Transparency', vs.GetFldName(recHand, 4), vs.Num2Str(4, self.__fTransparency))