def finish(self):

        Gui.activeView().removeEventCallback("SoEvent", self.call)
        Gui.Snapper.off()
        Gui.Control.closeDialog()

        return None
Example #2
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()
Example #3
0
    def createBody(self, cell_name):

        body = App.ActiveDocument.addObject("PartDesign::Body", cell_name)

        body.addObject(self.Object)

        Gui.activeView().setActiveObject('pdbody', body)

        return body
Example #4
0
def process_test_file(ifc_path, doc):
    ifc_importer = IfcImporter(ifc_path, doc)
    ifc_importer.generate_rel_space_boundaries()
    processing_sia_boundaries(doc)
    bem_xml = write_xml(doc)
    output_xml_to_path(bem_xml)
    ifc_importer.xml = bem_xml
    ifc_importer.log = LOG_STREAM.getvalue()
    if FreeCAD.GuiUp:
        FreeCADGui.activeView().viewIsometric()
        FreeCADGui.SendMsgToActiveView("ViewFit")
    with open("./boundaries.log", "w", encoding="utf-8") as log_file:
        log_file.write(ifc_importer.log)
    return ifc_importer
Example #5
0
 def reject(self):
     if (self.feature != None):
         self.hideFeature() # Show the support again
         document = self.feature.Document
         body = FreeCADGui.activeView().getActiveObject("pdbody");
         groove = self.feature.HoleGroove
         sketch = groove.Sketch
         plane = sketch.Support[0]
         axis = plane.References[0][0]     
         body.removeObject(self.feature)
         document.removeObject(self.feature.Name)                      
         body.removeObject(groove)
         document.removeObject(groove.Name)
         body.removeObject(sketch)
         try:
             document.removeObject(sketch.Name)      
         except:
             pass # This always throws an exception: "Sketch support has been deleted" from SketchObject::execute()
         body.removeObject(plane)
         document.removeObject(plane.Name)
         body.removeObject(axis)
         document.removeObject(axis.Name)            
     FreeCADGui.ActiveDocument.resetEdit()
     FreeCADGui.Control.closeDialog(self)
     return True
Example #6
0
 def reject(self):
     if (self.feature != None):
         self.hideFeature()  # Show the support again
         document = self.feature.Document
         body = FreeCADGui.activeView().getActiveObject("pdbody")
         groove = self.feature.HoleGroove
         sketch = groove.Sketch
         plane = sketch.Support[0]
         axis = plane.References[0][0]
         body.removeObject(self.feature)
         document.removeObject(self.feature.Name)
         body.removeObject(groove)
         document.removeObject(groove.Name)
         body.removeObject(sketch)
         try:
             document.removeObject(sketch.Name)
         except:
             pass  # This always throws an exception: "Sketch support has been deleted" from SketchObject::execute()
         body.removeObject(plane)
         document.removeObject(plane.Name)
         body.removeObject(axis)
         document.removeObject(axis.Name)
     FreeCADGui.ActiveDocument.resetEdit()
     FreeCADGui.Control.closeDialog(self)
     return True
def make(mode, container):
    plm = calculatePlace(Gui.Selection.getSelectionEx(), mode,
                         Gui.activeView())
    plmobj = makeLatticePlacement('Dart')
    plmobj.Placement = plm
    executeFeature(plmobj)
    if container is not None:
        container.Links = container.Links + [plmobj]
    return plmobj
    def __init__(self, vobj):

        base = vobj.Object.Placement.Base
        size = vobj.Object.Size.Value
        string = vobj.Object.String
        font = vobj.Object.FontFile

        super().__init__(base, size, string, font)
        self.pointPicked = True
        self.vobj = vobj
        self.call = Gui.activeView().addEventCallback("SoEvent", self.action)
Example #9
0
 def Activated(self):
     text = FreeCAD.Qt.translate("QObject", "Create tube")
     FreeCAD.ActiveDocument.openTransaction(text)
     tube = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Tube")
     Shapes.TubeFeature(tube)
     vp = ViewProviderShapes.ViewProviderTube(tube.ViewObject)
     activePart = FreeCADGui.activeView().getActiveObject('part')
     if activePart:
         activePart.addObject(tube)
     FreeCAD.ActiveDocument.recompute()
     vp.startDefaultEditMode(tube.ViewObject)
Example #10
0
def select():
    global menu
    global obj
    global picker
    pos = Gui.activeView().getCursorPos()
    obj = getObjectBelow(pos)
    if pos[0] > 0 and pos[1] > 0:
        saveUserSettings()
        prepareGUI()
        picker = Picker()
        picker.pick(pos, obj)
        menu = createMenu()
        menu.exec_(QtGui.QCursor.pos())
Example #11
0
def onResize():
    """Resize dock."""
    mdi = mw.findChild(QtGui.QMdiArea)

    if mode == 1:
        x = 0
        y = 0
        w = mdi.geometry().width() / 100 * 20
        h = (mdi.geometry().height() -
             mdi.findChild(QtGui.QTabBar).geometry().height())
        dock.setGeometry(x, y, w, h)

    if str(Gui.activeView()) == "View3DInventor":
        dock.show()
    else:
        dock.hide()
Example #12
0
    def Activated(self):
        # Get main window
        mw = self.getMainWindow()

        # Get active document
        doc = FreeCAD.activeDocument()
        if doc is None:
            QtGui.QMessageBox.critical(
                mw, "No document",
                "A document must be open in order to create a hole feature")
            return

        # Check for valid position selection
        selection = FreeCADGui.Selection.getSelectionEx()
        if len(selection) != 1:
            QtGui.QMessageBox.critical(
                mw, "No position defined",
                "Please select a face to create the hole feature on")
            return
        if selection[0].DocumentName != doc.Name:
            QtGui.QMessageBox.critical(
                mw, "Wrong document",
                "Please select a face in the active document")
            return
        # Note: For some reason setting the Support property here breaks all sorts of things.
        #       It is done in TaskHole.updateUI() instead

        # Show feature preview
        body = FreeCADGui.activeView().getActiveObject("pdbody")
        if body is None:
            QtGui.QMessageBox.critical(
                mw, "No active body",
                "Please create a body or make a body active")
            return

        feature = doc.addObject("Part::FeaturePython", "Hole")
        hole = Hole(feature)
        body.addFeature(feature)

        vp = ViewProviderHole(feature.ViewObject)
        feature.touch()
        FreeCAD.ActiveDocument.recompute()
        # Fit view (remove after the testing phase)
        FreeCADGui.SendMsgToActiveView("ViewFit")

        vp.setEdit(vp, 1)
Example #13
0
    def pick(self, cursorPos, obj):
        self.vp = obj.ViewObject

        pickAction = coin.SoRayPickAction(self._getViewport())
        pickAction.setPickAll(True)
        pickAction.setRadius(Gui.activeView().getViewer().getPickRadius())
        pickAction.setPoint(coin.SbVec2s(cursorPos))
        path = self._getPathForVP(self.vp)

        sa = coin.SoSearchAction()
        sa.setNode(self.vp.RootNode)
        sa.apply(self._getSceneGraph())
        pickAction.apply(sa.getPath())

        for pp in pickAction.getPickedPointList():
            node = pp.getPath().getTail()
            detail = self._castDetail(pp.getDetail())
            self._updatePicked(node, detail)
        self._clearPreselect()
Example #14
0
 def __init__(self, feature):
     self.feature = feature
     self.feature.addProperty("App::PropertyString","HoleType","Hole","Type of hole").HoleType="Depth"
     self.feature.addProperty("App::PropertyBool","Threaded","Hole","Threaded hole").Threaded=False
     self.feature.addProperty("App::PropertyBool","Counterbore","Hole","Counterbore hole").Counterbore=False
     self.feature.addProperty("App::PropertyBool","Countersink","Hole","Countersink hole").Countersink=False
     self.feature.addProperty("App::PropertyString","Norm","Hole","Name of norm").Norm="Custom"
     self.feature.addProperty("App::PropertyString","NormTolerance","Hole","Tolerance field of norm").NormTolerance="medium"
     self.feature.addProperty("App::PropertyLength","NormDiameter","Hole","Nominal diameter of hole").NormDiameter=4.0
     self.feature.addProperty("App::PropertyString", "ExtraNorm", "Hole", "Norm of bolt or washer used in hole").ExtraNorm="ISO 4762"
     self.feature.addProperty("App::PropertyString", "NormThread", "Hole", "Norm of thread").NormThread="DIN 13-1"
     self.feature.addProperty("App::PropertyString", "NormThreadFinish", "Hole", "Norm defining thread finish length").NormThreadFinish="DIN 76-2"
     self.feature.addProperty("App::PropertyLength","Diameter","Hole","Diameter of hole").Diameter=5.0
     self.feature.addProperty("App::PropertyLength","Depth","Hole","Depth of hole").Depth=8.0
     self.feature.addProperty("App::PropertyLength","CounterboreDiameter","Hole","Diameter of counterbore").CounterboreDiameter=10.0
     self.feature.addProperty("App::PropertyLength","CounterboreDepth","Hole","Depth of counterbore").CounterboreDepth=4.0
     self.feature.addProperty("App::PropertyLength","CountersinkAngle","Hole","Angle of countersink").CountersinkAngle=45.0;
     self.feature.addProperty("App::PropertyLength","ThreadLength","Hole","Length of thread").ThreadLength=5.0;
     self.feature.addProperty("App::PropertyString","PositionType","Hole","Type of position references").PositionType="Linear"
     self.feature.addProperty("App::PropertyLinkSub","Support","Hole","Support of hole feature").Support=None
     self.feature.addProperty("App::PropertyLink","HoleGroove","Hole","Revolution feature creating the hole").HoleGroove=None
     # Create new HoleGroove feature
     body = FreeCADGui.activeView().getActiveObject("pdbody");
     self.sketchaxis = self.feature.Document.addObject("PartDesign::Line", "HoleSketchAxis")
     body.addFeature(self.sketchaxis)
     self.Gui.ActiveDocument.hide(self.sketchaxis.Name)
     self.sketchplane = self.feature.Document.addObject("PartDesign::Plane", "HoleSketchPlane")
     self.sketchplane.References = (self.sketchaxis,  "")
     body.addFeature(self.sketchplane)
     self.Gui.ActiveDocument.hide(self.sketchplane.Name)
     self.sketch = self.feature.Document.addObject("Sketcher::SketchObject","HoleSketch")
     self.sketch.Support = (self.sketchplane,  ["front"])
     body.addFeature(self.sketch)
     self.Gui.ActiveDocument.hide(self.sketch.Name)
     feature.HoleGroove = feature.Document.addObject("PartDesign::Groove","HoleGroove")
     feature.HoleGroove.Angle = 360.0
     feature.HoleGroove.Sketch = self.sketch
     body.addFeature(feature.HoleGroove)
     self.Gui.ActiveDocument.hide(feature.HoleGroove.Name)
     self.feature.Proxy = self
     self.oldCounterbore = False
     self.oldCountersink = False
Example #15
0
 def __init__(self, feature):
     self.feature = feature
     self.feature.addProperty("App::PropertyString","HoleType","Hole","Type of hole").HoleType="Depth"
     self.feature.addProperty("App::PropertyBool","Threaded","Hole","Threaded hole").Threaded=False
     self.feature.addProperty("App::PropertyBool","Counterbore","Hole","Counterbore hole").Counterbore=False
     self.feature.addProperty("App::PropertyBool","Countersink","Hole","Countersink hole").Countersink=False
     self.feature.addProperty("App::PropertyString","Norm","Hole","Name of norm").Norm="Custom"
     self.feature.addProperty("App::PropertyString","NormTolerance","Hole","Tolerance field of norm").NormTolerance="medium"
     self.feature.addProperty("App::PropertyLength","NormDiameter","Hole","Nominal diameter of hole").NormDiameter=4.0
     self.feature.addProperty("App::PropertyString", "ExtraNorm", "Hole", "Norm of bolt or washer used in hole").ExtraNorm="ISO 4762"
     self.feature.addProperty("App::PropertyString", "NormThread", "Hole", "Norm of thread").NormThread="DIN 13-1"
     self.feature.addProperty("App::PropertyString", "NormThreadFinish", "Hole", "Norm defining thread finish length").NormThreadFinish="DIN 76-2"
     self.feature.addProperty("App::PropertyLength","Diameter","Hole","Diameter of hole").Diameter=5.0
     self.feature.addProperty("App::PropertyLength","Depth","Hole","Depth of hole").Depth=8.0
     self.feature.addProperty("App::PropertyLength","CounterboreDiameter","Hole","Diameter of counterbore").CounterboreDiameter=10.0
     self.feature.addProperty("App::PropertyLength","CounterboreDepth","Hole","Depth of counterbore").CounterboreDepth=4.0
     self.feature.addProperty("App::PropertyLength","CountersinkAngle","Hole","Angle of countersink").CountersinkAngle=45.0;
     self.feature.addProperty("App::PropertyLength","ThreadLength","Hole","Length of thread").ThreadLength=5.0;
     self.feature.addProperty("App::PropertyString","PositionType","Hole","Type of position references").PositionType="Linear"
     self.feature.addProperty("App::PropertyLinkSub","Support","Hole","Support of hole feature").Support=None
     self.feature.addProperty("App::PropertyLink","HoleGroove","Hole","Revolution feature creating the hole").HoleGroove=None
     # Create new HoleGroove feature
     body = FreeCADGui.activeView().getActiveObject("pdbody");
     self.sketchaxis = self.feature.Document.addObject("PartDesign::Line", "HoleSketchAxis")
     body.addFeature(self.sketchaxis)
     self.Gui.ActiveDocument.hide(self.sketchaxis.Name)
     self.sketchplane = self.feature.Document.addObject("PartDesign::Plane", "HoleSketchPlane")
     self.sketchplane.References = (self.sketchaxis,  "")
     body.addFeature(self.sketchplane)
     self.Gui.ActiveDocument.hide(self.sketchplane.Name)
     self.sketch = self.feature.Document.addObject("Sketcher::SketchObject","HoleSketch")
     self.sketch.Support = (self.sketchplane,  ["front"])
     body.addFeature(self.sketch)
     self.Gui.ActiveDocument.hide(self.sketch.Name)
     feature.HoleGroove = feature.Document.addObject("PartDesign::Groove","HoleGroove")
     feature.HoleGroove.Angle = 360.0
     feature.HoleGroove.Sketch = self.sketch
     body.addFeature(feature.HoleGroove)
     self.Gui.ActiveDocument.hide(feature.HoleGroove.Name)
     self.feature.Proxy = self
     self.oldCounterbore = False
     self.oldCountersink = False
Example #16
0
    def Activated(self):
        # Get main window
        mw = self.getMainWindow()

        # Get active document
        doc = FreeCAD.activeDocument()
        if doc == None:
            QtGui.QMessageBox.critical(mw, "No document", "A document must be open in order to create a hole feature")
            return

        # Check for valid position selection
        selection = FreeCADGui.Selection.getSelectionEx()
        if len(selection) != 1:
            QtGui.QMessageBox.critical(mw, "No position defined", "Please select a face to create the hole feature on")
            return
        if selection[0].DocumentName != doc.Name:
            QtGui.QMessageBox.critical(mw, "Wrong document", "Please select a face in the active document")
        # Note: For some reason setting the Support property here breaks all sorts of things.
        #       It is done in TaskHole.updateUI() instead

        # Show feature preview
        body = FreeCADGui.activeView().getActiveObject("pdbody");
        if body == None:
            QtGui.QMessageBox.critical(mw, "No active body", "Please create a body or make a body active")
    
        feature = doc.addObject("Part::FeaturePython","Hole")
        hole = Hole(feature)
        body.addFeature(feature)
        
        vp = ViewProviderHole(feature.ViewObject)
        feature.touch()
        FreeCAD.ActiveDocument.recompute()
        # Fit view (remove after the testing phase)
        FreeCADGui.SendMsgToActiveView("ViewFit")

        vp.setEdit(vp,  1)
def modify(plmobj, mode):
    plm = calculatePlace(Gui.Selection.getSelectionEx(), mode,
                         Gui.activeView())
    plmobj.Placement = plm
    executeFeature(plmobj)
    return plmobj
Example #18
0
        return {"vertices": vertices, "edges": edges, "faces": faces}


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()
Example #19
0
# import numpy as np
import sys
sys.path.append('C:\\Users\\apl\\Anaconda3\\Library\\bin')
import FreeCAD as App
import FreeCADGui as Gui
import Part, math
# import PartDesignGui
Gui.showMainWindow()
App.newDocument("Unnamed")
App.setActiveDocument("Unnamed")
App.ActiveDocument = App.getDocument("Unnamed")
Gui.ActiveDocument = Gui.getDocument("Unnamed")

Gui.activateWorkbench("PartDesignWorkbench")
App.activeDocument().addObject('PartDesign::Body', 'Body')
Gui.activeView().setActiveObject('pdbody', App.activeDocument().Body)
Gui.Selection.clearSelection()
Gui.Selection.addSelection(App.ActiveDocument.Body)
App.ActiveDocument.recompute()
App.activeDocument().Body.newObject('Sketcher::SketchObject', 'Sketch')
App.activeDocument().Sketch.Support = (App.activeDocument().XY_Plane, [''])
App.activeDocument().Sketch.MapMode = 'FlatFace'
App.ActiveDocument.recompute()
Gui.activeDocument().setEdit('Sketch')
Gui.activateWorkbench('SketcherWorkbench')
ActiveSketch = App.ActiveDocument.getObject('Sketch')
tv = Show.TempoVis(App.ActiveDocument)
time.sleep(3)
if ActiveSketch.ViewObject.HideDependent:
    objs = tv.get_all_dependent(ActiveSketch)
    objs = filter(lambda x: not x.TypeId.startswith("TechDraw::"), objs)
    def createPack(self):
        s = self.qSpinBox_n_cells_in_series.value()
        p = self.qSpinBox_n_cells_in_parallel.value()

        self.cell = Cell(self.model.text(), self.freecad_dir)
        # For now, n cells in series = width, n cells in para = length
        n_cells_in_height = p

        self.space_between_cells = float(self.qSpinBox_space_cells.value())

        # Shorthands
        
        prop = 'App::Property'
        
        fl = prop+'Float'
        pi = prop+'Integer'
        pl = prop+'Length'

        self.part = App.activeDocument().addObject('App::Part',generate_freecad_name())
        self.part.Label = BATTERY_PACK_DEFAULT_PART_LABEL
        self.part.addProperty(pl, 'Width', 'Dimensions', 'Battery pack width').Width = '10 mm'
        self.part.addProperty(pi, 'serie', 'Cells arrangement', 'Cells in series').serie = s
        self.part.addProperty(pi, 'para', 'Cells arrangement', 'Cells in parallel').para = p
        self.part.addProperty(
            fl,
            'space_between_cells',
            'Cells arrangement',
            'Space between cells'
        ).space_between_cells = self.space_between_cells

        # Default value, will change when we set the number of cells, the space between the cells, etc...
        self.part.addProperty(fl,
                            'total_nickel_strip_length',
                            "Connections",
                            "Total nickel strip length").total_nickel_strip_length = 0.0
        
        self.part.addProperty(pi, 'nc', 'Cell', 'Number of cells in the pack').nc = 0
        self.part.setExpression("nc", "serie*para")

        ### Cell ###
        self.part.addProperty(prop+'String', 'cell', 'Cell', 'Model of Cell used').cell = self.model.text()
        self.part.addProperty(fl, 'cell_price', 'Cell', 'Individual cell price').cell_price = self.cell.price
        self.part.addProperty(fl, 'cell_weight', 'Cell', 'Individual cell weight').cell_weight = self.cell.weight
        self.part.addProperty(fl, 'cell_radius', 'Cell', 'Individual cell radius').cell_radius = self.cell.radius
        self.part.addProperty(fl, 'cell_height', 'Cell', 'Individual cell height').cell_height = self.cell.height

        ### Nickel Strip ###
        self.part.addProperty(fl,
                            'nickel_strip_width',
                            'Nickel strip',
                            'Nickel strip width').nickel_strip_width = NICKEL_STRIP_WIDTH

        self.part.addProperty(fl,
                            'nickel_strip_height',
                            'Nickel strip',
                            'Nickel strip height'
                            ).nickel_strip_height = NICKEL_STRIP_HEIGHT

        self.part.addProperty(fl,
                            'nickel_strip_weight_per_mm3',
                            'Nickel strip',
                            'Nickel strip weight per mm3'
                            ).nickel_strip_weight_per_mm3 = NICKEL_STRIP_WEIGHT_PER_MM3

        ### Weight ###

        self.part.addProperty(fl,
                            'battery_holder_weight',
                            'Weight',
                            'Individual battery holder weight').battery_holder_weight = BATTERY_HOLDER_WEIGHT

        self.part.addProperty(fl, 'total_cells_weight', 'Weight', 'Total cells weight').total_cells_weight = 0.0
        self.part.setExpression("total_cells_weight", "cell_weight*nc")

        self.part.addProperty(fl,
                            'total_nickel_strip_weight',
                            'Weight',
                            'Total weight of nickel strip').total_nickel_strip_weight = 0.0

        self.part.addProperty(fl,
                            'total_battery_holders_weight',
                            'Weight',
                            'Total battery holders weight').total_battery_holders_weight = 0.0

        self.part.addProperty(fl,
                            'total_weight',
                            'Weight',
                            'Total weight of the battery pack').total_weight = 0.0
        
        ### Price ###

        self.part.addProperty(fl, 'total_cells_price', 'Price', 'Total cells price').total_cells_price = 0.0
        
        self.part.addProperty(fl,
                            'nickel_strip_price_per_mm',
                            'Price', 'Nickel strip price per mm'
                            ).nickel_strip_price_per_mm = NICKEL_STRIP_PRICE_PER_MM
        
        self.part.addProperty(fl,
                            'total_nickel_strip_price',
                            'Price',
                            'Total nickel strip price'
                            ).total_nickel_strip_price = 0.0

        Gui.activateView('Gui::View3DInventor', True)
        Gui.activeView().setActiveObject('part', self.part)
        App.ActiveDocument.recompute()

        for w in range(self.part.serie):
            placement_of_last_cell = self.create3dCell(w, self.part.space_between_cells)
            App.ActiveDocument.recompute()
        
        # Hacky way to import a .step model
        # Source : <https://forum.freecadweb.org/viewtopic.php?f=3&t=3951>

        current_instances = set(App.ActiveDocument.findObjects())
        ImportGui.insert(get_mod_path(self.freecad_dir)+HOLDER_PATH, App.ActiveDocument.Name)
        new_instances = set(App.ActiveDocument.findObjects()) - current_instances
        
        # Rotates the part 180 so the bottom of the holder is correctly placed
        new_instances.pop().Placement = App.Placement(App.Vector(0,0,0), App.Rotation(0,180,0), App.Vector(0,0,0))
        
        # Creates the nickel strips connecting all the cells in series
        
        # we multiply by 2 for the top and bottom strips
        self.part.setExpression(
            "total_nickel_strip_length",
            "2*(  ( (serie*((cell_radius*2)) ) + serie*(space_between_cells) ) - space_between_cells )"
        )

        # TEMPORARY
        #self.create_nickel_strips(placement_of_last_cell)
       
        # Volume * weight per mm³
        self.part.setExpression(
            "total_nickel_strip_weight",
            "total_nickel_strip_length*nickel_strip_width*nickel_strip_height*nickel_strip_weight_per_mm3"
        )
        
        self.part.setExpression(
            "total_battery_holders_weight",
            "battery_holder_weight*nc*2"
        )
        
        # One holder on top, one on the bottom
        self.part.setExpression(
            "total_weight",
            "total_nickel_strip_weight+total_battery_holders_weight+total_cells_weight"
        )
        
        ### Price ###
        self.part.setExpression("total_cells_price", "cell_price*nc")
        
        self.part.setExpression(
            "total_nickel_strip_price",
            "nickel_strip_price_per_mm*total_nickel_strip_length"
        )

        Gui.SendMsgToActiveView("ViewFit")
        App.ActiveDocument.recompute()

        self.close()
Example #21
0
 def _getRenderManager(self):
     return Gui.activeView().getViewer().getSoRenderManager()
Example #22
0
def getObjectBelow(cursorPos):
    objInfo = Gui.activeView().getObjectInfo(cursorPos)
    if objInfo is None:
        return None
    return App.ActiveDocument.getObject(objInfo["Object"])
Example #23
0
def getPreselectMode():
    sg = Gui.activeView().getSceneGraph()
    return sg.highlightMode.getValue()
Example #24
0
def setPreselectMode(mode):
    sg = Gui.activeView().getSceneGraph()
    sg.highlightMode.setValue(mode)