femtools.femutils Namespace Reference


def check_working_dir (wdir)
def createObject (doc, name, proxy, viewProxy=None)
def get_beside_base (obj)
def get_beside_dir (obj)
def get_custom_base (solver)
def get_custom_dir (obj)
def get_part_to_mesh (mesh_obj)
def get_pref_working_dir (solver_obj)
def get_refshape_type (fem_doc_object)
def get_temp_dir (obj=None)
def getBoundBoxOfAllDocumentShapes (doc)
def getSelectedFace (selectionex)
def is_derived_from (obj, t)
def is_of_type (obj, ty)
def make_dir (specific_path)
def pydecode (bytestring)
def startProgramInfo (code)
def type_of_obj (obj)

Function Documentation

◆ check_working_dir()

def femtools.femutils.check_working_dir (   wdir)

◆ createObject()

def femtools.femutils.createObject (   doc,
  viewProxy = None 
 Add python object to document using python type string.

Add a document object suitable for the *proxy* and the *viewProxy* to *doc*
and attach it to the *proxy* and the *viewProxy*. This function can only be
used with python proxies that specify their C++ type via the BaseType class
member (e.g. Cube.BaseType). If there already exists a object with *name* a
suitable unique name is generated. To auto generate a name pass ``""``.

:param doc:         document object to which the object is added
:param name:        string of the name of new object in *doc*, use
                    ``""`` to generate a name
:param proxy:       python proxy for new object
:param viewProxy:   view proxy for new object

:returns:           reference to new object

◆ get_beside_base()

def femtools.femutils.get_beside_base (   obj)

◆ get_beside_dir()

def femtools.femutils.get_beside_dir (   obj)

◆ get_custom_base()

def femtools.femutils.get_custom_base (   solver)

◆ get_custom_dir()

◆ get_part_to_mesh()

def femtools.femutils.get_part_to_mesh (   mesh_obj)
gmsh mesh object: the Attribute is Part
netgen mesh object: the Attribute is Shape
other mesh objects: do not have a Attribute which holds the part to mesh

References femtools.femutils.is_derived_from().

◆ get_pref_working_dir()

def femtools.femutils.get_pref_working_dir (   solver_obj)
 Return working directory for solver honoring user settings.

:throws femtools.errors.MustSaveError:
 If user setting is set to BESIDE and the document isn't saved.

 Not working correctly for most cases because this circumvents directory
 caching of the solver framework. For solver use getMachine from run.py

References femtools.femutils.get_beside_dir(), femtools.femutils.get_custom_dir(), and femtools.femutils.get_temp_dir().

◆ get_refshape_type()

def femtools.femutils.get_refshape_type (   fem_doc_object)
 Return shape type the constraints references.

Determine single shape type of references of *fem_doc_object* which must be
a constraint (=have a *References* property). All references must be of the
same type which is than returned as a string. A type can be "Vertex",
"Edge", "Face" or "Solid".

:param fem_doc_object:
 A constraint object with a *References* property.

 A string representing the shape type ("Vertex", "Edge", "Face" or
 "Solid"). If *fem_doc_object* isn't a constraint ``""`` is returned.

 Undefined behaviour if the type of the references of one object are
 not all the same.

 Undefined behaviour if constraint contains no references (empty list).

◆ get_temp_dir()

◆ getBoundBoxOfAllDocumentShapes()

def femtools.femutils.getBoundBoxOfAllDocumentShapes (   doc)
 Calculate bounding box containing all objects inside *doc*.

 A bounding box containing all objects that have a *Shape* attribute (all
 Part and PartDesign objects). If the document contains no such objects or
 no objects at all return ``None``.

◆ getSelectedFace()

def femtools.femutils.getSelectedFace (   selectionex)
 Return selected face if exactly one face is selected.

 The selected face as a ``Part::TopoShape`` if exactly one face is selected.
 Otherwise return ``None``.

:param selectionex:
 A list of selection object like the one Gui.Selection.getSelectionEx()

◆ is_derived_from()

def femtools.femutils.is_derived_from (   obj,
 Check if *obj* is derived from *t* honoring Fems typesytem.

Essentially just call ``obj.isDerivedFrom(t)`` and return it's value. For
objects using Fems typesystem (see :py:func:`type_of_obj`) return always
True if the Fem type is equal to *t*.

 Inheritance of Fem types is not checked. If *obj* uses Fems typesystem the
 type is just checked for equality. If the type doesn't match
 ``obj.isDerivedFrom`` is called as usual. See

Referenced by femtools.femutils.get_part_to_mesh().

◆ is_of_type()

def femtools.femutils.is_of_type (   obj,
 Compare type of *obj* with *ty* honoring Fems typesystem.

See :py:func:`type_of_obj` for more info about the special typesystem of
the Fem module.

 ``True`` if *obj* is of type *ty*, ``False`` otherwise. Type must match
 exactly: Derived objects are not considered to be of type of one of their
 super classes.

References femtools.femutils.type_of_obj().

◆ make_dir()

def femtools.femutils.make_dir (   specific_path)

◆ pydecode()

def femtools.femutils.pydecode (   bytestring)
 Return *bytestring* as a unicode string for python 2 and 3.

For python 2 *bytestring* is converted to a string of type ``unicode``. For
python 3 it is returned as is because it uses unicode for it's ``str`` type

◆ startProgramInfo()

def femtools.femutils.startProgramInfo (   code)
 starts a program under Windows minimized, hidden or normal 

◆ type_of_obj()

def femtools.femutils.type_of_obj (   obj)
 Return type of *obj* honoring the special typesystem of Fem.

Python objects of the Fem workbench define their type via a class member
``<Class>.Type``. Return this type if the property exists. If not return
the conventional ``TypeId`` value.

:para obj: a document object

Referenced by femtools.femutils.is_of_type().