diff --git a/src/compas_timber/ghpython/components/CT_Model/code.py b/src/compas_timber/ghpython/components/CT_Model/code.py index 18888eb63..baa5ff000 100644 --- a/src/compas_timber/ghpython/components/CT_Model/code.py +++ b/src/compas_timber/ghpython/components/CT_Model/code.py @@ -125,19 +125,14 @@ def RunScript(self, Elements, JointRules, Features, MaxDistance, CreateGeometry) Model = TimberModel() debug_info = DebugInfomation() beams = [] - plates = [] for element in Elements: if element is None: continue element.remove_features() element.debug_info = [] Model.add_element(element) - if element.__class__.__name__ == "Plate": - plates.append(element) - elif element.__class__.__name__ == "Beam": - beams.append(element) - for beam in beams: + for beam in Model.beams: # prepare elements for downstream processing beam.remove_blank_extension() topologies = [] @@ -150,8 +145,7 @@ def RunScript(self, Elements, JointRules, Features, MaxDistance, CreateGeometry) topologies.append({"detected_topo": detected_topo, "beam_a": beam_a, "beam_b": beam_b}) Model.set_topologies(topologies) - beams = Model.beams - joints = self.get_joints_from_rules(beams, JointRules, topologies) + joints = self.get_joints_from_rules(Model.beams, JointRules, topologies) if joints: handled_beams = [] diff --git a/src/compas_timber/model/model.py b/src/compas_timber/model/model.py index 2925d2d3c..10a85d037 100644 --- a/src/compas_timber/model/model.py +++ b/src/compas_timber/model/model.py @@ -119,6 +119,19 @@ def beam_by_guid(self, guid): """ return self._guid_element[guid] + def add_element(self, element, **kwargs): + node = super(TimberModel, self).add_element(element, **kwargs) + + if isinstance(element, Beam): + self._beams.append(element) + elif isinstance(element, Wall): + self._walls.append(element) + elif isinstance(element, Plate): + self._plates.append(element) + else: + raise NotImplementedError("Element type not supported: {}".format(type(element))) + return node + def add_beam(self, beam): # type: (Beam) -> None """Adds a Beam to this model.