@@ -42,25 +42,48 @@ def polyline(self, points, closed=False, position_offset=None):
4242 segments .append ( (len (points ),1 ) )
4343 if position_offset :
4444 points = [Vector (p ) + position_offset for p in points ]
45- ifc_points = self .ifc .createIfcCartesianPointList2D (points )
45+
46+ dimensions = len (points [0 ])
47+ if dimensions == 2 :
48+ ifc_points = self .ifc .createIfcCartesianPointList2D (points )
49+ elif dimensions == 3 :
50+ ifc_points = self .ifc .createIfcCartesianPointList3D (points )
51+
4652 ifc_segments = [ self .ifc .createIfcLineIndex ( segment ) for segment in segments ]
4753 ifc_curve = self .ifc .createIfcIndexedPolyCurve (Points = ifc_points , Segments = ifc_segments )
4854 return ifc_curve
4955
5056 def get_rectangle_coords (self ,
5157 size :Vector = Vector ( (1. , 1. ) ).freeze (),
52- position :Vector = Vector ( (0. , 0. ) ).freeze ()):
58+ position :Vector = None ):
59+
60+ dimensions = len (size )
61+
62+ if not position :
63+ position = Vector ([0 ]* dimensions )
64+
65+ # adds support both 2d and 3d sizes
66+ non_empty_coords = [i for i , v in enumerate (size ) if v ]
67+ id_matrix = Matrix .Identity (dimensions )
68+
5369 points = [
5470 position ,
55- position + size * Vector ( ( 0 , 1 )) ,
71+ position + size * id_matrix [ non_empty_coords [ 0 ]] ,
5672 position + size ,
57- position + size * Vector ( ( 1 , 0 ))
73+ position + size * id_matrix [ non_empty_coords [ 1 ]]
5874 ]
5975 return points
6076
6177 def rectangle (self ,
6278 size :Vector = Vector ( (1. , 1. ) ).freeze (),
63- position :Vector = Vector ( (0. , 0. ) ).freeze ()):
79+ position :Vector = None ):
80+ """
81+ function supports both 2d and 3d rectangle sizes
82+
83+ if `position` not specified zero-vector will be used
84+
85+ returns IfcIndexedPolyCurve
86+ """
6487 # < IfcIndexedPolyCurve
6588 return self .polyline (self .get_rectangle_coords (size , position ), closed = True )
6689
0 commit comments