Mô tả lỗi

Lỗi xuất hiện khi có quá nhiều đường cong không khép kín được tạo ra , lỗi này phát hiện khi sử dụng đối tượng model in place chuyển đổi sang family với nhu cầu người dùng, tuy nhiên cái người dùng vẽ phức tạp không đơn giản như các cấu kiện thông thường.

Trường hợp 1 : Không lấy về được Geometry

trim with edge loops requires

Trường hợp 2 : Đường cong Arc nhận diện sai với tính toán vòng cung.

trim with edge loops requires fix2

Cách sửa lỗi

# Created By Karam Baki, karam@aecedx.vom
# Inspired By @5devene, dimitar.ven@gmail.com
# Clone Chuongmep.com
import clr
import System
from System.Collections.Generic import *
from itertools import repeat
pf_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86)
import sys
sys.path.append('%s\IronPython 2.7\Lib' %pf_path)
import traceback
import random
import string
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from Autodesk.DesignScript.Geometry import Point as DynPoint
from Autodesk.DesignScript.Geometry import Line as DynLine
from Autodesk.DesignScript.Geometry import Curve as DynCurve
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import StructuralType
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
def tolist(obj1):
if hasattr(obj1,'__iter__'): return obj1
else: return [obj1]
def flatten(x):
result = []
try:
for el in x:
if hasattr(el, "__iter__") and not isinstance(el, basestring):
result.extend(flatten(el))
else:
result.append(el)
except:
result = x
return result
geom = UnwrapElement(IN[0])
if geom != None:
geom = tolist(geom)
else:
pass
temp_path = System.IO.Path.GetTempPath()
satOpt = SATExportOptions()
opt1 = Options()
opt1.ComputeReferences = True
#Find a 3D view type
collector1 = FilteredElementCollector(doc)
viewFamilyTypes = collector1.OfClass((ViewFamilyType))
for e in viewFamilyTypes:
if str(e.ViewFamily) == "ThreeDimensional":
viewType = e.Id
break
def NewForm_background(s1):
try:
randomname = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(5)])
TransactionManager.Instance.EnsureInTransaction(doc)
sat_path = '%s%s.sat' % (temp_path, randomname)
status = True
finalres = []
resultgeom = []
threedeeview = View3D.CreateIsometric(doc, viewType)
threedeeviewid = threedeeview.Id
kilist = List[ElementId]([threedeeviewid])
tid = []
for each in s1:
tid.append(each.Id)
ielements = List[ElementId](tid)
threedeeview.IsolateElementsTemporary(ielements)
collectorinside = FilteredElementCollector(doc,threedeeviewid).ToElements()
elemento = []
for k in collectorinside:
elemento.append(int(str(k.Id)))
for each in s1:
if int(str(each.Id)) in elemento:
doc.Export(temp_path, randomname, kilist, satOpt)
eachlist = Geometry.ImportFromSAT(sat_path)
tmplist = []
for e in eachlist:
tmplist.append(e)
resultgeom.append(tmplist)
System.IO.File.Delete(sat_path)
else:
resultgeom = [None]
break
doc.Delete(threedeeview.Id)
finalres.append(flatten(resultgeom))
TransactionManager.Instance.TransactionTaskDone()
return finalres
except:
return traceback.format_exc(),''
result = NewForm_background(geom)
OUT = flatten(result)
satOpt.Dispose()
opt1.Dispose()
view raw geometryfix.py hosted with ❤ by GitHub

Kết quả

Trường hợp 1:

trim with edge loops requires fix

Trường hợp 2 :

trim with edge loops requires fix3

101780350 252105876113166 8406925636085481472 n

Download Source Test1 : FurnitureTowersRVT2021.rvt
Download Source Test2 : Circulararcsweep_RVT2020.rvt

Tham khảo

DynamoDS