Announcement

Collapse
No announcement yet.

TextNotes location

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    TextNotes location

    I can't get location of Text Notes elements by Element.GetLocation. Is there any way i can get the location?

    #2
    In the API, TextElements have a .Coord property that stores the position. Looks do-able with some python work, see here:
    https://forum.dynamobim.com/t/set-lo...t-element/5700
    Chris Ellersick

    Comment


      #3
      Dear cellersick,

      I have read the discussion, but i am not (yet) good with python. Appreciate if you can give me full script of python to get TextNotes location.

      Thanks.

      Comment


        #4
        got it.

        python script:

        import clr


        clr.AddReference('RevitAPI')
        from Autodesk.Revit.DB import *


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


        OUT=[]


        for val in UnwrapElement(IN[0]):
        OUT.append(val.Coord)

        Comment


          #5
          What are you feeding into this script to get the coordinates? I am trying to give it an element or list or elements and output coordinates, but i dont think i have it right.

          Comment


            #6
            Hello HandyAndy,

            You need to write it as the following:



            And you should be able to copy and paste the following into your Python node

            Code:
            [COLOR=#75715e]# Importing the 'Common Language Runtime' library[/COLOR]
            [COLOR=#f92672][B]import[/B][/COLOR] clr
            [COLOR=#75715e]# Adding specific references: The Revit API[/COLOR]
            clr.[COLOR=#ffffff][B]AddReference[/B][/COLOR]([COLOR=#e6db74]'RevitAPI'[/COLOR])
            [COLOR=#f92672][B]from[/B][/COLOR] Autodesk.Revit.DB [COLOR=#f92672][B]import[/B][/COLOR] *
            clr.[COLOR=#ffffff][B]AddReference[/B][/COLOR]([COLOR=#e6db74]'RevitNodes'[/COLOR])
            [COLOR=#f92672][B]import[/B][/COLOR] Revit
            [COLOR=#75715e]# Importing specific extension methods that allow us to gain[/COLOR]
            [COLOR=#75715e]# information such as 'Coord' data[/COLOR]
            clr.[COLOR=#ffffff][B]ImportExtensions[/B][/COLOR](Revit.GeometryConversion)
            clr.[COLOR=#ffffff][B]ImportExtensions[/B][/COLOR](Revit.Elements)
            [COLOR=#75715e]# Creating an empty list that we populate later[/COLOR]
            OUT = []
            [COLOR=#75715e]# Running a 'for loop' over everything inside our input list[/COLOR]
            [COLOR=#75715e]# by Unwrapping them (Which is requried between Revit and Dynamo[/COLOR]
            [COLOR=#75715e]# objects[/COLOR]
            [COLOR=#f92672][B]for[/B][/COLOR] item [COLOR=#f92672][B]in[/B][/COLOR] [COLOR=#ffffff][B]UnwrapElement[/B][/COLOR](IN[[COLOR=#ae81ff]0[/COLOR]]):
                [COLOR=#75715e]# For our 'for loop' to work, we need to indent as Python is [/COLOR]
                [COLOR=#75715e]# very particular about indentation. We simply then 'nest' in[/COLOR]
                [COLOR=#75715e]# our line of code an appendation of each 'looped' item into[/COLOR]
                [COLOR=#75715e]# our previously created empty list. We then 'cast' the data[/COLOR]
                [COLOR=#75715e]# to a Point (Which dynamo can read)[/COLOR]
                OUT.[COLOR=#ffffff][B]append[/B][/COLOR](item.Coord.[COLOR=#ffffff][B]ToPoint[/B][/COLOR]())
                [COLOR=#75715e]# Natively, Dynamo understands that the OUT is our output, so[/COLOR]
                [COLOR=#75715e]# pushes this data through the node out port
            [/COLOR]
            Attached Files

            Sol Amour

            Architectural Explorer, Digital warrior, Affectual adventurer and Curious Human Being
            Portfolio Website @ Cargo Collective

            Comment

            Related Topics

            Collapse

            Working...
            X