Skip to content

FreeCADWrapper#

RLFEM.FreeCADWrapper #

FreeCADWrapper #

Class allowing to interact with the FreeCad simulation.

TODO: more description

__init__(self, path='') special #

Args: path: path to the .ply file.

Source code in RLFEM/FreeCADWrapper.py
def __init__(self, path=''):
    """
    Args:
        path: path to the .ply file.
    """
    self.path = path

    # TODO: add the number of actions (sequence) and repeat until it's satisfied
    # doc = FreeCAD.getDocument("Unnamed") # CHANGE LATER!
    self.doc = App.newDocument("doc")

    if not (self.path == ''):
        self.insert_mesh()
    else:
        # TODO: correct the dimensions
        obj = self.doc.addObject('Part::Box', 'Box')
        obj.Height = 2
        obj.Width = 5
        obj.Length = 50

    self.obj = self.doc.Objects[-1]

    if (self.obj.Module == 'Mesh'):
        self.convert2solidmesh()
        self.obj = self.doc.Objects[-1]

    self.box_obj = self.doc.addObject('Part::Box', 'Box')
    # box_obj.ViewObject.Visibility = False

    self.v_CoM, self.v_NoF = self.extract_info_mesh(self.obj)

    self.min_vals = self.v_CoM.min(axis=0)
    self.max_vals = self.v_CoM.max(axis=0)
    self.obj_dims = abs(self.max_vals - self.min_vals)
    self.LENGTH = self.obj_dims[0]  # x direction
    self.WIDTH = self.obj_dims[1]  # y direction
    self.HEIGHT = self.obj_dims[2]  # z direction

    self.NUM_BIN = 1000

    self.flag_elong = 'length'
    self.calc_epsilon()

    self.v_CoM_sorted = self.get_sorted_CoM(self.v_CoM, self.column_index)