Beispiel #1
0
def display_geom(ifc_path, base_class="IfcProduct"):
    """Display geom in from file in FreeCAD"""
    ifc_file = ifcopenshell.open(ifc_path)

    # Define settings
    settings = geom.settings()
    settings.set(settings.USE_BREP_DATA, True)

    # Allow you to embed FreeCAD in python https://www.freecadweb.org/wiki/Embedding_FreeCAD
    FreeCADGui.showMainWindow()
    doc = FreeCAD.newDocument()

    parts = [
        convert_geom(ifc_entity, doc, settings)
        for ifc_entity in ifc_file.by_type(base_class)
    ]

    # Set Draw Style to display mesh edges. Orient view and fit to wall
    FreeCADGui.runCommand("Std_DrawStyle", 1)
    for part in parts:
        FreeCADGui.Selection.addSelection(part)
    FreeCADGui.activeView().viewIsometric()
    FreeCADGui.SendMsgToActiveView("ViewSelection")

    FreeCADGui.exec_loop()
Beispiel #2
0
import FreeCAD

from wgtocx1_proj import *

GUIMode = FreeCAD.ConfigGet("RunMode")

if not GUIMode:
    FreeCADGui.showMainWindow()

FreeCADGui.activateWorkbench("QW_ModellerWorkbench")

qwm_doc = QW_Modeller.newQWDocument("wgtocx1")

FreeCADGui.activeDocument().activeView().viewAxometric()

proj = wgtocx1_Project(qwm_doc)
proj.set_Circuit_Parameters()
proj.set_GeometryAndMedia()
proj.set_Mesh()
proj.set_Excitation()
proj.set_Postprocessing()
proj.set_Simulation()
proj.run_Simulation()

FreeCADGui.SendMsgToActiveView("ViewFit")
qwm_doc.recompute()

if not GUIMode:
    FreeCADGui.exec_loop() #for quick tests

        
print s1.Volume  # об'єм (див. також Length, Area, CenterOfMass)
print s1.distToShape(s2)[0]  # мінімальна відстань до іншої форми
print s1.Faces[0]  # перша грань
print s1.Edges[0]  # перше ребро
print type(s1.Edges[0].Curve)  # тип кривої першого ребра
print s1.Vertexes[0].Point.x  # координата x точки першої вершини

#s1.exportBrep("my.brep") # експорт у форматі BREP (див. також exportStep, exportIges)
#s1 = Part.Shape()
#s1.read("my.brep") # імпорт у форматі BREP

# Наступні команди потрібні тільки для візуалізації створених форм
Gui.showMainWindow()  # показати головне вікно
doc = App.newDocument()  # створити новий документ
for shape in [l1.toShape(), a1.toShape(), w1, f1, f2, s1, bs.toShape(), s2]:
    Part.show(shape)  # показати форму
doc.recompute()  # перебудувати
Gui.exec_loop()  # головний цикл програми
"""
    Compound
    389.596349447
    0.0
    <Face object at 0000000003AF38D0>
    <Edge object at 0000000003AF4350>
    <type 'Part.Line'>
    -1.27414669346
![](fig.png)

Рисунок - Результати виконання програми
"""
Beispiel #4
0
"""
Created on 2012-12-29

@author: laine
"""

import FreeCAD, FreeCADGui

FreeCADGui.showMainWindow()
FreeCADGui.exec_loop()
Beispiel #5
0
#!/usr/bin/python2

import FreeCAD
import FreeCADGui as gui

gui.showMainWindow()
gui.activateWorkbench("gliderWorkbench")
l = gui.listWorkbenches().keys()
l.pop(l.index('gliderWorkbench'))
l.pop(l.index('DraftWorkbench'))
map(gui.removeWorkbench, l)

#FreeCAD.newDocument()

gui.exec_loop()
Beispiel #6
0

if __name__ == "__main__":
    mesh_values = read_geom(
        "/home/cyril/git/pythoncvc.net/IfcOpenShellSamples/Wall.ifc"
    )

    # Create a FreeCAD geometry. A FreeCAD can take vertices and faces as input
    mesh = Mesh.Mesh((mesh_values["vertices"], mesh_values["faces"]))
    # Ifc lenght internal unit : meter. FreeCAD internal unit : mm.
    scale_factor = 1000
    matrix = FreeCAD.Matrix()
    matrix.scale(scale_factor, scale_factor, scale_factor)
    mesh.transform(matrix)

    # Allow you to embed FreeCAD in python https://www.freecadweb.org/wiki/Embedding_FreeCAD
    FreeCADGui.showMainWindow()
    doc = FreeCAD.newDocument()

    # Add geometry to FreeCAD scenegraph (Coin)
    fc_mesh = doc.addObject("Mesh::Feature", "IfcMesh")
    fc_mesh.Mesh = mesh

    # Set Draw Style to display mesh edges. Orient view and fit to wall
    FreeCADGui.runCommand("Std_DrawStyle",1) 
    FreeCADGui.Selection.addSelection(fc_mesh)
    FreeCADGui.activeView().viewIsometric()
    FreeCADGui.SendMsgToActiveView("ViewSelection")
    
    FreeCADGui.exec_loop()
Beispiel #7
0
 def start(self):
     self.doc.recompute()
     self.centerView()
     FreeCADGui.exec_loop()
 def start(self):
     self.doc.recompute()
     self.centerView()
     FreeCADGui.exec_loop()