def execute(self): shape = context.getState().shape # only 2D shapes can be translated at the moment! if not isinstance(shape, Shape2d): return # rotation matrix, note True as the third parameter to rotation_zNormal_xHorizontal(..) matrix = rotation_zNormal_xHorizontal(shape.firstLoop, shape.getNormal(), True) bmesh.ops.translate(context.bm, verts=shape.face.verts, vec=matrix * mathutils.Vector(self.vec))
def execute(self): bm = context.bm state = context.getState() shape = state.shape # get rectangle origin origin = shape.center() xVec = self.xSize/2 * xAxis yVec = self.ySize/2 * yAxis if self.replace: context.popState() shape.delete() # rotation matrix matrix = rotation_zNormal_xHorizontal(shape.firstLoop, shape.getNormal()) shape = createRectangle(( bm.verts.new( (-xVec - yVec)*matrix + origin), bm.verts.new( ( xVec - yVec)*matrix + origin), bm.verts.new( ( xVec + yVec)*matrix + origin), bm.verts.new( (-xVec + yVec)*matrix + origin) )) if self.operator: context.pushState(shape=shape) self.operator.execute() context.popState() elif self.replace: context.pushState(shape=shape)
def execute(self): state = context.getState() shape = state.shape.extrude(self) if self.parts: decompose_execute(shape, self.parts) else: state.shape = shape
def execute(self): materialManager = context.materialManager material = materialManager.getMaterial(self.material) if material: materialIndex = materialManager.getMaterialIndex(self.material) # assign material to the bmesh face shape = context.getState().shape shape.clearUVlayers() shape.face.material_index = materialIndex
def execute(self): shape = context.getState().shape # We now know the absolute shape size, so let's update self.parts # for self.symmetric = True and self.relativeCoord1 = False if self.symmetric and not self.relativeCoord1: self.updateSymmetricAbsolute(shape) shapesWithRule = shape.extrude2(self.parts, self) # apply the rule for each shape in shapesWithRule list for entry in shapesWithRule: context.pushState(shape=entry[0]) entry[1].execute() context.popState()
def execute(self): shape = context.getState().shape # only 2D shapes can be copied at the moment! if not isinstance(shape, Shape2d): return duplicate = bmesh.ops.duplicate(context.bm, geom = (shape.face,)) copiedFace = [entry for entry in duplicate["geom"] if isinstance(entry, bmesh.types.BMFace)][0] constructor = type(shape) copiedShape = constructor(copiedFace.loops[0]) if self.operator: context.pushState(shape=copiedShape) self.operator.execute() context.popState()
def execute(self): materialManager = context.materialManager colorHex = self.colorHex material = materialManager.getMaterial(colorHex) if material: materialIndex = materialManager.getMaterialIndex(colorHex) else: material = bpy.data.materials.new(colorHex) material.diffuse_color = self.color + (0xff, ) materialManager.setMaterial(colorHex, material) materialIndex = materialManager.getMaterialIndex(colorHex) # assign material to the bmesh face shape = context.getState().shape shape.clearUVlayers() shape.face.material_index = materialIndex
def execute(self): materialManager = context.materialManager colorHex = self.colorHex material = materialManager.getMaterial(colorHex) if material: materialIndex = materialManager.getMaterialIndex(colorHex) else: material = bpy.data.materials.new(colorHex) material.diffuse_color = self.color + (0xff,) materialManager.setMaterial(colorHex, material) materialIndex = materialManager.getMaterialIndex(colorHex) # assign material to the bmesh face shape = context.getState().shape shape.clearUVlayers() shape.face.material_index = materialIndex
def execute(self): shape = context.getState().shape parts = self.parts if self.reverse == False else reversed(self.parts) # Calculate cuts. # cuts is a list of tuples (cutShape, ruleForTheCutShape) cuts = shape.split(self.direction, parts) if len(cuts) == 1: # degenerate case, i.e. no cut is needed cuts[0][2].execute() else: # apply the rule for each cut for cut in cuts: context.pushState(shape=cut[1]) cut[2].execute() context.popState()
def execute(self): shape = context.getState().shape parts = self.parts if self.reverse==False else reversed(self.parts) # Calculate cuts. # cuts is a list of tuples (cutShape, ruleForTheCutShape) cuts = shape.split(self.direction, parts) if len(cuts)==1: # degenerate case, i.e. no cut is needed cuts[0][2].execute() else: # apply the rule for each cut for cut in cuts: context.pushState(shape=cut[1]) cut[2].execute() context.popState()
def execute(self): shape = context.getState().shape bm = context.bm if self.path=="" and self.width==0 and self.height==0: pass else: shape.setUV(self.layer, self) # now deal with the related material materialManager = context.materialManager path = self.path name = os.path.basename(path) material = materialManager.getMaterial(name) if not material: material = materialManager.createMaterial(name, (self,)) if material: materialIndex = materialManager.getMaterialIndex(name) shape.face.material_index = materialIndex # set preview texture materialManager.setPreviewTexture(shape, materialIndex)
def execute(self): shape = context.getState().shape bm = context.bm if self.path == "" and self.width == 0 and self.height == 0: pass else: shape.setUV(self.layer, self) # now deal with the related material materialManager = context.materialManager path = self.path name = os.path.basename(path) material = materialManager.getMaterial(name) if not material: material = materialManager.createMaterial(name, (self, )) if material: materialIndex = materialManager.getMaterialIndex(name) shape.face.material_index = materialIndex # set preview texture materialManager.setPreviewTexture(shape, materialIndex)
def execute(self): shape = context.getState().shape face = shape.face self.init(len(face.verts)) manager = Manager() roof = Roof(face.verts, shape.getNormal(), manager) # soffits if self.soffits: manager.rule = self.soffit roof.inset(*self.soffits, negate=True) # fascias if self.fasciaSize: manager.rule = self.fascia roof.translate(self.fasciaSize) # hip roof itself manager.rule = self.face roof.roof(*self.pitches) shape.delete() # finalizing: if there is a rule for the shape, execute it for entry in manager.shapes: context.pushState(shape=entry[0]) entry[1].execute() context.popState()
def execute(self): shape = context.getState().shape face = shape.face manager = Manager() polygon = Polygon(face.verts, shape.getNormal(), manager) manager.rule = self.side kwargs = {"height": self.height} if self.height else {} polygon.inset(*self.insets, **kwargs) # create a shape for the cap if necessary cap = self.cap if not isinstance(cap, Delete): shape = polygon.getShape(type(shape)) if cap: context.pushState(shape=shape) self.cap.execute() context.popState() if not self.keepOriginal: context.facesForRemoval.append(face) # finalizing: if there is a rule for the shape, execute it for entry in manager.shapes: context.pushState(shape=entry[0]) entry[1].execute() context.popState()
def execute(self): shape = context.getState().shape face = shape.face manager = Manager() polygon = Polygon(face.verts, shape.getNormal(), manager) # process each inset for inset in self.insets: if isinstance(inset, tuple): height = inset[1] if isinstance(height, Operator): rule = height height = height.value else: rule = self.side manager.rule = rule if float(inset[0]): # not zero kwargs = {"height": height} if height else {} polygon.inset(inset[0], **kwargs) else: polygon.translate(height) # create a shape for the cap if necessary cap = self.cap if not isinstance(cap, Delete): shape = polygon.getShape(type(shape)) if cap: context.pushState(shape=shape) self.cap.execute() context.popState() if not self.keepOriginal: context.facesForRemoval.append(face) # finalizing: if there is a rule for the shape, execute it for entry in manager.shapes: context.pushState(shape=entry[0]) entry[1].execute() context.popState()
def execute(self): shape = context.getState().shape context.addDeferred(shape, self)
def execute(self): shape = context.getState().shape shape.delete()
def execute(self): decompose_execute(context.getState().shape, self.parts)