Skip to content

Commit

Permalink
Arch: General improvements
Browse files Browse the repository at this point in the history
* Removed roundings in exported objects
* Added toggleIfcBrepFlag command to force export as BREP
* Prepared Arch objects for Materials and custom IFC attributes
* Supported latest developement version of IfcOpenShell
* Cleanup of IFC exporter
* Export of Arch Sites as IfcSite
* Export of Groups as IfcGroup
  • Loading branch information
yorikvanhavre committed Jul 15, 2014
1 parent d456cd2 commit 7f387ea
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 261 deletions.
38 changes: 36 additions & 2 deletions src/Mod/Arch/ArchCommands.py
Expand Up @@ -600,7 +600,7 @@ def check(objectslist,includehidden=False):
def getTuples(data,scale=1,placement=None,normal=None,close=True):
"""getTuples(data,[scale,placement,normal,close]): returns a tuple or a list of tuples from a vector
or from the vertices of a shape. Scale can indicate a scale factor"""
rnd = True
rnd = False
import Part
if isinstance(data,FreeCAD.Vector):
if placement:
Expand Down Expand Up @@ -944,8 +944,26 @@ def survey(callback=False):
FreeCAD.SurveyObserver.selection.extend(newsels)


def toggleIfcBrepFlag(obj):
"""toggleIfcBrepFlag(obj): toggles the IFC brep flag of the given object, forcing it
to be exported as brep geometry or not."""
if not hasattr(obj,"IfcAttributes"):
FreeCAD.Console.PrintMessage(translate("Arch","Object doesn't have settable IFC Attributes"))
else:
d = obj.IfcAttributes
if "ForceBrep" in d.keys():
if d["ForceBrep"] == "True":
d["ForceBrep"] = "False"
FreeCAD.Console.PrintMessage(translate("Arch","Disabling Brep force flag of object")+" "+obj.Label+"\n")
else:
d["ForceBrep"] = "True"
FreeCAD.Console.PrintMessage(translate("Arch","Enabling Brep force flag of object")+" "+obj.Label+"\n")
else:
d["ForceBrep"] = "True"
FreeCAD.Console.PrintMessage(translate("Arch","Enabling Brep force flag of object")+" "+obj.Label+"\n")
obj.IfcAttributes = d



# command definitions ###############################################

class _CommandAdd:
Expand Down Expand Up @@ -1183,6 +1201,21 @@ def Activated(self):
FreeCADGui.doCommand("Arch.survey()")


class _ToggleIfcBrepFlag:
"the Toggle IFC Brep flag command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_ToggleIfcBrepFlag',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_ToggleIfcBrepFlag","Toggle IFC Brep flag"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_ToggleIfcBrepFlag","Force an object to be exported as Brep or not")}

def IsActive(self):
return bool(FreeCADGui.Selection.getSelection())

def Activated(self):
for o in FreeCADGui.Selection.getSelection():
toggleIfcBrepFlag(o)


if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Add',_CommandAdd())
FreeCADGui.addCommand('Arch_Remove',_CommandRemove())
Expand All @@ -1194,3 +1227,4 @@ def Activated(self):
FreeCADGui.addCommand('Arch_Check',_CommandCheck())
FreeCADGui.addCommand('Arch_IfcExplorer',_CommandIfcExplorer())
FreeCADGui.addCommand('Arch_Survey',_CommandSurvey())
FreeCADGui.addCommand('Arch_ToggleIfcBrepFlag',_ToggleIfcBrepFlag())
15 changes: 10 additions & 5 deletions src/Mod/Arch/ArchComponent.py
Expand Up @@ -25,6 +25,11 @@
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"

# Possible roles for IFC objects
Roles = ['Undefined','Beam','Chimney','Column','Covering','Curtain Wall','Door','Foundation',
'Member','Plate','Railing','Ramp','Ramp Flight','Rebar','Pile','Roof','Shading Device','Slab',
'Stair','Stair Flight','Tendon','Wall','Wall Layer','Window']

import FreeCAD,Draft
from FreeCAD import Vector
if FreeCAD.GuiUp:
Expand Down Expand Up @@ -287,6 +292,8 @@ def __init__(self,obj):
obj.addProperty("App::PropertyLinkList","Subtractions","Arch","Other shapes that are subtracted from this object")
obj.addProperty("App::PropertyString","Description","Arch","An optional description for this component")
obj.addProperty("App::PropertyString","Tag","Arch","An optional tag for this component")
obj.addProperty("App::PropertyMap","IfcAttributes","Arch","Custom IFC properties and attributes")
obj.addProperty("App::PropertyMap","Material","Arch","A material for this object")
obj.Proxy = self
self.Type = "Component"
self.Subvolume = None
Expand Down Expand Up @@ -633,8 +640,7 @@ def attach(self,vobj):
return

def getDisplayModes(self,vobj):
modes=["Detailed"]
return modes
return []

def setDisplayMode(self,mode):
return mode
Expand All @@ -659,8 +665,6 @@ def claimChildren(self):
if Draft.getType(s) == "Roof":
continue
c.append(s)
if hasattr(self.Object,"Fixtures"):
c.extend(self.Object.Fixtures)
if hasattr(self.Object,"Armatures"):
c.extend(self.Object.Armatures)
if hasattr(self.Object,"Tool"):
Expand All @@ -679,7 +683,8 @@ def setEdit(self,vobj,mode):
def unsetEdit(self,vobj,mode):
FreeCADGui.Control.closeDialog()
return False



class ArchSelectionObserver:
"""ArchSelectionObserver([origin,watched,hide,nextCommand]): The ArchSelectionObserver
object can be added as a selection observer to the FreeCAD Gui. If watched is given (a
Expand Down
9 changes: 5 additions & 4 deletions src/Mod/Arch/ArchWindow.py
Expand Up @@ -35,11 +35,12 @@ def translate(ctxt,txt):
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"

# presets
WindowPartTypes = ["Frame","Solid panel","Glass panel"]
AllowedHosts = ["Wall","Structure","Roof"]
WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane",
"Sliding 2-pane", "Simple door", "Glass door"]
Roles = ["Window","Door"]
AllowedHosts = ["Wall","Structure","Roof"]
WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane",
"Sliding 2-pane", "Simple door", "Glass door"]
Roles = ["Window","Door"]


def makeWindow(baseobj=None,width=None,height=None,parts=None,name=translate("Arch","Window")):
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Arch/Arch_rc.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Mod/Arch/InitGui.py
Expand Up @@ -77,7 +77,7 @@ def Initialize(self):
self.utilities = ["Arch_SplitMesh","Arch_MeshToShape",
"Arch_SelectNonSolidMeshes","Arch_RemoveShape",
"Arch_CloseHoles","Arch_MergeWalls","Arch_Check",
"Arch_IfcExplorer"]
"Arch_IfcExplorer","Arch_ToggleIfcBrepFlag"]

# draft tools
self.drafttools = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc","Draft_Ellipse",
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Arch/Resources/Arch.qrc
Expand Up @@ -44,6 +44,7 @@
<file>icons/IFC.svg</file>
<file>icons/Arch_StructuralSystem.svg</file>
<file>icons/Arch_StructuralSystem_Tree.svg</file>
<file>icons/Arch_ToggleIfcBrepFlag.svg</file>
<file>ui/archprefs-base.ui</file>
<file>ui/archprefs-defaults.ui</file>
<file>ui/archprefs-import.ui</file>
Expand Down
106 changes: 106 additions & 0 deletions src/Mod/Arch/Resources/icons/Arch_ToggleIfcBrepFlag.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7f387ea

Please sign in to comment.