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))
Beispiel #2
0
 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 __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 )
Beispiel #4
0
def reset_event_handler(rename_handle):
    # Create the Image
    if vs.PWithImage:
        image_texture = vs.GetTextureRefN(rename_handle, 0, 0, True)
        if image_texture:
            image_prop = vs.CreateImageProp(vs.PPictureName, image_texture, vs.PImageHeight, vs.PImageWidth, False, False, False, False, False)
            if image_prop != 0:
                vs.Move3DObj(image_prop, 0, (vs.PFrameDepth / 2) - vs.PImagePosition, 0)
                existing_texture = vs.GetObject("{} Picture Texture".format(vs.GetName(rename_handle)))
                if existing_texture:
                    set_name(existing_texture, "{} Previous Picture Texture".format(vs.GetName(rename_handle)))
                vs.SetName(
                    vs.GetObject(vs.Index2Name(image_texture)),
                    "{} Picture Texture".format(vs.GetName(rename_handle)))
            else:
                vs.SetRField(rename_handle, "Picture", "WithImage", "False")
                vs.DelObject(vs.GetObject(vs.Index2Name(image_texture)))
                vs.AlertCritical("Error creating Picture object", "Close/Open VectorWorks and retry the operation")

    # Create the Frame
    if vs.PWithFrame:
        vs.BeginPoly3D()
        vs.Add3DPt((-vs.PFrameWidth / 2, -(vs.PFrameDepth / 2), -(vs.PFrameHeight - vs.PImageHeight) / 2))
        vs.Add3DPt((vs.PFrameWidth / 2,  -(vs.PFrameDepth / 2), -(vs.PFrameHeight - vs.PImageHeight) / 2))
        vs.Add3DPt((vs.PFrameWidth / 2,  -(vs.PFrameDepth / 2), vs.PFrameHeight - ((vs.PFrameHeight - vs.PImageHeight) / 2)))
        vs.Add3DPt((-vs.PFrameWidth / 2, -(vs.PFrameDepth / 2), vs.PFrameHeight - ((vs.PFrameHeight - vs.PImageHeight) / 2)))
        vs.Add3DPt((-vs.PFrameWidth / 2, -(vs.PFrameDepth / 2), -(vs.PFrameHeight - vs.PImageHeight) / 2))
        vs.EndPoly3D()
        extrude_path = vs.LNewObj()
        extrude_path = vs.ConvertToNURBS(extrude_path, False)

        vs.Rect((-1 * vs.PFrameThickness, -1 * vs.PFrameDepth), (0, 0))
        extrude_profile = vs.LNewObj()

        frame = vs.ExtrudeAlongPath(extrude_path, extrude_profile)
        vs.DelObject(extrude_path)
        vs.DelObject(extrude_profile)

        vs.SetClass(frame, vs.PFrameClass)
        vs.SetFPatByClass(frame)
        vs.SetFillColorByClass(frame)
        vs.SetLSByClass(frame)
        vs.SetLWByClass(frame)
        vs.SetMarkerByClass(frame)
        vs.SetOpacityByClass(frame)
        vs.SetPenColorByClass(frame)
        vs.SetTextStyleByClass(frame)
        vs.SetTextureRefN(frame, -1, 0, 0)
        vs.SetTexMapRealN(frame, 3, 0, 3, vs.PFrameTextureScale)
        vs.SetTexMapRealN(frame, 3, 0, 4, vs.Deg2Rad(vs.PFrameTextureRotation))

    # Create the Matboard
    if vs.PWithMatboard:
        # vs.BeginPoly3D()
        # vs.Add3DPt((-vs.PFrameWidth / 2, (vs.PFrameDepth / 2) - vs.PMatboardPosition, -(vs.PFrameHeight - vs.PImageHeight) / 2))
        # vs.Add3DPt((vs.PFrameWidth / 2,  (vs.PFrameDepth / 2) - vs.PMatboardPosition, -(vs.PFrameHeight - vs.PImageHeight) / 2))
        # vs.Add3DPt((vs.PFrameWidth / 2,  (vs.PFrameDepth / 2) - vs.PMatboardPosition, vs.PFrameHeight - ((vs.PFrameHeight - vs.PImageHeight) / 2)))
        # vs.Add3DPt((-vs.PFrameWidth / 2, (vs.PFrameDepth / 2) - vs.PMatboardPosition, vs.PFrameHeight - ((vs.PFrameHeight - vs.PImageHeight) / 2)))
        # vs.Add3DPt((-vs.PFrameWidth / 2, (vs.PFrameDepth / 2) - vs.PMatboardPosition, -(vs.PFrameHeight - vs.PImageHeight) / 2))
        # vs.EndPoly3D()
        # matboard = vs.LNewObj()

        vs.BeginMXtrd(0, 0.01)
        vs.Rect((-vs.PFrameWidth / 2, vs.PFrameHeight / 2), (vs.PFrameWidth / 2, -vs.PFrameHeight / 2))
        vs.Rect((-vs.PFrameWidth / 2, vs.PFrameHeight / 2), (vs.PFrameWidth / 2, -vs.PFrameHeight / 2))
        vs.EndMXtrd()
        matboard = vs.LNewObj()

        vs.BeginMXtrd(0, 0.01)
        vs.Rect((-vs.PWindowWidth / 2, vs.PWindowHeight / 2), (vs.PWindowWidth / 2, -vs.PWindowHeight / 2))
        vs.Rect((-vs.PWindowWidth / 2, vs.PWindowHeight / 2), (vs.PWindowWidth / 2, -vs.PWindowHeight / 2))
        vs.EndMXtrd()
        window = vs.LNewObj()

        result, new_object = vs.SubtractSolid(matboard, window)

        vs.Set3DRot(new_object, 90, 0, 0, 0, 0, 0)
        vs.Move3DObj(new_object, 0, (vs.PFrameDepth / 2) - vs.PMatboardPosition + 0.01, vs.PImageHeight / 2)

        vs.SetClass(new_object, vs.PMatboardClass)
        vs.SetFPatByClass(new_object)
        vs.SetFillColorByClass(new_object)
        vs.SetLSByClass(new_object)
        vs.SetLWByClass(new_object)
        vs.SetMarkerByClass(new_object)
        vs.SetOpacityByClass(new_object)
        vs.SetPenColorByClass(new_object)
        vs.SetTextStyleByClass(new_object)
        vs.SetTextureRefN(new_object, -1, 0, 0)
        vs.SetTexMapRealN(new_object, 3, 0, 3, vs.PMatboardTextureScale)
        vs.SetTexMapRealN(new_object, 3, 0, 4, vs.Deg2Rad(vs.PMatboardTextureRotat))

    # Create the Glass
    if vs.PWithGlass:
        vs.BeginPoly3D()
        vs.Add3DPt((-vs.PFrameWidth / 2, (vs.PFrameDepth / 2) - vs.PGlassPosition, -(vs.PFrameHeight - vs.PImageHeight) / 2))
        vs.Add3DPt((vs.PFrameWidth / 2,  (vs.PFrameDepth / 2) - vs.PGlassPosition, -(vs.PFrameHeight - vs.PImageHeight) / 2))
        vs.Add3DPt((vs.PFrameWidth / 2,  (vs.PFrameDepth / 2) - vs.PGlassPosition, vs.PFrameHeight - ((vs.PFrameHeight - vs.PImageHeight) / 2)))
        vs.Add3DPt((-vs.PFrameWidth / 2, (vs.PFrameDepth / 2) - vs.PGlassPosition,  vs.PFrameHeight - ((vs.PFrameHeight - vs.PImageHeight) / 2)))
        vs.Add3DPt((-vs.PFrameWidth / 2, (vs.PFrameDepth / 2) - vs.PGlassPosition, -(vs.PFrameHeight - vs.PImageHeight) / 2))
        vs.EndPoly3D()
        glass = vs.LNewObj()

        vs.SetClass(glass, vs.PGlassClass)
        vs.SetFPatByClass(glass)
        vs.SetFillColorByClass(glass)
        vs.SetLSByClass(glass)
        vs.SetLWByClass(glass)
        vs.SetMarkerByClass(glass)
        vs.SetOpacityByClass(glass)
        vs.SetPenColorByClass(glass)
        vs.SetTextStyleByClass(glass)
        vs.SetTextureRefN(glass, -1, 0, 0)
def OnOK():
    ##Must check!!!
    global windowWidth
    fraction, display, format, upi, name, squareName = vs.GetUnits()
    #######################################################    
    ok,val = vs.GetEditInteger(Constants.dialogId,kIDLabel)
    vs.SetRField(Constants.h, kPluginName, 'IDLabel', val.__str__())
    #######################################################
    ok,val= vs.GetEditReal(Constants.dialogId, kWidth, kEditRealDim)
    windowWidth = val
    vs.SetRField(Constants.h,kPluginName, 'Width', val.__str__())
    #######################################################    
    ok,val = vs.GetEditReal(Constants.dialogId,kHeight,kEditRealDim)
    vs.SetRField(Constants.h,kPluginName, 'Height', val.__str__())
    #######################################################    
    ok,val = vs.GetEditReal(Constants.dialogId,kElevationInWall,kEditRealDim)
    vs.SetRField(Constants.h,kPluginName, 'ElvInWall', val.__str__())
    #######################################################    
    val = vs.GetBooleanItem(Constants.dialogId, kOpenTheWindow)
    vs.SetRField(Constants.h,kPluginName, 'OpenTheWindow', val.__str__())
    #######################################################   
    ok,val = vs.GetEditReal(Constants.dialogId,kOpeningAngle,kEditRealAng)
    vs.SetRField(Constants.h,kPluginName, 'OpeningAngle', val.__str__())
    #######################################################    
    index = vs.GetSelectedChoiceIndex(Constants.dialogId, kLeaf, 0)
    if(index == 0):
        vs.SetRField(Constants.h,kPluginName,'Leaf','None')
    elif(index == 1):
        vs.SetRField(Constants.h,kPluginName,'Leaf','1(no glass)')
    elif(index == 2):
        vs.SetRField(Constants.h,kPluginName,'Leaf','1(glass)')
    elif(index == 3):
        vs.SetRField(Constants.h,kPluginName,'Leaf','2(no glass)')
    else:
        vs.SetRField(Constants.h,kPluginName,'Leaf','2(glass)')
    #######################################################    
    val = vs.GetBooleanItem(Constants.dialogId,kHasCurtains)
    vs.SetRField(Constants.h,kPluginName,'HasCurts',val.__str__())
    #######################################################    
    index = vs.GetSelectedChoiceIndex(Constants.dialogId,kLedgeType,0)
    if(index == 0):
        vs.SetRField(Constants.h,kPluginName,'LedgeType','Attach to wall')
    else:
        vs.SetRField(Constants.h,kPluginName,'LedgeType','Attach to ceiling')
    #######################################################        
    index = vs.GetSelectedChoiceIndex(Constants.dialogId,kLedgeMaterial,0)
    if(index == 0):
        vs.SetRField(Constants.h,kPluginName,'LedgeMaterial','Wood')
    elif(index == 1):
        vs.SetRField(Constants.h,kPluginName,'LedgeMaterial','Plastic')
    else:
        vs.SetRField(Constants.h,kPluginName,'LedgeMaterial','Metal')
    #######################################################    
    val = vs.GetBooleanItem(Constants.dialogId,kDrawTheCurts)
    vs.SetRField(Constants.h,kPluginName,'DrawTheCurts',val.__str__())
    #######################################################
    colorIndex = vs.GetColorChoice(Constants.dialogId, kCurtsColor)
    colorText = str(colorIndex)
    vs.SetRField(Constants.h,kPluginName,'__CustomColor',colorIndex)
    vs.SetRField(Constants.h,kPluginName,'__PrevCustomColor',colorIndex)
    
    #######################################################
    if colorIndex == 256:
        vs.SetRField(Constants.h,kPluginName,'CurtsColor','White')
    elif colorIndex == 257:
        vs.SetRField(Constants.h,kPluginName,'CurtsColor','Black')
    else:
        vs.SetRField(Constants.h,kPluginName,'CurtsColor','Custom Color')
    ##########################
    
    ok,val = vs.GetEditInteger(Constants.dialogId,kPieces)
    ########### Check for correct set value of the pieces: min 4" 
    #inches per unit = 1/upi
    #max width of one piece of curtain = 4 inhes
    inchesPerUnit = 1/upi
    windowWidth = windowWidth*inchesPerUnit
    maxPieces = windowWidth // kMaxWidthOfPiece 
    
    if val > maxPieces:
        val = maxPieces
    vs.SetRField(Constants.h,kPluginName,'Pieces',val.__str__())
    #######################################################    
    val = vs.GetControlData(Constants.dialogId,kOpacitySlider)
    vs.SetRField(Constants.h,kPluginName,'Opacity',val.__str__())
Beispiel #6
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)
 def __SetOpacity(self, recHand):
     vs.SetRField(self.__fTextureHand, 'NNAMaxon Plain Transparency',
                  vs.GetFldName(recHand, 4),
                  vs.Num2Str(4, self.__fTransparency))
Beispiel #8
0
 def value(self, value: str):
     """:type value: str"""
     vs.SetRField(self.__object_handle, self.__record_name, self.name, value)