[Python] Discontinuous Curveloop

Discussão em 'Python' iniciado por Stack, Abril 9, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Python within Dynamo, and I am trying to create a CurveLoop from a given list of lines. However, I am encountering an error that says:


    ArgumentException: This curve will make the loop discontinuous
    ​

    I need to iterate over the list of lines and check if the start point of each line is not equal to the end point of the previous line. If they are not equal, I need to reverse the line, but I am unsure how to do that.

    Here my script:

    import clr
    import sys
    import System
    import math

    #import Revit API
    clr.AddReference('RevitAPI')
    import Autodesk
    from Autodesk.Revit.DB import *
    import Autodesk.Revit.DB as DB
    #import specify namespace



    #import net library
    from System import Array
    from System.Collections.Generic import List, IList, Dictionary

    clr.AddReference('RevitNodes')
    import Revit
    clr.ImportExtensions(Revit.Elements)
    clr.ImportExtensions(Revit.GeometryConversion)
    clr.ImportExtensions(Revit.GeometryReferences)

    #import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
    clr.AddReference('RevitServices')
    import RevitServices
    from RevitServices.Persistence import DocumentManager
    from RevitServices.Transactions import TransactionManager

    doc = DocumentManager.Instance.CurrentDBDocument

    Lines = []
    line1 = Line.CreateBound(XYZ(5,0,5), XYZ(5,0,0))
    Lines.append(line1)
    line2 = Line.CreateBound(XYZ(-5,0,0), XYZ(5,0,0))
    Lines.append(line2)
    line3 = Line.CreateBound(XYZ(-5,0,0), XYZ(-5,0,5))
    Lines.append(line3)

    curves = CurveLoop()

    # how to append lines in the CurveLoop with the correct orientation and order?
    for i in Lines:
    curves.Append(i)


    OUT = curves

    Continue reading...

Compartilhe esta Página