Merge pull request #9738 from yorikvanhavre/arch-nativeifc-provisions
Arch nativeifc provisions
This commit is contained in:
@@ -2368,7 +2368,7 @@ def getRepresentation(
|
||||
placement = ifcbin.createIfcLocalPlacement()
|
||||
representation = [ifcfile.createIfcShapeRepresentation(context,'Body',solidType,shapes)]
|
||||
# additional representations?
|
||||
if Draft.getType(obj) in ["Wall"]:
|
||||
if Draft.getType(obj) in ["Wall","Structure"]:
|
||||
addrepr = createAxis(ifcfile,obj,preferences)
|
||||
if addrepr:
|
||||
representation = representation + [addrepr]
|
||||
@@ -2477,9 +2477,14 @@ def getAxisContext(ifcfile):
|
||||
def createAxis(ifcfile,obj,preferences):
|
||||
"""Creates an axis for a given wall, if applicable"""
|
||||
|
||||
if hasattr(obj,"Base") and hasattr(obj.Base,"Shape") and obj.Base.Shape:
|
||||
if obj.Base.Shape.ShapeType in ["Wire","Edge"]:
|
||||
curve = createCurve(ifcfile,obj.Base.Shape,preferences["SCALE_FACTOR"])
|
||||
shape = None
|
||||
if getattr(obj,"Nodes",None):
|
||||
shape = Part.makePolygon([obj.Placement.multVec(v) for v in obj.Nodes])
|
||||
elif hasattr(obj,"Base") and hasattr(obj.Base,"Shape") and obj.Base.Shape:
|
||||
shape = obj.Base.Shape
|
||||
if shape:
|
||||
if shape.ShapeType in ["Wire","Edge"]:
|
||||
curve = createCurve(ifcfile,shape,preferences["SCALE_FACTOR"])
|
||||
if curve:
|
||||
ctx = getAxisContext(ifcfile)
|
||||
axis = ifcfile.createIfcShapeRepresentation(ctx,'Axis','Curve2D',[curve])
|
||||
|
||||
@@ -20,34 +20,29 @@
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
"""This module contains placeholders for viewproviders provided by the NativeIFC addon"""
|
||||
|
||||
import FreeCAD
|
||||
|
||||
class ifc_vp_object:
|
||||
"""NativeIFC class placeholder"""
|
||||
def __init__(self):
|
||||
pass
|
||||
def attach(self, vobj):
|
||||
return
|
||||
def getDisplayModes(self, obj):
|
||||
return []
|
||||
def getDefaultDisplayMode(self):
|
||||
return "FlatLines"
|
||||
def setDisplayMode(self,mode):
|
||||
return mode
|
||||
def __getstate__(self):
|
||||
return None
|
||||
def __setstate__(self, state):
|
||||
return None
|
||||
|
||||
class ifc_vp_document(ifc_vp_object):
|
||||
class ifc_vp_document:
|
||||
"""NativeIFC class placeholder"""
|
||||
def __init__(self):
|
||||
pass
|
||||
def attach(self, vobj):
|
||||
FreeCAD.Console.PrintWarning("Warning: Object "+vobj.Object.Label+" depends on the NativeIFC addon which is not installed, and will not display correctly in the 3D view\n")
|
||||
FreeCAD.Console.PrintWarning("Warning: Object "+vobj.Object.Label+" depends on the NativeIFC addon which is not installed, and might not display correctly in the 3D view\n")
|
||||
return
|
||||
|
||||
class ifc_vp_group:
|
||||
"""NativeIFC class placeholder"""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
class ifc_vp_material:
|
||||
"""NativeIFC class placeholder"""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@@ -123,33 +123,40 @@ def autogroup(obj):
|
||||
return
|
||||
|
||||
# autogroup code
|
||||
active_group = None
|
||||
if Gui.draftToolBar.autogroup is not None:
|
||||
active_group = App.ActiveDocument.getObject(Gui.draftToolBar.autogroup)
|
||||
if active_group:
|
||||
found = False
|
||||
for o in active_group.Group:
|
||||
if o.Name == obj.Name:
|
||||
found = True
|
||||
if not found:
|
||||
gr = active_group.Group
|
||||
gr = active_group.Group
|
||||
if not obj in gr:
|
||||
gr.append(obj)
|
||||
active_group.Group = gr
|
||||
|
||||
else:
|
||||
if Gui.ActiveDocument.ActiveView.getActiveObject("NativeIFC"):
|
||||
# NativeIFC handling
|
||||
try:
|
||||
import ifc_tools
|
||||
parent = Gui.ActiveDocument.ActiveView.getActiveObject("NativeIFC")
|
||||
if parent != active_group:
|
||||
ifc_tools.aggregate(obj, parent)
|
||||
except:
|
||||
pass
|
||||
|
||||
if Gui.ActiveDocument.ActiveView.getActiveObject("Arch"):
|
||||
# add object to active Arch Container
|
||||
active_arch_obj = Gui.ActiveDocument.ActiveView.getActiveObject("Arch")
|
||||
elif Gui.ActiveDocument.ActiveView.getActiveObject("Arch"):
|
||||
# add object to active Arch Container
|
||||
active_arch_obj = Gui.ActiveDocument.ActiveView.getActiveObject("Arch")
|
||||
if active_arch_obj != active_group:
|
||||
if obj in active_arch_obj.InListRecursive:
|
||||
# do not autogroup if obj points to active_arch_obj to prevent cyclic references
|
||||
return
|
||||
active_arch_obj.addObject(obj)
|
||||
|
||||
elif Gui.ActiveDocument.ActiveView.getActiveObject("part", False) is not None:
|
||||
# add object to active part and change it's placement accordingly
|
||||
# so object does not jump to different position, works with App::Link
|
||||
# if not scaled. Modified accordingly to realthunder suggestions
|
||||
active_part, parent, sub = Gui.ActiveDocument.ActiveView.getActiveObject("part", False)
|
||||
elif Gui.ActiveDocument.ActiveView.getActiveObject("part", False) is not None:
|
||||
# add object to active part and change it's placement accordingly
|
||||
# so object does not jump to different position, works with App::Link
|
||||
# if not scaled. Modified accordingly to realthunder suggestions
|
||||
active_part, parent, sub = Gui.ActiveDocument.ActiveView.getActiveObject("part", False)
|
||||
if active_part != active_group:
|
||||
if obj in active_part.InListRecursive:
|
||||
# do not autogroup if obj points to active_part to prevent cyclic references
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user