importIFCHelper Namespace Reference


class  ProjectImporter


def applyColorDict (doc, colordict=None)
def buildRelAdditions (ifcfile)
def buildRelColors (ifcfile, prodrepr)
def buildRelGroups (ifcfile)
def buildRelMaterialColors (ifcfile, prodrepr)
def buildRelMattable (ifcfile)
def buildRelProductColors (ifcfile, prodrepr)
def buildRelProductRepresentation (ifcfile)
def buildRelProductsAnnotations (ifcfile, root_element='IfcProduct')
def buildRelProperties (ifcfile)
def buildRelSubtractions (ifcfile)
def createAnnotation (annotation, doc, ifcscale, preferences)
def createFromProperties (propsets, ifcfile, parametrics)
def dd2dms (dd)
def decode (filename, utf=False)
def dms2dd (degrees, minutes, seconds, milliseconds=0)
def get2DShape (representation, scaling=1000)
def getColorFromMaterial (material)
def getColorFromProduct (product)
def getColorFromStyledItem (styled_item)
def getIfcProperties (ifcfile, pid, psets, d)
def getIfcPropertySets (ifcfile, pid)
def getIfcPsetProperties (ifcfile, pid)
def getParents (ifcobj)
def getPlacement (entity, scaling=1000)
def getProfileCenterPoint (sweptsolid)
def getRotation (entity)
def getScaling (ifcfile)
def getUnit (unit)
def getVector (entity, scaling=1000)
def isRectangle (verts)
def predefined_to_rgb (rgb_color)


bool DEBUG_prod_colors = False
bool DEBUG_prod_repr = False

Function Documentation

◆ applyColorDict()

def importIFCHelper.applyColorDict (   doc,
  colordict = None 
applies the contents of a color dict to the objects in the given doc.
If no colordict is given, the doc Meta property is searched for a "colordict" entry.

◆ buildRelAdditions()

def importIFCHelper.buildRelAdditions (   ifcfile)
Build the additions relation table.

Referenced by importIFC.insert().

◆ buildRelColors()

def importIFCHelper.buildRelColors (   ifcfile,
Build the colors relation table.

Returns all IfcStyledItem colors, material and product colors.

    A dictionary with `{id: (r,g,b), ...}` values.

◆ buildRelGroups()

def importIFCHelper.buildRelGroups (   ifcfile)
Build the groups relation table.

Referenced by importIFC.insert().

◆ buildRelMaterialColors()

def importIFCHelper.buildRelMaterialColors (   ifcfile,

◆ buildRelMattable()

def importIFCHelper.buildRelMattable (   ifcfile)
Build the mattable relation table.

Referenced by importIFC.insert().

◆ buildRelProductColors()

def importIFCHelper.buildRelProductColors (   ifcfile,
Build the colors relation table from a product.

    A dictionary with `{id: (r,g,b), ...}` values.

References getColorFromStyledItem().

Referenced by importIFC.insert().

◆ buildRelProductRepresentation()

def importIFCHelper.buildRelProductRepresentation (   ifcfile)
Build the product/representations relation table.

Referenced by importIFC.insert().

◆ buildRelProductsAnnotations()

def importIFCHelper.buildRelProductsAnnotations (   ifcfile,
  root_element = 'IfcProduct' 
Build the products and annotations relation table.

Referenced by importIFC.insert().

◆ buildRelProperties()

def importIFCHelper.buildRelProperties (   ifcfile)
Builds and returns a dictionary of {object:[properties]} from an IFC file

◆ buildRelSubtractions()

def importIFCHelper.buildRelSubtractions (   ifcfile)
Build the subtractions relation table.

Referenced by importIFC.insert().

◆ createAnnotation()

def importIFCHelper.createAnnotation (   annotation,
creates an annotation object

References get2DShape(), and getPlacement().

Referenced by importIFCmulticore.insert(), and importIFC.insert().

◆ createFromProperties()

def importIFCHelper.createFromProperties (   propsets,
Creates a FreeCAD parametric object from a set of properties.

Referenced by importIFC.insert().

◆ dd2dms()

def importIFCHelper.dd2dms (   dd)
Convert decimal degrees to degrees, minutes, seconds.

Used in export.

◆ decode()

def importIFCHelper.decode (   filename,
  utf = False 
Turn unicode into strings, only for Python 2.

Referenced by importIFC.insert(),, and

◆ dms2dd()

def importIFCHelper.dms2dd (   degrees,
  milliseconds = 0 
Convert degrees, minutes, seconds to decimal degrees.

Used in import.

Referenced by importIFC.insert().

◆ get2DShape()

def importIFCHelper.get2DShape (   representation,
  scaling = 1000 

◆ getColorFromMaterial()

def importIFCHelper.getColorFromMaterial (   material)

◆ getColorFromProduct()

def importIFCHelper.getColorFromProduct (   product)

◆ getColorFromStyledItem()

def importIFCHelper.getColorFromStyledItem (   styled_item)
Get color from the IfcStyledItem.

float, float, float, int
    A tuple with the red, green, blue, and transparency values.
    If the `IfcStyledItem` is a `IfcDraughtingPreDefinedColour`
    the transparency is set to 0.
    The first three values range from 0 to 1.0, while the transparency
    varies from 0 to 100.

    Return `None` if `styled_item` is not of type `'IfcStyledItem'`
    or if there is any other problem getting a color.

References predefined_to_rgb().

Referenced by buildRelProductColors(), and getColorFromMaterial().

◆ getIfcProperties()

def importIFCHelper.getIfcProperties (   ifcfile,
builds valid property values for FreeCAD

Referenced by getIfcPsetProperties(), and importIFC.insert().

◆ getIfcPropertySets()

def importIFCHelper.getIfcPropertySets (   ifcfile,
Returns a dictionary of {pset_id:[prop_id, prop_id...]} for an IFC object

Referenced by getIfcPsetProperties(), and importIFC.insert().

◆ getIfcPsetProperties()

def importIFCHelper.getIfcPsetProperties (   ifcfile,
 directly build the property table from pid and ifcfile for FreeCAD

References getIfcProperties(), and getIfcPropertySets().

◆ getParents()

def importIFCHelper.getParents (   ifcobj)
finds the parent entities of an IFC entity

Referenced by importIFCmulticore.createModelStructure().

◆ getPlacement()

def importIFCHelper.getPlacement (   entity,
  scaling = 1000 
returns a placement from the given entity

References getPlacement(), DraftVecUtils.getPlaneRotation(), and getVector().

Referenced by createAnnotation(), get2DShape(), getPlacement(), and getProfileCenterPoint().

◆ getProfileCenterPoint()

def importIFCHelper.getProfileCenterPoint (   sweptsolid)
returns the center point of the profile of an extrusion

References get2DShape(), and getPlacement().

Referenced by importIFC.insert().

◆ getRotation()

def importIFCHelper.getRotation (   entity)
returns a FreeCAD rotation from an IfcProduct with a IfcMappedItem representation

References WorkingPlane.plane.

Referenced by get2DShape(), and importIFC.insert().

◆ getScaling()

def importIFCHelper.getScaling (   ifcfile)
Return a scaling factor from the IFC file; units to mm.

References getUnit().

Referenced by importIFCmulticore.insert(), and importIFC.insert().

◆ getUnit()

def importIFCHelper.getUnit (   unit)
Get the unit multiplier for different decimal prefixes.

Only for when the unit is METRE.
When no Prefix is provided, return 1000, that is, mm x 1000 = metre.
For other cases, return 1.0.

Referenced by getScaling().

◆ getVector()

def importIFCHelper.getVector (   entity,
  scaling = 1000 
returns a vector from the given entity

Referenced by get2DShape(), and getPlacement().

◆ isRectangle()

def importIFCHelper.isRectangle (   verts)
returns True if the given 4 vertices form a rectangle

Referenced by importIFC.insert().

◆ predefined_to_rgb()

def importIFCHelper.predefined_to_rgb (   rgb_color)
Transform a predefined color name to its [r, g, b] representation.

TODO: at the moment it doesn't handle 'by layer'.
See: `IfcDraughtingPreDefinedColour` and `IfcPresentationLayerWithStyle`.

Referenced by getColorFromStyledItem().

Variable Documentation

◆ DEBUG_prod_colors

bool importIFCHelper.DEBUG_prod_colors = False

◆ DEBUG_prod_repr

bool importIFCHelper.DEBUG_prod_repr = False


dictionary importIFCHelper.PREDEFINED_RGB
Initial value:
1= {"black": (0, 0, 0),
2 "red": (1.0, 0, 0),
3 "green": (0, 1.0, 0),
4 "blue": (0, 0, 1.0),
5 "yellow": (1.0, 1.0, 0),
6 "magenta": (1.0, 0, 1.0),
7 "cyan": (0, 1.0, 1.0),
8 "white": (1.0, 1.0, 1.0)}