join curve revit api
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
#from Revit import GeometryConversion as gp
import math
curves = IN[0]
#The next 2 methods will assume that the directions is known.
#The start point of a curve
def startPoint(curve):
return curve.GetEndPoint(0)
#The end point of a curve
def endPoint(curve):
return curve.GetEndPoint(1)
#Groups lines to be joined in sublists with the curves that have to be joined
def joinCurves(list):
comp=[]
re=[]
unjoined = []
for c in curves:
c = c.ToRevitType()
match = False
for co in comp:
if startPoint(c).IsAlmostEqualTo(startPoint(co)) and endPoint(c).IsAlmostEqualTo(endPoint(co)):
match = True
if match:
continue
else:
comp.append(c)
joined = []
for c2 in curves:
match = False
c2 = c2.ToRevitType()
for co in comp:
if startPoint(c2).IsAlmostEqualTo(startPoint(co)) and endPoint(c2).IsAlmostEqualTo(endPoint(co)):
match = True
if match:
continue
else:
if c2.Intersect(c) == SetComparisonResult.Disjoint:
continue
elif c2.Intersect(c) == SetComparisonResult.Equal:
continue
elif c2.Intersect(c) == SetComparisonResult.Subset:
comp.append(c2)
joined.append(c2.ToProtoType())
joined.append(c.ToProtoType())
re.append(joined)
return re
result = joinCurves(curves)
OUT = result
Are there any code examples left?
New code examples in category Other
-
Other 2023-03-27 22:50:10 how to select the whole line in vscode with keyboard shortcut
-
Other 2022-03-27 22:45:24 income of a web developer
-
Other 2022-03-27 22:35:01 \pyrcc_main.py: File does not exist 'resources.qrc'
-
Other 2022-03-27 22:30:45 rick roll embed code
-
Other 2022-03-27 22:20:08 Circuit_04_Potentiometer
-
Other 2022-03-27 22:20:05 iterative power
-
Other 2022-03-27 22:15:11 flutter run all
-
Other 2022-03-27 22:10:05 when is karlson release
-
Other 2022-03-27 22:10:02 wp .htaccess example
-
Other 2022-03-27 22:00:08 bash pause in file read line by line