Arch: Internal IFC parser not used anymore if IfcOpenShell is present
This commit is contained in:
parent
8079e6452b
commit
af529e2603
|
@ -78,7 +78,7 @@ def addComponents(objectsList,host):
|
|||
if not o in c:
|
||||
c.append(o)
|
||||
host.Group = c
|
||||
elif tp in ["Wall","Structure"]:
|
||||
elif tp in ["Wall","Structure","Window","Roof"]:
|
||||
a = host.Additions
|
||||
if hasattr(host,"Axes"):
|
||||
x = host.Axes
|
||||
|
|
|
@ -37,7 +37,7 @@ def addToComponent(compobject,addobject,mod=None):
|
|||
to override the default.'''
|
||||
import Draft
|
||||
if compobject == addobject: return
|
||||
# first check is already there
|
||||
# first check zis already there
|
||||
found = False
|
||||
attribs = ["Additions","Objects","Components","Subtractions","Base"]
|
||||
for a in attribs:
|
||||
|
|
|
@ -30,7 +30,7 @@ __title__="FreeCAD Roof"
|
|||
__author__ = "Yorik van Havre"
|
||||
__url__ = "http://free-cad.sourceforge.net"
|
||||
|
||||
def makeRoof(baseobj,facenr=1,angle=45,name=str(translate("Arch","Roof"))):
|
||||
def makeRoof(baseobj=None,facenr=1,angle=45,name=str(translate("Arch","Roof"))):
|
||||
'''makeRoof(baseobj,[facenr],[angle],[name]) : Makes a roof based on a
|
||||
face from an existing object. You can provide the number of the face
|
||||
to build the roof on (default = 1), the angle (default=45) and a name (default
|
||||
|
@ -38,7 +38,8 @@ def makeRoof(baseobj,facenr=1,angle=45,name=str(translate("Arch","Roof"))):
|
|||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
_Roof(obj)
|
||||
_ViewProviderRoof(obj.ViewObject)
|
||||
obj.Base = baseobj
|
||||
if baseobj:
|
||||
obj.Base = baseobj
|
||||
obj.Face = facenr
|
||||
obj.Angle = angle
|
||||
return obj
|
||||
|
@ -92,7 +93,7 @@ class _Roof(ArchComponent.Component):
|
|||
str(translate("Arch","The angle of this roof")))
|
||||
obj.addProperty("App::PropertyInteger","Face","Base",
|
||||
str(translate("Arch","The face number of the base object used to build this roof")))
|
||||
self.Type = "Structure"
|
||||
self.Type = "Roof"
|
||||
|
||||
def execute(self,obj):
|
||||
self.createGeometry(obj)
|
||||
|
|
|
@ -361,11 +361,11 @@ class _Wall(ArchComponent.Component):
|
|||
base = obj.Base.Shape.copy()
|
||||
if base.Solids:
|
||||
pass
|
||||
elif base.Faces and (not obj.ForceWire):
|
||||
elif (len(base.Faces) == 1) and (not obj.ForceWire):
|
||||
if height:
|
||||
norm = normal.multiply(height)
|
||||
base = base.extrude(norm)
|
||||
elif base.Wires:
|
||||
elif len(base.Wires) == 1:
|
||||
temp = None
|
||||
for wire in obj.Base.Shape.Wires:
|
||||
sh = getbase(wire)
|
||||
|
@ -376,9 +376,10 @@ class _Wall(ArchComponent.Component):
|
|||
base = temp
|
||||
elif base.Edges:
|
||||
wire = Part.Wire(base.Edges)
|
||||
sh = getbase(wire)
|
||||
if sh:
|
||||
base = sh
|
||||
if wire:
|
||||
sh = getbase(wire)
|
||||
if sh:
|
||||
base = sh
|
||||
else:
|
||||
base = None
|
||||
FreeCAD.Console.PrintError(str(translate("Arch","Error: Invalid base object")))
|
||||
|
|
|
@ -167,6 +167,34 @@ class _Window(ArchComponent.Component):
|
|||
if not DraftGeomUtils.isNull(pl):
|
||||
obj.Placement = pl
|
||||
|
||||
# processing additions and subtractions
|
||||
sh = obj.Shape
|
||||
for app in obj.Additions:
|
||||
if app.isDerivedFrom("Part::Feature"):
|
||||
if app.Shape:
|
||||
if not app.Shape.isNull():
|
||||
if sh.isNull():
|
||||
sh = app.Shape
|
||||
else:
|
||||
if sh.Solids and app.Shape.Solids:
|
||||
sh = sh.fuse(app.Shape)
|
||||
app.ViewObject.hide() #to be removed
|
||||
else:
|
||||
print "ArchWindow: shape not solid"
|
||||
for hole in obj.Subtractions:
|
||||
if hole.isDerivedFrom("Part::Feature"):
|
||||
if hole.Shape:
|
||||
if not hole.Shape.isNull():
|
||||
if not sh.isNull():
|
||||
if sh.Solids and hole.Shape.Solids:
|
||||
sh = sh.cut(hole.Shape)
|
||||
hole.ViewObject.hide() # to be removed
|
||||
else:
|
||||
print "ArchWindow: shape not solid"
|
||||
if not sh.isNull():
|
||||
sh.removeSplitter()
|
||||
obj.Shape = sh
|
||||
|
||||
class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
"A View Provider for the Window object"
|
||||
|
||||
|
|
16883
src/Mod/Arch/Arch_rc.py
16883
src/Mod/Arch/Arch_rc.py
File diff suppressed because it is too large
Load Diff
|
@ -164,18 +164,38 @@
|
|||
<string>IFC import</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_5">
|
||||
<property name="toolTip">
|
||||
<string>Check this to display debug messages while importing IFC files</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show debug messages</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ifcDebug</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Arch</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox">
|
||||
<property name="toolTip">
|
||||
<string>If this is checked, the IFCOpenShell importer will be used, allowing to import more IFC types</string>
|
||||
<string>If this is checked, IFC files will always be imported with the internal python parser, even if IfcOpenShell is installed</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use IFCOpenShell if available</string>
|
||||
<string>Force python parser</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>useIfcOpenShell</cstring>
|
||||
<cstring>forceIfcPythonParser</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Arch</cstring>
|
||||
|
@ -221,6 +241,76 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_6">
|
||||
<property name="toolTip">
|
||||
<string>If this is checked, openings will be imported as subtractions, otherwise wall shapes will already have their openings subtracted</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Separate openings</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ifcSeparateOpenings</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Arch</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_7">
|
||||
<property name="toolTip">
|
||||
<string>If this is checked, object names will be prefixed with the IFC ID number</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Prefix names with ID number</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ifcPrefixNumbers</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Arch</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Exclude list: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefLineEdit" name="gui::preflineedit">
|
||||
<property name="toolTip">
|
||||
<string>A comma-separated list of Ifc entities to exclude from import</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>IfcSpace,IfcBuildingElementProxy,IfcFlowTerminal</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ifcSkip</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Arch</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -290,22 +380,22 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
|
@ -326,6 +416,11 @@
|
|||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
|
|
|
@ -29,9 +29,8 @@ __author__ = "Yorik van Havre"
|
|||
__url__ = "http://free-cad.sourceforge.net"
|
||||
|
||||
# config
|
||||
DEBUG = True
|
||||
subtractiveTypes = ["IfcOpeningElement"] # elements that must be subtracted from their parents
|
||||
SCHEMA = "http://www.steptools.com/support/stdev_docs/express/ifc2x3/ifc2x3_tc1.exp"
|
||||
SKIP = ["IfcOpeningElement","IfcSpace"]
|
||||
# end config
|
||||
|
||||
if open.__module__ == '__builtin__':
|
||||
|
@ -43,14 +42,7 @@ def open(filename):
|
|||
doc = FreeCAD.newDocument(docname)
|
||||
doc.Label = decode(docname)
|
||||
FreeCAD.ActiveDocument = doc
|
||||
global createIfcGroups, useIfcOpenShell, importIfcFurniture
|
||||
createIfcGroups = useIfcOpenShell = importIfcFurniture = False
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
useIfcOpenShell = p.GetBool("useIfcOpenShell")
|
||||
createIfcGroups = p.GetBool("createIfcGroups")
|
||||
importIfcFurniture = p.GetBool("importIfcFurniture")
|
||||
if not importIfcFurniture:
|
||||
SKIP.append("IfcFurnishingElement")
|
||||
getConfig()
|
||||
read(filename)
|
||||
return doc
|
||||
|
||||
|
@ -61,17 +53,451 @@ def insert(filename,docname):
|
|||
except:
|
||||
doc = FreeCAD.newDocument(docname)
|
||||
FreeCAD.ActiveDocument = doc
|
||||
global createIfcGroups, useIfcOpenShell, importIfcFurniture
|
||||
createIfcGroups = useIfcOpenShell = importIfcFurniture = False
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
useIfcOpenShell = p.GetBool("useIfcOpenShell")
|
||||
createIfcGroups = p.GetBool("createIfcGroups")
|
||||
importIfcFurniture = p.GetBool("importIfcFurniture")
|
||||
if not importIfcFurniture:
|
||||
SKIP.append("IfcFurnishingElement")
|
||||
getConfig()
|
||||
read(filename)
|
||||
return doc
|
||||
|
||||
def getConfig():
|
||||
"Gets Arch IFC import preferences"
|
||||
global CREATE_IFC_GROUPS, IMPORT_IFC_FURNITURE, DEBUG, SKIP, PREFIX_NUMBERS, FORCE_PYTHON_PARSER, SEPARATE_OPENINGS
|
||||
CREATE_IFC_GROUPS = False
|
||||
IMPORT_IFC_FURNITURE = False
|
||||
DEBUG = False
|
||||
SKIP = ["IfcSpace","IfcBuildingElementProxy","IfcFlowTerminal"]
|
||||
PREFIX_NUMBERS = False
|
||||
FORCE_PYTHON_PARSER = False
|
||||
SEPARATE_OPENINGS = False
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
CREATE_IFC_GROUPS = p.GetBool("createIfcGroups")
|
||||
IMPORT_IFC_FURNITURE = p.GetBool("importIfcFurniture")
|
||||
FORCE_PYTHON_PARSER = p.GetBool("forceIfcPythonParser")
|
||||
DEBUG = p.GetBool("ifcDebug")
|
||||
SEPARATE_OPENINGS = p.GetBool("ifcSeparateOpenings")
|
||||
PREFIX_NUMBERS = p.GetBool("ifcPrefixNumbers")
|
||||
skiplist = p.GetString("ifcSkip")
|
||||
if skiplist:
|
||||
SKIP = skiplist.split(",")
|
||||
|
||||
|
||||
def getIfcOpenShell():
|
||||
"locates and imports ifcopenshell"
|
||||
try:
|
||||
global IfcImport
|
||||
import IfcImport
|
||||
except:
|
||||
FreeCAD.Console.PrintMessage(str(translate("Arch","Couldn't locate IfcOpenShell\n")))
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def read(filename):
|
||||
"Parses an IFC file"
|
||||
|
||||
# parsing the IFC file
|
||||
t1 = time.time()
|
||||
num_lines = sum(1 for line in pyopen(filename))
|
||||
|
||||
if getIfcOpenShell() and not FORCE_PYTHON_PARSER:
|
||||
# use the IfcOpenShell parser
|
||||
|
||||
# preparing IfcOpenShell
|
||||
if DEBUG: global ifcObjects,ifcParents
|
||||
ifcObjects = {} # a table to relate ifc id with freecad object
|
||||
ifcParents = {} # a table to relate ifc id with parent id
|
||||
if not IMPORT_IFC_FURNITURE:
|
||||
SKIP.append("IfcFurnishingElement")
|
||||
if hasattr(IfcImport,"DISABLE_OPENING_SUBTRACTIONS") and SEPARATE_OPENINGS:
|
||||
IfcImport.Settings(IfcImport.DISABLE_OPENING_SUBTRACTIONS,True)
|
||||
else:
|
||||
SKIP.append("IfcOpeningElement")
|
||||
useShapes = False
|
||||
if hasattr(IfcImport,"USE_BREP_DATA"):
|
||||
IfcImport.Settings(IfcImport.USE_BREP_DATA,True)
|
||||
useShapes = True
|
||||
else:
|
||||
if DEBUG: print "Warning: IfcOpenShell version very old, unable to handle Brep data"
|
||||
|
||||
# processing geometry
|
||||
if IfcImport.Init(filename):
|
||||
while True:
|
||||
|
||||
obj = IfcImport.Get()
|
||||
if DEBUG: print "["+str(int((float(obj.id)/num_lines)*100))+"%] parsing ",obj.id,": ",obj.name," of type ",obj.type
|
||||
meshdata = []
|
||||
|
||||
# retrieving name
|
||||
n = getName(obj)
|
||||
|
||||
# skip types
|
||||
if obj.type in SKIP:
|
||||
if DEBUG: print "skipping because type is in skip list"
|
||||
nobj = None
|
||||
|
||||
else:
|
||||
# build shape
|
||||
shape = None
|
||||
if useShapes:
|
||||
shape = getShape(obj)
|
||||
|
||||
# walls
|
||||
if obj.type in ["IfcWallStandardCase","IfcWall"]:
|
||||
nobj = makeWall(obj.id,shape,n)
|
||||
|
||||
# windows
|
||||
elif obj.type in ["IfcWindow","IfcDoor"]:
|
||||
nobj = makeWindow(obj.id,shape,n)
|
||||
|
||||
# structs
|
||||
elif obj.type in ["IfcBeam","IfcColumn","IfcSlab","IfcFooting"]:
|
||||
nobj = makeStructure(obj.id,shape,n)
|
||||
|
||||
# roofs
|
||||
elif obj.type in ["IfcRoof"]:
|
||||
nobj = makeRoof(obj.id,shape,n)
|
||||
|
||||
# furniture
|
||||
elif obj.type in ["IfcFurnishingElement"]:
|
||||
nobj = FreeCAD.ActiveDocument.addObject("Part::Feature",n)
|
||||
nobj.Shape = shape
|
||||
|
||||
# sites
|
||||
elif obj.type in ["IfcSite"]:
|
||||
nobj = makeSite(obj.id,shape,n)
|
||||
|
||||
elif shape:
|
||||
# treat as dumb parts
|
||||
#if DEBUG: print "Fixme: Shape-containing object not handled: ",obj.id, " ", obj.type
|
||||
nobj = FreeCAD.ActiveDocument.addObject("Part::Feature",n)
|
||||
nobj.Shape = shape
|
||||
|
||||
else:
|
||||
# treat as meshes
|
||||
if DEBUG: print "Warning: Object without shape: ",obj.id, " ", obj.type
|
||||
me,pl = getMesh(obj)
|
||||
nobj = FreeCAD.ActiveDocument.addObject("Mesh::Feature",n)
|
||||
nobj.Mesh = me
|
||||
nobj.Placement = pl
|
||||
|
||||
# registering object number and parent
|
||||
if obj.parent_id > 0:
|
||||
ifcParents[obj.id] = [obj.parent_id,not (obj.type in subtractiveTypes)]
|
||||
ifcObjects[obj.id] = nobj
|
||||
|
||||
if not IfcImport.Next():
|
||||
break
|
||||
|
||||
# processing non-geometry and relationships
|
||||
parents_temp = dict(ifcParents)
|
||||
import ArchCommands
|
||||
|
||||
while parents_temp:
|
||||
id, c = parents_temp.popitem()
|
||||
parent_id = c[0]
|
||||
additive = c[1]
|
||||
|
||||
if (id <= 0) or (parent_id <= 0):
|
||||
# root dummy object
|
||||
parent = None
|
||||
|
||||
elif parent_id in ifcObjects:
|
||||
parent = ifcObjects[parent_id]
|
||||
# check if parent is a subtraction, if yes parent to grandparent
|
||||
if parent_id in ifcParents:
|
||||
if ifcParents[parent_id][1] == False:
|
||||
grandparent_id = ifcParents[parent_id][0]
|
||||
if grandparent_id in ifcObjects:
|
||||
parent = ifcObjects[grandparent_id]
|
||||
else:
|
||||
# creating parent if needed
|
||||
parent_ifcobj = IfcImport.GetObject(parent_id)
|
||||
if DEBUG: print "["+str(int((float(parent_ifcobj.id)/num_lines)*100))+"%] parsing ",parent_ifcobj.id,": ",parent_ifcobj.name," of type ",parent_ifcobj.type
|
||||
n = getName(parent_ifcobj)
|
||||
if parent_ifcobj.id <= 0:
|
||||
parent = None
|
||||
elif parent_ifcobj.type == "IfcBuildingStorey":
|
||||
parent = Arch.makeFloor(name=n)
|
||||
elif parent_ifcobj.type == "IfcBuilding":
|
||||
parent = Arch.makeBuilding(name=n)
|
||||
elif parent_ifcobj.type == "IfcSite":
|
||||
parent = Arch.makeSite(name=n)
|
||||
elif parent_ifcobj.type == "IfcWindow":
|
||||
parent = Arch.makeWindow(name=n)
|
||||
else:
|
||||
if DEBUG: print "Fixme: skipping unhandled parent: ", parent_ifcobj.id, " ", parent_ifcobj.type
|
||||
parent = None
|
||||
# registering object number and parent
|
||||
if parent_ifcobj.parent_id > 0:
|
||||
ifcParents[parent_ifcobj.id] = [parent_ifcobj.parent_id,True]
|
||||
parents_temp[parent_ifcobj.id] = [parent_ifcobj.parent_id,True]
|
||||
if parent and (not parent_ifcobj.id in ifcObjects):
|
||||
ifcObjects[parent_ifcobj.id] = parent
|
||||
|
||||
# attributing parent
|
||||
if parent and (id in ifcObjects):
|
||||
if ifcObjects[id]:
|
||||
if additive:
|
||||
ArchCommands.addComponents(ifcObjects[id],parent)
|
||||
else:
|
||||
ArchCommands.removeComponents(ifcObjects[id],parent)
|
||||
|
||||
IfcImport.CleanUp()
|
||||
|
||||
else:
|
||||
# use only the internal python parser
|
||||
|
||||
FreeCAD.Console.PrintWarning(str(translate("Arch","IfcOpenShell not found, falling back on internal parser.\n")))
|
||||
schema=getSchema()
|
||||
if schema:
|
||||
if DEBUG: global ifc
|
||||
if DEBUG: print "opening",filename,"..."
|
||||
ifc = ifcReader.IfcDocument(filename,schema=schema,debug=DEBUG)
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning(str(translate("Arch","IFC Schema not found, IFC import disabled.\n")))
|
||||
return None
|
||||
t2 = time.time()
|
||||
if DEBUG: print "Successfully loaded",ifc,"in %s s" % ((t2-t1))
|
||||
|
||||
# getting walls
|
||||
for w in ifc.getEnt("IfcWallStandardCase"):
|
||||
nobj = makeWall(w)
|
||||
|
||||
# getting windows and doors
|
||||
for w in (ifc.getEnt("IfcWindow") + ifc.getEnt("IfcDoor")):
|
||||
nobj = makeWindow(w)
|
||||
|
||||
# getting structs
|
||||
for w in (ifc.getEnt("IfcSlab") + ifc.getEnt("IfcBeam") + ifc.getEnt("IfcColumn") \
|
||||
+ ifc.getEnt("IfcFooting")):
|
||||
nobj = makeStructure(w)
|
||||
|
||||
# getting floors
|
||||
for f in ifc.getEnt("IfcBuildingStorey"):
|
||||
group(f,ifc,"Floor")
|
||||
|
||||
# getting buildings
|
||||
for b in ifc.getEnt("IfcBuilding"):
|
||||
group(b,ifc,"Building")
|
||||
|
||||
# getting sites
|
||||
for s in ifc.getEnt("IfcSite"):
|
||||
group(s,ifc,"Site")
|
||||
|
||||
if DEBUG: print "done parsing. Recomputing..."
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
t3 = time.time()
|
||||
if DEBUG: print "done processing IFC file in %s s" % ((t3-t1))
|
||||
|
||||
return None
|
||||
|
||||
def getName(ifcobj):
|
||||
"Get a clean name from an ifc object"
|
||||
n = ifcobj.name
|
||||
if not n:
|
||||
n = ifcobj.type
|
||||
if PREFIX_NUMBERS:
|
||||
n = "ID"+str(ifcobj.id)+" "+n
|
||||
#for c in ",.!?;:":
|
||||
# n = n.replace(c,"_")
|
||||
return n
|
||||
|
||||
|
||||
def makeWall(entity,shape=None,name="Wall"):
|
||||
"makes a wall in the freecad document"
|
||||
try:
|
||||
if shape:
|
||||
# use ifcopenshell
|
||||
body = FreeCAD.ActiveDocument.addObject("Part::Feature","WallBody")
|
||||
body.Shape = shape
|
||||
wall = Arch.makeWall(body,name=name)
|
||||
wall.Label = name
|
||||
if DEBUG: print "made wall object ",entity,":",wall
|
||||
return wall
|
||||
|
||||
# use internal parser
|
||||
if DEBUG: print "=====> making wall",entity.id
|
||||
placement = wall = wire = body = width = height = None
|
||||
placement = getPlacement(entity.ObjectPlacement)
|
||||
if DEBUG: print "got wall placement",entity.id,":",placement
|
||||
width = entity.getProperty("Width")
|
||||
height = entity.getProperty("Height")
|
||||
if width and height:
|
||||
if DEBUG: print "got width, height ",entity.id,":",width,"/",height
|
||||
for r in entity.Representation.Representations:
|
||||
if r.RepresentationIdentifier == "Axis":
|
||||
wire = getWire(r.Items,placement)
|
||||
wall = Arch.makeWall(wire,width,height,align="Center",name="Wall"+str(entity.id))
|
||||
else:
|
||||
if DEBUG: print "no height or width properties found..."
|
||||
for r in entity.Representation.Representations:
|
||||
if r.RepresentationIdentifier == "Body":
|
||||
for b in r.Items:
|
||||
if b.type == "IFCEXTRUDEDAREASOLID":
|
||||
norm = getVector(b.ExtrudedDirection)
|
||||
norm.normalize()
|
||||
wire = getWire(b.SweptArea,placement)
|
||||
wall = Arch.makeWall(wire,width=0,height=b.Depth,name="Wall"+str(entity.id))
|
||||
wall.Normal = norm
|
||||
if wall:
|
||||
if DEBUG: print "made wall object ",entity.id,":",wall
|
||||
return wall
|
||||
if DEBUG: print "error: skipping wall",entity.id
|
||||
return None
|
||||
except:
|
||||
if DEBUG: print "error: skipping wall",entity.id
|
||||
return None
|
||||
|
||||
|
||||
def makeWindow(entity,shape=None,name="Window"):
|
||||
"makes a window in the freecad document"
|
||||
try:
|
||||
if shape:
|
||||
# use ifcopenshell
|
||||
window = Arch.makeWindow(name=name)
|
||||
window.Shape = shape
|
||||
window.Label = name
|
||||
if DEBUG: print "made window object ",entity,":",window
|
||||
return window
|
||||
|
||||
# use internal parser
|
||||
if DEBUG: print "=====> making window",entity.id
|
||||
placement = window = wire = body = width = height = None
|
||||
placement = getPlacement(entity.ObjectPlacement)
|
||||
if DEBUG: print "got window placement",entity.id,":",placement
|
||||
width = entity.getProperty("Width")
|
||||
height = entity.getProperty("Height")
|
||||
for r in entity.Representation.Representations:
|
||||
if r.RepresentationIdentifier == "Body":
|
||||
for b in r.Items:
|
||||
if b.type == "IFCEXTRUDEDAREASOLID":
|
||||
wire = getWire(b.SweptArea,placement)
|
||||
window = Arch.makeWindow(wire,width=b.Depth,name=objtype+str(entity.id))
|
||||
if window:
|
||||
if DEBUG: print "made window object ",entity.id,":",window
|
||||
return window
|
||||
if DEBUG: print "error: skipping window",entity.id
|
||||
return None
|
||||
except:
|
||||
if DEBUG: print "error: skipping window",entity.id
|
||||
return None
|
||||
|
||||
|
||||
def makeStructure(entity,shape=None,name="Structure"):
|
||||
"makes a structure in the freecad document"
|
||||
try:
|
||||
if shape:
|
||||
# use ifcopenshell
|
||||
sh = FreeCAD.ActiveDocument.addObject("Part::Feature","StructureBody")
|
||||
sh.Shape = shape
|
||||
structure = Arch.makeStructure(sh,name=name)
|
||||
structure.Label = name
|
||||
if DEBUG: print "made structure object ",entity,":",structure
|
||||
return structure
|
||||
|
||||
# use internal parser
|
||||
if DEBUG: print "=====> making struct",entity.id
|
||||
placement = structure = wire = body = width = height = None
|
||||
placement = getPlacement(entity.ObjectPlacement)
|
||||
if DEBUG: print "got window placement",entity.id,":",placement
|
||||
width = entity.getProperty("Width")
|
||||
height = entity.getProperty("Height")
|
||||
for r in entity.Representation.Representations:
|
||||
if r.RepresentationIdentifier == "Body":
|
||||
for b in r.Items:
|
||||
if b.type == "IFCEXTRUDEDAREASOLID":
|
||||
wire = getWire(b.SweptArea,placement)
|
||||
structure = Arch.makeStructure(wire,height=b.Depth,name=objtype+str(entity.id))
|
||||
if structure:
|
||||
if DEBUG: print "made structure object ",entity.id,":",structure
|
||||
return structure
|
||||
if DEBUG: print "error: skipping structure",entity.id
|
||||
return None
|
||||
except:
|
||||
if DEBUG: print "error: skipping structure",entity.id
|
||||
return None
|
||||
|
||||
|
||||
def makeSite(entity,shape=None,name="Site"):
|
||||
"makes a site in the freecad document"
|
||||
try:
|
||||
if shape:
|
||||
# use ifcopenshell
|
||||
site = Arch.makeSite(name=name)
|
||||
site.Label = name
|
||||
body = FreeCAD.ActiveDocument.addObject("Part::Feature",name+"_body")
|
||||
body.Shape = shape
|
||||
site.Terrain = body
|
||||
if DEBUG: print "made site object ",entity,":",site
|
||||
return site
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
def makeRoof(entity,shape=None,name="Roof"):
|
||||
"makes a roof in the freecad document"
|
||||
try:
|
||||
if shape:
|
||||
# use ifcopenshell
|
||||
roof = Arch.makeRoof(name=name)
|
||||
roof.Label = name
|
||||
roof.Shape = shape
|
||||
if DEBUG: print "made roof object ",entity,":",roof
|
||||
return roof
|
||||
except:
|
||||
return None
|
||||
|
||||
# geometry helpers ###################################################################
|
||||
|
||||
def getMesh(obj):
|
||||
"gets mesh and placement from an IfcOpenShell object"
|
||||
import Mesh
|
||||
f = obj.mesh.faces
|
||||
v = obj.mesh.verts
|
||||
for i in range(0, len(f), 3):
|
||||
face = []
|
||||
for j in range(3):
|
||||
vi = f[i+j]*3
|
||||
face.append([v[vi],v[vi+1],v[vi+2]])
|
||||
meshdata.append(face)
|
||||
me = Mesh.Mesh(meshdata)
|
||||
# get transformation matrix
|
||||
m = obj.matrix
|
||||
mat = FreeCAD.Matrix(m[0], m[3], m[6], m[9],
|
||||
m[1], m[4], m[7], m[10],
|
||||
m[2], m[5], m[8], m[11],
|
||||
0, 0, 0, 1)
|
||||
pl = FreeCAD.Placement(mat)
|
||||
return me,pl
|
||||
|
||||
def getShape(obj):
|
||||
"gets a shape from an IfcOpenShell object"
|
||||
import StringIO,Part
|
||||
sh=Part.Shape()
|
||||
sh.importBrep(StringIO.StringIO(obj.mesh.brep_data))
|
||||
if not sh.Solids:
|
||||
# try to extract a solid shape
|
||||
if sh.Faces:
|
||||
try:
|
||||
if DEBUG: print "Malformed solid. Attempting to fix..."
|
||||
shell = Part.makeShell(sh.Faces)
|
||||
if shell:
|
||||
solid = Part.makeSolid(shell)
|
||||
if solid:
|
||||
sh = solid
|
||||
except:
|
||||
if DEBUG: print "failed to retrieve solid from object ",obj.id
|
||||
else:
|
||||
if DEBUG: print "object ", obj.id, " doesn't contain any face"
|
||||
m = obj.matrix
|
||||
mat = FreeCAD.Matrix(m[0], m[3], m[6], m[9],
|
||||
m[1], m[4], m[7], m[10],
|
||||
m[2], m[5], m[8], m[11],
|
||||
0, 0, 0, 1)
|
||||
sh.Placement = FreeCAD.Placement(mat)
|
||||
# if DEBUG: print "getting Shape from ",obj
|
||||
return sh
|
||||
|
||||
# below is only used by the internal parser #########################################
|
||||
|
||||
def decode(name):
|
||||
"decodes encoded strings"
|
||||
try:
|
||||
|
@ -94,151 +520,11 @@ def getSchema():
|
|||
p = ArchCommands.download(SCHEMA)
|
||||
if p:
|
||||
return p
|
||||
return None
|
||||
|
||||
def getIfcOpenShell():
|
||||
"locates and imports ifcopenshell"
|
||||
try:
|
||||
global IfcImport
|
||||
import IfcImport
|
||||
except:
|
||||
FreeCAD.Console.PrintMessage(str(translate("Arch","Couldn't locate IfcOpenShell\n")))
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def read(filename):
|
||||
"Parses an IFC file"
|
||||
|
||||
# parsing the IFC file
|
||||
t1 = time.time()
|
||||
schema=getSchema()
|
||||
ifcRel = {}
|
||||
if schema:
|
||||
if DEBUG: global ifc
|
||||
if DEBUG: print "opening",filename,"..."
|
||||
ifc = ifcReader.IfcDocument(filename,schema=schema,debug=DEBUG)
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning(str(translate("Arch","IFC Schema not found, IFC import disabled.\n")))
|
||||
return None
|
||||
t2 = time.time()
|
||||
if DEBUG: print "Successfully loaded",ifc,"in %s s" % ((t2-t1))
|
||||
return None
|
||||
|
||||
if useIfcOpenShell and getIfcOpenShell():
|
||||
# use the IfcOpenShell parser
|
||||
|
||||
useShapes = False
|
||||
if hasattr(IfcImport,"USE_BREP_DATA"):
|
||||
IfcImport.Settings(IfcImport.USE_BREP_DATA,True)
|
||||
useShapes = True
|
||||
if IfcImport.Init(filename):
|
||||
while True:
|
||||
|
||||
obj = IfcImport.Get()
|
||||
if DEBUG: print "parsing ",obj.id,": ",obj.name," of type ",obj.type
|
||||
meshdata = []
|
||||
|
||||
# retrieving name
|
||||
n = obj.name
|
||||
if not n:
|
||||
n = ""
|
||||
|
||||
# build shape
|
||||
shape = None
|
||||
if useShapes:
|
||||
shape = getShape(obj)
|
||||
|
||||
# skip types
|
||||
if obj.type in SKIP:
|
||||
pass
|
||||
|
||||
# walls
|
||||
elif obj.type == "IfcWallStandardCase":
|
||||
nobj = makeWall(ifc.Entities[obj.id],shape,n)
|
||||
|
||||
# windows
|
||||
elif obj.type in ["IfcWindow","IfcDoor"]:
|
||||
nobj = makeWindow(ifc.Entities[obj.id],shape,n)
|
||||
|
||||
# structs
|
||||
elif obj.type in ["IfcBeam","IfcColumn","IfcSlab","IfcFooting"]:
|
||||
nobj = makeStructure(ifc.Entities[obj.id],shape,n)
|
||||
|
||||
# furniture
|
||||
elif obj.type == "IfcFurnishingElement":
|
||||
nobj = FreeCAD.ActiveDocument.addObject("Part::Feature",n)
|
||||
nobj.Shape = shape
|
||||
|
||||
elif shape:
|
||||
# treat as dumb parts
|
||||
if not n:
|
||||
n = "Unnamed"
|
||||
nobj = FreeCAD.ActiveDocument.addObject("Part::Feature",n)
|
||||
nobj.Shape = shape
|
||||
|
||||
else:
|
||||
# treat as meshes
|
||||
if not n:
|
||||
n = "Unnamed"
|
||||
me,pl = getMesh(obj)
|
||||
nobj = FreeCAD.ActiveDocument.addObject("Mesh::Feature",n)
|
||||
nobj.Mesh = me
|
||||
nobj.Placement = pl
|
||||
|
||||
ifcRel[obj.id] = nobj
|
||||
|
||||
# mark terrain objects so they can be associated to sites
|
||||
if obj.type == "IfcSite":
|
||||
if not "terrains" in ifcRel:
|
||||
ifcRel["terrains"] = []
|
||||
ifcRel["terrains"].append([obj.id,nobj])
|
||||
|
||||
if not IfcImport.Next():
|
||||
break
|
||||
|
||||
IfcImport.CleanUp()
|
||||
|
||||
else:
|
||||
# use only the internal python parser
|
||||
|
||||
# getting walls
|
||||
for w in ifc.getEnt("IfcWallStandardCase"):
|
||||
nobj = makeWall(w)
|
||||
ifcRel[w.id] = nobj
|
||||
|
||||
# getting windows and doors
|
||||
for w in (ifc.getEnt("IfcWindow") + ifc.getEnt("IfcDoor")):
|
||||
nobj = makeWindow(w)
|
||||
ifcRel[w.id] = nobj
|
||||
|
||||
# getting structs
|
||||
for w in (ifc.getEnt("IfcSlab") + ifc.getEnt("IfcBeam") + ifc.getEnt("IfcColumn") \
|
||||
+ ifc.getEnt("IfcFooting")):
|
||||
nobj = makeStructure(w)
|
||||
ifcRel[w.id] = nobj
|
||||
|
||||
order(ifc,ifcRel)
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
t3 = time.time()
|
||||
if DEBUG: print "done processing",ifc,"in %s s" % ((t3-t1))
|
||||
|
||||
return None
|
||||
|
||||
def order(ifc,ifcRel):
|
||||
"orders the already generated elements by building and by floor"
|
||||
|
||||
# getting floors
|
||||
for f in ifc.getEnt("IfcBuildingStorey"):
|
||||
group(f,ifcRel,"Floor")
|
||||
# getting buildings
|
||||
for b in ifc.getEnt("IfcBuilding"):
|
||||
group(b,ifcRel,"Building")
|
||||
# getting sites
|
||||
for s in ifc.getEnt("IfcSite"):
|
||||
group(s,ifcRel,"Site")
|
||||
|
||||
def group(entity,ifcRel,mode=None):
|
||||
def group(entity,ifc,mode=None):
|
||||
"gathers the children of the given entity"
|
||||
# only used by internal parser
|
||||
|
||||
try:
|
||||
if DEBUG: print "=====> making group",entity.id
|
||||
|
@ -274,14 +560,12 @@ def group(entity,ifcRel,mode=None):
|
|||
for g in groups:
|
||||
for t in g[1]:
|
||||
if e.type.upper() == t.upper():
|
||||
if e.id in ifcRel:
|
||||
g[2].append(ifcRel[e.id])
|
||||
elif hasattr(FreeCAD.ActiveDocument,g[0]+str(e.id)):
|
||||
if hasattr(FreeCAD.ActiveDocument,g[0]+str(e.id)):
|
||||
g[2].append(FreeCAD.ActiveDocument.getObject(g[0]+str(e.id)))
|
||||
print "groups:",groups
|
||||
|
||||
comps = []
|
||||
if createIfcGroups:
|
||||
if CREATE_IFC_GROUPS:
|
||||
if DEBUG: print "creating subgroups"
|
||||
for g in groups:
|
||||
if g[2]:
|
||||
|
@ -301,12 +585,6 @@ def group(entity,ifcRel,mode=None):
|
|||
cell = None
|
||||
if mode == "Site":
|
||||
cell = Arch.makeSite(comps,name=name)
|
||||
# add terrain object
|
||||
if "terrains" in ifcRel:
|
||||
for t in ifcRel["terrains"]:
|
||||
if t[0] == entity.id:
|
||||
if not t[1] in comps:
|
||||
cell.Terrain = t[1]
|
||||
elif mode == "Floor":
|
||||
cell = Arch.makeFloor(comps,name=name)
|
||||
elif mode == "Building":
|
||||
|
@ -314,171 +592,11 @@ def group(entity,ifcRel,mode=None):
|
|||
if label and cell:
|
||||
cell.Label = label
|
||||
except:
|
||||
if DEBUG: print "error: skipping group ",entity.id
|
||||
|
||||
def makeWall(entity,shape=None,name=None):
|
||||
"makes a wall in the freecad document"
|
||||
try:
|
||||
if DEBUG: print "=====> making wall",entity.id
|
||||
if shape:
|
||||
# use ifcopenshell
|
||||
sh = FreeCAD.ActiveDocument.addObject("Part::Feature","WallBody")
|
||||
sh.Shape = shape
|
||||
wall = Arch.makeWall(sh,name="Wall"+str(entity.id))
|
||||
wall.Label = name
|
||||
if DEBUG: print "made wall object ",entity.id,":",wall
|
||||
return wall
|
||||
# use internal parser
|
||||
placement = wall = wire = body = width = height = None
|
||||
placement = getPlacement(entity.ObjectPlacement)
|
||||
if DEBUG: print "got wall placement",entity.id,":",placement
|
||||
width = entity.getProperty("Width")
|
||||
height = entity.getProperty("Height")
|
||||
if width and height:
|
||||
if DEBUG: print "got width, height ",entity.id,":",width,"/",height
|
||||
for r in entity.Representation.Representations:
|
||||
if r.RepresentationIdentifier == "Axis":
|
||||
wire = getWire(r.Items,placement)
|
||||
wall = Arch.makeWall(wire,width,height,align="Center",name="Wall"+str(entity.id))
|
||||
if name:
|
||||
wall.Label = name
|
||||
else:
|
||||
if DEBUG: print "no height or width properties found..."
|
||||
for r in entity.Representation.Representations:
|
||||
if r.RepresentationIdentifier == "Body":
|
||||
for b in r.Items:
|
||||
if b.type == "IFCEXTRUDEDAREASOLID":
|
||||
norm = getVector(b.ExtrudedDirection)
|
||||
norm.normalize()
|
||||
wire = getWire(b.SweptArea,placement)
|
||||
wall = Arch.makeWall(wire,width=0,height=b.Depth,name="Wall"+str(entity.id))
|
||||
wall.Normal = norm
|
||||
if wall:
|
||||
if DEBUG: print "made wall object ",entity.id,":",wall
|
||||
return wall
|
||||
if DEBUG: print "error: skipping wall",entity.id
|
||||
return None
|
||||
except:
|
||||
if DEBUG: print "error: skipping wall",entity.id
|
||||
return None
|
||||
|
||||
|
||||
def makeWindow(entity,shape=None,name=""):
|
||||
"makes a window in the freecad document"
|
||||
try:
|
||||
typ = "Window" if entity.type == "IFCWINDOW" else "Door"
|
||||
if DEBUG: print "=====> making window",entity.id
|
||||
if shape:
|
||||
# use ifcopenshell
|
||||
window = Arch.makeWindow(name=typ+str(entity.id))
|
||||
window.Shape = shape
|
||||
if name:
|
||||
window.Label = name
|
||||
if DEBUG: print "made window object ",entity.id,":",window
|
||||
return window
|
||||
# use internal parser
|
||||
placement = window = wire = body = width = height = None
|
||||
placement = getPlacement(entity.ObjectPlacement)
|
||||
if DEBUG: print "got window placement",entity.id,":",placement
|
||||
width = entity.getProperty("Width")
|
||||
height = entity.getProperty("Height")
|
||||
for r in entity.Representation.Representations:
|
||||
if r.RepresentationIdentifier == "Body":
|
||||
for b in r.Items:
|
||||
if b.type == "IFCEXTRUDEDAREASOLID":
|
||||
wire = getWire(b.SweptArea,placement)
|
||||
window = Arch.makeWindow(wire,width=b.Depth,name=typ+str(entity.id))
|
||||
if window:
|
||||
if DEBUG: print "made window object ",entity.id,":",window
|
||||
return window
|
||||
if DEBUG: print "error: skipping window",entity.id
|
||||
return None
|
||||
except:
|
||||
if DEBUG: print "error: skipping window",entity.id
|
||||
return None
|
||||
|
||||
def makeStructure(entity,shape=None,name=""):
|
||||
"makes a structure in the freecad document"
|
||||
try:
|
||||
if entity.type == "IFCSLAB":
|
||||
typ = "Slab"
|
||||
elif entity.type == "IFCBEAM":
|
||||
typ = "Beam"
|
||||
elif entity.type == "IFCFOOTING":
|
||||
typ = "Footing"
|
||||
else:
|
||||
typ = "Column"
|
||||
|
||||
if DEBUG: print "=====> making struct",entity.id
|
||||
if shape:
|
||||
# use ifcopenshell
|
||||
sh = FreeCAD.ActiveDocument.addObject("Part::Feature","StructureBody")
|
||||
sh.Shape = shape
|
||||
structure = Arch.makeStructure(sh,name=typ+str(entity.id))
|
||||
if name:
|
||||
structure.Label = name
|
||||
if DEBUG: print "made structure object ",entity.id,":",structure
|
||||
return structure
|
||||
# use internal parser
|
||||
placement = structure = wire = body = width = height = None
|
||||
placement = getPlacement(entity.ObjectPlacement)
|
||||
if DEBUG: print "got window placement",entity.id,":",placement
|
||||
width = entity.getProperty("Width")
|
||||
height = entity.getProperty("Height")
|
||||
for r in entity.Representation.Representations:
|
||||
if r.RepresentationIdentifier == "Body":
|
||||
for b in r.Items:
|
||||
if b.type == "IFCEXTRUDEDAREASOLID":
|
||||
wire = getWire(b.SweptArea,placement)
|
||||
structure = Arch.makeStructure(wire,height=b.Depth,name=typ+str(entity.id))
|
||||
if structure:
|
||||
if DEBUG: print "made structure object ",entity.id,":",structure
|
||||
return structure
|
||||
if DEBUG: print "error: skipping structure",entity.id
|
||||
return None
|
||||
except:
|
||||
if DEBUG: print "error: skipping structure",entity.id
|
||||
return None
|
||||
|
||||
# geometry helpers ###################################################################
|
||||
|
||||
def getMesh(obj):
|
||||
"gets mesh and placement from an IfcOpenShell object"
|
||||
import Mesh
|
||||
f = obj.mesh.faces
|
||||
v = obj.mesh.verts
|
||||
for i in range(0, len(f), 3):
|
||||
face = []
|
||||
for j in range(3):
|
||||
vi = f[i+j]*3
|
||||
face.append([v[vi],v[vi+1],v[vi+2]])
|
||||
meshdata.append(face)
|
||||
me = Mesh.Mesh(meshdata)
|
||||
# get transformation matrix
|
||||
m = obj.matrix
|
||||
mat = FreeCAD.Matrix(m[0], m[3], m[6], m[9],
|
||||
m[1], m[4], m[7], m[10],
|
||||
m[2], m[5], m[8], m[11],
|
||||
0, 0, 0, 1)
|
||||
pl = FreeCAD.Placement(mat)
|
||||
return me,pl
|
||||
|
||||
def getShape(obj):
|
||||
"gets a shape from an IfcOpenShell object"
|
||||
import StringIO
|
||||
sh=Part.Shape()
|
||||
sh.importBrep(StringIO.StringIO(obj.mesh.brep_data))
|
||||
m = obj.matrix
|
||||
mat = FreeCAD.Matrix(m[0], m[3], m[6], m[9],
|
||||
m[1], m[4], m[7], m[10],
|
||||
m[2], m[5], m[8], m[11],
|
||||
0, 0, 0, 1)
|
||||
sh.Placement = FreeCAD.Placement(mat)
|
||||
if DEBUG: print "getting Shape from ",obj
|
||||
return sh
|
||||
if DEBUG: print "error: skipping group ",entity.id
|
||||
|
||||
def getWire(entity,placement=None):
|
||||
"returns a wire (created in the freecad document) from the given entity"
|
||||
# only used by internal parser
|
||||
if DEBUG: print "making Wire from :",entity
|
||||
if not entity: return None
|
||||
if entity.type == "IFCPOLYLINE":
|
||||
|
@ -494,6 +612,7 @@ def getWire(entity,placement=None):
|
|||
|
||||
def getPlacement(entity):
|
||||
"returns a placement from the given entity"
|
||||
# only used by internal parser
|
||||
if DEBUG: print "getting placement ",entity
|
||||
if not entity: return None
|
||||
pl = None
|
||||
|
@ -521,6 +640,7 @@ def getPlacement(entity):
|
|||
|
||||
def getVector(entity):
|
||||
"returns a vector from the given entity"
|
||||
# only used by internal parser
|
||||
if DEBUG: print "getting point from",entity
|
||||
if entity.type == "IFCDIRECTION":
|
||||
if len(entity.DirectionRatios) == 3:
|
||||
|
|
Loading…
Reference in New Issue
Block a user