From eceebf4d71b6f1540bcbbb49e5682a77fc8291b1 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 4 Jan 2014 11:30:15 -0200 Subject: [PATCH 1/2] Arch: Fixes to ifc importer to make it compatible with ifcopenshell 0.4 --- src/Mod/Arch/importIFC.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 13ca34350..325e13dd6 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -170,7 +170,10 @@ def read(filename): objparentid = int(str(getAttr(r,"RelatingBuildingElement")).split("=")[0].strip("#")) else: - obj = IfcImport.Get() + if hasattr(IfcImport, 'GetBrepData'): + obj = IfcImport.GetBrepData() + else: + obj = IfcImport.Get() objid = obj.id idx = objid objname = obj.name @@ -244,13 +247,18 @@ def read(filename): else: # treat as meshes - if DEBUG: print "Warning: Object without shape: ",objid, " ", objtype - me,pl = getMesh(obj) - nobj = FreeCAD.ActiveDocument.addObject("Mesh::Feature",n) - nobj.Label = n - nobj.Mesh = me - nobj.Placement = pl - + if DEBUG: print "Warning: Object without shape: ",objid, " ", objtype + if hasattr(obj,"mesh"): + if not hasattr(obj.mesh, 'verts'): + obj = IfcImport.Get() # Get triangulated rep of same product + me,pl = getMesh(obj) + nobj = FreeCAD.ActiveDocument.addObject("Mesh::Feature",n) + nobj.Label = n + nobj.Mesh = me + nobj.Placement = pl + else: + if DEBUG: print "Error: Skipping object without mesh: ",objid, " ", objtype + # registering object number and parent if objparentid > 0: ifcParents[objid] = [objparentid,not (objtype in subtractiveTypes)] From 9c3d1a80d4d070f449d90f15353f0c45742a0011 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 4 Jan 2014 22:07:30 -0200 Subject: [PATCH 2/2] Draft: allow makePoint to take a vector --- src/Mod/Draft/Draft.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 1d7c4a9f5..e26053dc8 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -1995,7 +1995,9 @@ def makeSketch(objectslist,autoconstraints=False,addTo=None,delete=False,name="S return nobj def makePoint(X=0, Y=0, Z=0,color=None,name = "Point", point_size= 5): - ''' make a point (at coordinates x,y,z ,color(r,g,b),point_size) + ''' makePoint(x,y,z ,[color(r,g,b),point_size]) or + makePoint(Vector,color(r,g,b),point_size]) - + creates a Point in the current document. example usage: p1 = makePoint() p1.ViewObject.Visibility= False # make it invisible @@ -2006,6 +2008,10 @@ def makePoint(X=0, Y=0, Z=0,color=None,name = "Point", point_size= 5): p1.ViewObject.PointColor =(0.0,0.0,1.0) #change the color-make sure values are floats ''' obj=FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) + if isinstance(X,FreeCAD.Vector): + Z = X.z + Y = X.y + X = X.x _Point(obj,X,Y,Z) obj.X = X obj.Y = Y