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
def update_parameters_state(self, param_handle): vs.vsoWidgetSetVisible(self.kWidgetID_PictureName, param_handle == vs.Handle(0)) # vs.vsoWidgetSetVisible(self.kWidgetID_NameEditButton, param_handle != vs.Handle(0)) vs.vsoWidgetSetEnable(self.kWidgetID_ImageWidth, vs.PWithImage) vs.vsoWidgetSetEnable(self.kWidgetID_ImageHeight, vs.PWithImage) vs.vsoWidgetSetEnable(self.kWidgetID_ImagePosition, vs.PWithImage) vs.vsoWidgetSetEnable(self.kWidgetID_ImageTexture, vs.PWithImage) vs.vsoWidgetSetEnable(self.kWidgetID_WindowWidth, vs.PWithMatboard) vs.vsoWidgetSetEnable(self.kWidgetID_WindowHeight, vs.PWithMatboard) vs.vsoWidgetSetEnable(self.kWidgetID_MatboardPosition, vs.PWithMatboard) vs.vsoWidgetSetEnable(self.kWidgetID_MatboardClass, vs.PWithMatboard) vs.vsoWidgetSetEnable(self.kWidgetID_MatboardTextureScale, vs.PWithMatboard) vs.vsoWidgetSetEnable(self.kWidgetID_MatboardTextureRotation, vs.PWithMatboard) vs.vsoWidgetSetEnable(self.kWidgetID_FrameWidth, vs.PWithFrame) vs.vsoWidgetSetEnable(self.kWidgetID_FrameHeight, vs.PWithFrame) vs.vsoWidgetSetEnable(self.kWidgetID_FrameThickness, vs.PWithFrame) vs.vsoWidgetSetEnable(self.kWidgetID_FrameDepth, vs.PWithFrame) vs.vsoWidgetSetEnable(self.kWidgetID_FrameClass, vs.PWithFrame) vs.vsoWidgetSetEnable(self.kWidgetID_FrameTextureScale, vs.PWithFrame) vs.vsoWidgetSetEnable(self.kWidgetID_FrameTextureRotation, vs.PWithFrame) vs.vsoWidgetSetEnable(self.kWidgetID_GlassPosition, vs.PWithGlass) vs.vsoWidgetSetEnable(self.kWidgetID_GlassClass, vs.PWithGlass) # this is very important! this is how the system knows we've handled this vs.vsoSetEventResult(kObjectEventHandled)
class Texture: __fColor = None __fTransparency = None __fDefaultName = None __fRefNum = None __fTextureHand = vs.Handle() def __init__( self, defaultName = None, refNum = None, color = None, transparency = None ): self.__fColor = color self.__fTransparency = transparency / 100 self.__fDefaultName = defaultName self.__fRefNum = refNum 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 __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 __SetOpacity( self, recHand ): vs.SetRField( self.__fTextureHand, 'NNAMaxon Plain Transparency', vs.GetFldName( recHand, 4 ), vs.Num2Str( 4, self.__fTransparency ) ) def GetTexture( self ): if self.__fRefNum <= 0: textureName = self.__CreateTexture() else: textureName = vs.Index2Name( self.__fRefNum ) self.__fTextureHand = vs.GetObject( textureName ) self.__SetColor() self.__SetOpacity( vs.GetRecord( self.__fTextureHand, 1 ) ) return self.__fRefNum, textureName
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 main(): # Define globals global gObjName, gObjHandle, gRecordHandle, gWallHandle ok, gObjName, gObjHandle, gRecordHandle, gWallHandle = vs.GetCustomObjectInfo( ) if gObjHandle == vs.Handle(): gObjName = 'Window with Curtains' gObjHandle = vs.GetObject(gObjName) # get the format # Get event theEvent, theEventData = vs.vsoGetEventInfo() if theEvent == Constants.kObjOnInitXProperties: ok = vs.SetObjPropVS(Constants.kObjXPropPreference, True) ok = vs.SetObjPropVS(Constants.kObjXPropHasUIOverride, True) ok = vs.SetObjPropVS(Constants.kObjXHasCustomWidgetVisibilities, True) InitProps() elif theEvent == Constants.kObjOnWidgetPrep: UpdateParams() # to do: set visibilities # ... # this is very important! this is how the system knows we've handled this vs.vsoSetEventResult(Constants.kObjectEventHandled) elif theEvent == Constants.kParametricPreference: #Call the preferences window as the object is created or prefs button is clicked CurtWindowDlg.Dialog(gObjHandle) elif theEvent == Constants.kObjOnObjectUIButtonHit: OnButton(theEventData) elif theEvent == Constants.kParametricRecalculate: #Check the values, which the user enters in the OIP CheckValues() Reset()