Example #1
0
def unjoin(pairs):
    # print(pairs)

    # rng = range(len(selection))
    # checked_pairs = []
    # joined_pairs = []
    c = 0

    # for x in rng:
    #     for y in rng:
    #         if x == y:
    #             continue
    #         _p = sorted([x,y])
    #         _t = (_p[0],_p[1])
    #         if _t in checked_pairs:
    #             continue

    #         checked_pairs.append(_t)
    #         eid1 = selection[_p[0]]
    #         eid2 = selection[_p[1]]
    #         e1,e2 = doc.GetElement(eid1),doc.GetElement(eid2)
    #         joined = JoinGeometryUtils.AreElementsJoined(doc,e1,e2)
    #         if joined:
    #             joined_pairs.append((e1,e2))

    if len(pairs) > 0:
        t = Transaction(doc)
        t.Start("UnjoinSelected")
        for p in pairs:
            e1 = doc.GetElement(ElementId(p[0]))
            e2 = doc.GetElement(ElementId(p[1]))
            joined = JoinGeometryUtils.AreElementsJoined(doc, e1, e2)
            if joined:

                JoinGeometryUtils.UnjoinGeometry(doc, e1, e2)
                c += 1
        t.Commit()
    TaskDialog.Show("R", "%d пар элементов разъединены" % c)
    for elem in walls + floors + generic + roofs:
        minpoint = elem.get_BoundingBox(doc.ActiveView).Min
        maxpoint = elem.get_BoundingBox(doc.ActiveView).Max
        els = FilteredElementCollector(doc).OfCategory(
            BuiltInCategory.OST_StructuralFraming).WherePasses(
                BoundingBoxIntersectsFilter(Outline(
                    minpoint,
                    maxpoint))).WhereElementIsNotElementType().ToElements()
        if res == "Соединить":
            for el in els:
                if not JoinGeometryUtils.AreElementsJoined(doc, el, elem):
                    JoinGeometryUtils.JoinGeometry(doc, el, elem)
        elif res == "Отменить соединение":
            for el in els:
                if JoinGeometryUtils.AreElementsJoined(doc, el, elem):
                    JoinGeometryUtils.UnjoinGeometry(doc, el, elem)

else:
    if len(sel) == 1:
        target = sel[0]
        cutting_ids = uidoc.Selection.PickObjects(
            ObjectType.Element,
            'Выберите элементы, которые будут вырезаны из целевого')
        cutting_els = [doc.GetElement(elid.ElementId) for elid in cutting_ids]
        for el in cutting_els:
            if SolidSolidCutUtils.CanElementCutElement(target, el):
                SolidSolidCutUtils.AddCutBetweenSolids(doc, target, el)
    else:
        targets = sel
        cutting_id = uidoc.Selection.PickObject(
            ObjectType.Element,
				els_sol_fil_flat = flatten_List(elems_solid_filter)
				for els in els_sol_fil_flat:
					if els.Id.ToString() == i1.Id.ToString():
						pass
					else:
						if JoinGeometryUtils.AreElementsJoined(doc,els,i1):
							pass
						else:
							results += join(els,i1)
	TransactionManager.Instance.ForceCloseTransaction()
	#endregion
else:
	results = 0
	#region разделение геометрии
	items1 = flatten_List(elements)
	TransactionManager.Instance.EnsureInTransaction(doc)
	for i in items1:
		test = JoinGeometryUtils.GetJoinedElements(doc, i)
		if test:
			for t in test:
				JoinGeometryUtils.UnjoinGeometry(doc,i,doc.GetElement(t))
				results += 1
	TransactionManager.Instance.ForceCloseTransaction()
	#endregion
#endregion
t = time.stop()
if IN[1]:
	OUT = "Join elements = " + str(results), "Minutes, Seconds, Milliseconds = ", [t.Minutes, t.Seconds, t.Milliseconds]
else:
	OUT = "Unjoin elements = " + str(results), "Minutes, Seconds, Milliseconds = ", [t.Minutes, t.Seconds, t.Milliseconds]
Example #4
0
output = pyrevit.output.get_output()
tab = ' '
# input ---------------------
cate = []
sel_warning = ()
outprint = script.get_output()
path = 'C:\\Users\\loum\\Documents\\Pyscripts\\ClashScripts\\'
# t = Transaction(doc, 'Correct Lines')
# t.Start()
if revit.doc.IsWorkshared:
    warnings = doc.GetWarnings()
# select selected warnings
    for warning in warnings:
        selection = []
        elementId = warning.GetFailingElements()
        additionalId = warning.GetAdditionalElements()
        text = warning.GetDescriptionText()
        t = Transaction(doc, 'Unjoin Elements (STVTools)')

        if 'joined but do not intersect' in text:
            print('Found Warning')
            for e in elementId:
                print(doc.GetElement(e))
                for a in additionalId:
                    print(doc.GetElement(a))
                    t.Start()
                    JoinGeometryUtils.UnjoinGeometry(doc, doc.GetElement(e), doc.GetElement(a))
                    t.Commit()
                    print('Success')

Example #5
0
def UnjoinElement(element):
    from Autodesk.Revit.DB import JoinGeometryUtils
    joined = JoinGeometryUtils.GetJoinedElements(doc, element)
    for e in joined:
        secondElement = doc.GetElement(e)
        JoinGeometryUtils.UnjoinGeometry(doc, element, secondElement)
Example #6
0
checked_pairs = []
joined_pairs = []
c = 0

for x in rng:
    for y in rng:
        if x == y:
            continue
        _p = sorted([x,y])
        _t = (_p[0],_p[1])
        if _t in checked_pairs:
            continue

        checked_pairs.append(_t)
        eid1 = selected_ids[_p[0]]
        eid2 = selected_ids[_p[1]]
        e1,e2 = doc.GetElement(eid1),doc.GetElement(eid2)
        joined = JoinGeometryUtils.AreElementsJoined(doc,e1,e2)
        if joined:
            joined_pairs.append((e1,e2))

if len(joined_pairs) > 0:
    t = Transaction(doc)
    t.Start(__title__)
    for p in joined_pairs:
        JoinGeometryUtils.UnjoinGeometry(doc,p[0],p[1])
        c+=1
    t.Commit()

TaskDialog.Show(__title__,"%d pairs of elements unjoined" % c)