コード例 #1
0
 def __MoveLedge(self, hLedge):
     if self.__fType == LedgeType.AttachToWall:
         # to Wall
         vs.Move3DObj(
             hLedge, -(self.__fWindowWidth * kLedgeOutWindow) / 2.0,
             -self.__fLedgeWidth / 2.0 - self.__fFrameWidthOffset / 2.0,
             self.__fLedgeHeight +
             (self.__fWindowHeight * kLedgeOffsetFromWindow))
     else:
         isSuccessful, objName, objHand, recHand, wallHand = vs.GetCustomObjectInfo(
         )
         if isSuccessful and (vs.GetTypeN(wallHand) == 68
                              or vs.GetTypeN(wallHand) == 89
                              ):  # not sure if correct (need wall to test)
             # to Window
             startTopHeight, startBotHeight, endTopHeight, endBotHeight = vs.GetWallHeight(
                 wallHand)
             vs.Move3DObj(
                 hLedge, -(self.__fWindowWidth * kLedgeOutWindow) / 2.0,
                 -(kLedgeOffsetFromWall * self.__fLedgeWidth) /
                 -self.__fLedgeWidth / 2.0 - self.__fFrameWidthOffset / 2.0,
                 vs.Abs(endTopHeight - endBotHeight))
         else:
             self.__fType = LedgeType.AttachToWall
             vs.Move3DObj(
                 hLedge, -(self.__fWindowWidth * kLedgeOutWindow) / 2.0,
                 -self.__fLedgeWidth / 2.0 - self.__fFrameWidthOffset / 2.0,
                 self.__fLedgeHeight +
                 (self.__fWindowHeight * kLedgeOffsetFromWindow))
     return hLedge
コード例 #2
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)
コード例 #3
0
ファイル: leaf.py プロジェクト: jacob-ditkoff/SDKExamples
	def Draw(self):


		if self.leafType == kTypeNone:

			vs.BeginGroup()

			glassWidth 		= self.width  
			glassHeight 	= self.height
			glassThikness	= self.__glassThikness
			glassOrigin		= (0, 0)
			pathDirection	= (0, -1)

			vs.DSelectAll()
			vs.BeginXtrd( 0, glassThikness)
			vs.RectangleN( glassOrigin, pathDirection, glassWidth, glassHeight )
			hGlass = vs.LNewObj()
			vs.EndXtrd()

			vs.Set3DRot(hGlass, 0, 40, 0, 0, 0, 0)

			vs.EndGroup()
			hLeaf = vs.LNewObj()
			
			#position at origin with needed orientation
			vs.Set3DRot(hLeaf, 0, -90,   0, 0, 0, 0)
			vs.Move3DObj(hLeaf, self.__frameThickness/2, 0, 0)
			vs.Set3DRot(hLeaf, 0,   0, 90, 0, 0, 0)



		if self.leafType != kTypeNone:
				
			vs.BeginGroup()
			#Prepare Extrude Path
			pathWidth = self.width + self.__frameOverlap*2
			pathHeight = self.height + self.__frameOverlap*2
			pathOrigin = ( -self.__frameOverlap, self.__frameOverlap )
			pathDirection = (0, -1)

			vs.RectangleN( pathOrigin, pathDirection, pathWidth, pathHeight)
			hFramePath = vs.LNewObj()

			vs.SetPlanarRefIDToGround(hFramePath);
			hFramePath = vs.ConvertToNURBS(hFramePath, False)

			#Prepare Extrude Profile


			frameProfile = (
							self.__frameOverlap, 0,
							self.__frameWidth, 0, 										
							self.__frameWidth, self.__frameThickness,
							0, self.__frameThickness,
							0, self.__frameInsideThinckness,
							self.__frameOverlap, self.__frameInsideThinckness
							)



			vs.ClosePoly()
			vs.Poly(*frameProfile)
			hFrameProfile = vs.LNewObj()

			hFrameProfilePolyline = vs.MakePolyline(hFrameProfile)
			vs.DelObject(hFrameProfile)
			hFrameProfile = hFrameProfilePolyline

			
			hLeafFrame = vs.ExtrudeAlongPath(hFramePath, hFrameProfile)

			vs.DelObject(hFramePath)
			vs.DelObject(hFrameProfile)

			#insert glass
			glassWidth 		= self.width  - 2*self.__frameMainWidth
			glassHeight 	= self.height - 2*self.__frameMainWidth
			glassThikness	= self.__glassThikness
			glassOrigin		= (self.__frameMainWidth, -self.__frameMainWidth)

			vs.DSelectAll()
			vs.BeginXtrd(self.__frameThickness/2, self.__frameThickness/2 + glassThikness)
			vs.RectangleN( glassOrigin, pathDirection, glassWidth, glassHeight )
			hGlass = vs.LNewObj()
			vs.EndXtrd()

			vs.EndGroup()
			hLeaf = vs.LNewObj()


			#position at origin with needed orientation
			vs.Set3DRot(hLeaf, 0, -90,   0, 0, 0, 0)
			vs.Set3DRot(hLeaf, 0,   0, 180, 0, 0, 0)
			vs.Move3DObj(hLeaf, 0, -self.width, 0)
			vs.Set3DRot(hLeaf, 0,   0, 90, 0, 0, 0)
			



		#move to required position
		vs.Move3DObj(hLeaf, self.position[0], self.position[1], self.position[2], )


		if self.isGlassTrue == True:
			vs.SetFillBack(hGlass, 11)
			vs.SetOpacity(hGlass, 50)

		else:
			vs.SetFillBack(hGlass, 8)
			vs.SetOpacity(hGlass, 100)



		self.hLeaf = hLeaf
コード例 #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)