def join_s(x,y):
		try:
			JoinGeometryUtils.JoinGeometry(doc,x,y)
			JoinGeometryUtils.SwitchJoinOrder(doc,x,y)
			results = 1
		except:
			results = 0
		return results
Example #2
0
 def join_elements(self, elements_1, elements_2):
     "Присоединяет геометрию элементов"
     result = set()
     rebar_cat = Category.GetCategory(self.doc,
                                      BuiltInCategory.OST_Rebar).Name
     elements_1 = [
         i for i in elements_1 if i.element.Category.Name != rebar_cat
     ]
     elements_2 = [
         i for i in elements_2 if i.element.Category.Name != rebar_cat
     ]
     for element_1 in elements_1:
         for element_2 in elements_2:
             try:
                 res = BooleanOperationsUtils.ExecuteBooleanOperation(
                     element_2.union_solid, element_1.union_solid,
                     BooleanOperationsType.Difference)
                 if res.Volume < element_2.union_solid.Volume:
                     result.add(element_1)
                     try:
                         if not JoinGeometryUtils.AreElementsJoined(
                                 self.doc, element_2.element,
                                 element_1.element):
                             JoinGeometryUtils.JoinGeometry(
                                 self.doc, element_2.element,
                                 element_1.element)
                         if not JoinGeometryUtils.IsCuttingElementInJoin(
                                 self.doc, element_2.element,
                                 element_1.element):
                             JoinGeometryUtils.SwitchJoinOrder(
                                 self.doc, element_2.element,
                                 element_1.element)
                     except:
                         # echo("Ошибка в объединении {} с {}".format(element_1, element_2))
                         pass
             except InvalidOperationException:
                 result.add(element_1)
     return result