def getPoint(self, point=None, obj=None): "this function is called by the snapper when it has a 3D point" if obj: if Draft.getType(obj) == "Wall": if not obj in self.existing: self.existing.append(obj) if point == None: self.tracker.finalize() return self.points.append(point) if len(self.points) == 1: self.tracker.on() FreeCADGui.Snapper.getPoint(last=self.points[0], callback=self.getPoint, movecallback=self.update, extradlg=self.taskbox()) elif len(self.points) == 2: import Part add = False l = Part.Line(self.points[0], self.points[1]) self.tracker.finalize() FreeCAD.ActiveDocument.openTransaction( str(translate("Arch", "Create Wall"))) FreeCADGui.doCommand('import Arch') FreeCADGui.doCommand('import Part') FreeCADGui.doCommand('trace=Part.Line(FreeCAD.' + str(l.StartPoint) + ',FreeCAD.' + str(l.EndPoint) + ')') if not self.existing: self.addDefault(l) else: w = joinWalls(self.existing) if w: if areSameWallTypes([w, self]): FreeCADGui.doCommand('FreeCAD.ActiveDocument.' + w.Name + '.Base.addGeometry(trace)') else: self.addDefault(l) add = True else: self.addDefault(l) if add: FreeCADGui.doCommand( 'Arch.addComponents(FreeCAD.ActiveDocument.' + FreeCAD.ActiveDocument.Objects[-1].Name + ',FreeCAD.ActiveDocument.' + w.Name + ')') FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() if self.continueCmd: self.Activated()
def make_side_panels(width, height, thickness, spacing): half_width = width / 2.0 down_height = -height / 2.0 up_height = height / 2.0 x = spacing / 2.0 p1 = FreeCAD.Vector(x, -half_width, down_height) p2 = FreeCAD.Vector(x, -half_width, up_height) p3 = FreeCAD.Vector(x, half_width, up_height) p4 = FreeCAD.Vector(x, half_width, down_height) l1 = Part.Line(p1, p2) l2 = Part.Line(p2, p3) l3 = Part.Line(p3, p4) l4 = Part.Line(p4, p1) shape = Part.Shape([l1, l2, l3, l4]) wire = Part.Wire(shape.Edges) face = Part.Face(wire) left_part = face.extrude(FreeCAD.Vector(thickness, 0, 0)) right_part = left_part.copy() right_part.translate(FreeCAD.Vector(-spacing - thickness, 0, 0)) return left_part, right_part
def make_front_panels(length, height, thickness, spacing): half_length = length / 2.0 down_height = -height / 2.0 up_height = height / 2.0 y = spacing / 2.0 p1 = FreeCAD.Vector(-half_length, y, down_height) p2 = FreeCAD.Vector(-half_length, y, up_height) p3 = FreeCAD.Vector(half_length, y, up_height) p4 = FreeCAD.Vector(half_length, y, down_height) l1 = Part.Line(p1, p2) l2 = Part.Line(p2, p3) l3 = Part.Line(p3, p4) l4 = Part.Line(p4, p1) shape = Part.Shape([l1, l2, l3, l4]) wire = Part.Wire(shape.Edges) face = Part.Face(wire) front_part = face.extrude(FreeCAD.Vector(0, thickness, 0)) behind_part = front_part.copy() behind_part.translate(FreeCAD.Vector(0, -spacing - thickness, 0)) return front_part, behind_part
def build_air_ext(minum, x_low, x_high, y_low, y_high): #App.newDocument("Unnamed") App.activeDocument().addObject('Sketcher::SketchObject','Sketch003') App.activeDocument().Sketch003.Placement = App.Placement(App.Vector(0.000000,0.000000, minum),App.Rotation(0.000000,0.000000,0.000000,1.000000)) App.getDocument('Unnamed').recompute() App.ActiveDocument.Sketch003.addGeometry(Part.Line(App.Vector(x_low,y_low,0),App.Vector(x_high,y_low,0))) # these 4 create the rectangle App.ActiveDocument.Sketch003.addGeometry(Part.Line(App.Vector(x_high,y_low,0),App.Vector(x_high,y_high,0))) # x, y App.ActiveDocument.Sketch003.addGeometry(Part.Line(App.Vector(x_high,y_high,0),App.Vector(x_low,y_high,0))) App.ActiveDocument.Sketch003.addGeometry(Part.Line(App.Vector(x_low,y_high,0),App.Vector(x_low,y_low,0))) App.ActiveDocument.Sketch003.addConstraint(Sketcher.Constraint('Coincident',0,2,1,1)) App.ActiveDocument.Sketch003.addConstraint(Sketcher.Constraint('Coincident',1,2,2,1)) App.ActiveDocument.Sketch003.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1)) App.ActiveDocument.Sketch003.addConstraint(Sketcher.Constraint('Coincident',3,2,0,1)) App.ActiveDocument.Sketch003.addConstraint(Sketcher.Constraint('Horizontal',0)) App.ActiveDocument.Sketch003.addConstraint(Sketcher.Constraint('Horizontal',2)) App.ActiveDocument.Sketch003.addConstraint(Sketcher.Constraint('Vertical',1)) App.ActiveDocument.Sketch003.addConstraint(Sketcher.Constraint('Vertical',3)) App.ActiveDocument.recompute() #App.ActiveDocument.Sketch.addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1)) #App.ActiveDocument.recompute() App.getDocument('Unnamed').recompute() App.activeDocument().addObject("PartDesign::Pad","Pad003") App.activeDocument().Pad003.Sketch = App.activeDocument().Sketch003 App.activeDocument().Pad003.Length = 10.0 App.ActiveDocument.recompute() App.ActiveDocument.Pad003.Length = 1.2696 # 120 plus 10 due to offset above larger for air (120) -- can be modified if necessary App.ActiveDocument.Pad003.Reversed = 0 # changed for air App.ActiveDocument.Pad003.Midplane = 0 App.ActiveDocument.Pad003.Length2 = 100.000000 App.ActiveDocument.Pad003.Type = 0 App.ActiveDocument.Pad003.UpToFace = None App.ActiveDocument.recompute()
def make_twice_half_front_panel(length, height, thickness, spacing): quarter_length = length / 4.0 down_height = -height / 2.0 up_height = height / 2.0 y = spacing / 2.0 p1 = FreeCAD.Vector(-quarter_length, y, down_height) p2 = FreeCAD.Vector(-quarter_length, y, up_height) p3 = FreeCAD.Vector(quarter_length, y, up_height) p4 = FreeCAD.Vector(quarter_length, y, down_height) l1 = Part.Line(p1, p2) l2 = Part.Line(p2, p3) l3 = Part.Line(p3, p4) l4 = Part.Line(p4, p1) shape = Part.Shape([l1, l2, l3, l4]) wire = Part.Wire(shape.Edges) face = Part.Face(wire) front_part_1 = face.extrude(FreeCAD.Vector(0, thickness, 0)) front_part_2 = front_part_1.copy() front_part_1.translate(FreeCAD.Vector(-quarter_length, 0, 0)) front_part_2.translate(FreeCAD.Vector(quarter_length, 0, 0)) return front_part_1, front_part_2
def addPolyLineSketch(name, fcDoc, segmentOrder, lineSegments): ''' Add a sketch given segment order and line segments ''' if (fcDoc.getObject(name) != None): # this name already exists raise ValueError("Error: sketch " + name + " already exists.") obj = fcDoc.addObject('Sketcher::SketchObject', name) for segIndex, segment in enumerate(lineSegments): startPoint = segment[0, :] endPoint = segment[1, :] obj.addGeometry(Part.Line(FreeCAD.Vector(tuple(startPoint)), FreeCAD.Vector(tuple(endPoint)))) for i in range(len(lineSegments)): connectIndex = segmentOrder[i] if connectIndex < len(lineSegments): obj.addConstraint(Sketcher.Constraint('Coincident', i, 2, connectIndex, 1)) fcDoc.recompute() return obj
def getWire(self,obj): import Part if obj.Base: if not obj.Base.isDerivedFrom("Part::Feature"): FreeCAD.Console.PrintError(translate("Arch","The base object is not a Part\n")) return if len(obj.Base.Shape.Wires) != 1: FreeCAD.Console.PrintError(translate("Arch","Too many wires in the base shape\n")) return if obj.Base.Shape.Wires[0].isClosed(): FreeCAD.Console.PrintError(translate("Arch","The base wire is closed\n")) return w = obj.Base.Shape.Wires[0] else: if obj.Length.Value == 0: return w = Part.Wire([Part.Line(FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,obj.Length.Value)).toShape()]) return w