<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Selecting objects with Python in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11965632#M60907</link>
    <description>&lt;P&gt;Thanks for the suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've decided to just start with grabbing the info or rather recognizing what elements I have selected when I run the graph in Dynamo.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Figured to start with the starting point haha&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For whatever reason, Dynamo doesn't actually run the graph again or rather it doesnt refresh the data when I rerun it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the list of elements I had selected when the graph was ran, but when I select something else or even simply have nothing selected, the output doesn't change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I even added a random number generator just to see if it generates a new number when the graph is ran again and in fact it doesn't!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my starting point. (Works but the output doesn't change when ran again.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...btw I used chatGPT to generate the code haha.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CWagnerLYWJP_0-1684182941349.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1214739iB03455640C155763/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CWagnerLYWJP_0-1684182941349.png" alt="CWagnerLYWJP_0-1684182941349.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 May 2023 20:38:30 GMT</pubDate>
    <dc:creator>CWagnerLYWJP</dc:creator>
    <dc:date>2023-05-15T20:38:30Z</dc:date>
    <item>
      <title>Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6812756#M60892</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking to create a python script which will select objects based on their parameter values, the objects will then be the highlighted active selection in the Revit UI for the user to do something with.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To start this off, I'm writing a basic script to select an object. I'm writing this as a Python script within Dynamo.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in Dynamo&amp;nbsp;I use the 'Select Model Element' node which returns an object, I'm now trying to select that object in python using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;selob = Selection.SetElementIds(selobject.Id)&lt;/PRE&gt;&lt;P&gt;But when I run the script I get the error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;TypeError SetElementIds() takes exactly 2 arguements (1 given).&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But looking at the API documentation for the Selection Class, the SetElementsIds method only appears to require one arguement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.revitapidocs.com/2015/cf8c11bb-f0c7-6d50-cbdf-41d0a010d9d6.htm" target="_self"&gt;http://www.revitapidocs.com/2015/cf8c11bb-f0c7-6d50-cbdf-41d0a010d9d6.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 09:19:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6812756#M60892</guid>
      <dc:creator>Kevin.Bell</dc:creator>
      <dc:date>2017-01-18T09:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6813013#M60893</link>
      <description>&lt;P&gt;I cannot answer all aspects of your question, but I can address two:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Why does your error message include a typo? It says "&lt;EM&gt;arguements&lt;/EM&gt;"... I find that hard to believe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. You are passing in a single element id.&amp;nbsp;T&lt;SPAN&gt;he SetElementsIds method argument is a generic list of element ids, List&amp;lt;ElementId&amp;gt;. To pass in a single id, you can&amp;nbsp;create an empty list, add the id to it, and pass in that.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Unfortunately I cannot say why the error message mentions two arguments... that may be a Python-specific quirk.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do you want to start by trying to pass in the list instead of the single id on its own?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 11:30:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6813013#M60893</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-18T11:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6813052#M60894</link>
      <description>&lt;P&gt;Thanks for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I amended the code to add a list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import clr
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI.Selection import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
adoc = doc.ActiveView
uidoc = uiapp.ActiveUIDocument

#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
selobject		= UnwrapElement(IN[0])	# Object to select

sellist = []
sellist.append(selobject.Id)

selob = Selection.SetElementIds(sellist)

#Assign your output to the OUT variable.
OUT = [selob]&lt;/PRE&gt;&lt;P&gt;But get the same error: (I've copied and pasted this from the error window)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Traceback (most recent call last):&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;File "&amp;lt;string&amp;gt;", line 39, in &amp;lt;module&amp;gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;TypeError: SetElementIds() takes exactly 2 arguments (1 given)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Don't know if thats any help?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 11:45:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6813052#M60894</guid>
      <dc:creator>Kevin.Bell</dc:creator>
      <dc:date>2017-01-18T11:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6813055#M60895</link>
      <description>&lt;P&gt;Thank!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yup, helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I forwarded this to the Dynamo development team for help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 11:48:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6813055#M60895</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-18T11:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6813201#M60896</link>
      <description>&lt;P&gt;Excellent, thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 12:34:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6813201#M60896</guid>
      <dc:creator>Kevin.Bell</dc:creator>
      <dc:date>2017-01-18T12:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6814951#M60897</link>
      <description>&lt;P&gt;Give something like this a try:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;uidoc = self.ActiveUIDocument&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;doc = self.ActiveUIDocument.Document&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;app = self.Application&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;# Select some elements in Revit before invoking this command&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;# Get the element selection of current document.&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;selectedIds = uidoc.Selection.&lt;SPAN&gt;GetElementIds&lt;/SPAN&gt;()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;if&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;0&lt;/SPAN&gt;&amp;nbsp;== selectedIds.Count:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TaskDialog.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"Revit"&lt;/SPAN&gt;,&lt;SPAN&gt;"You haven't selected any elements."&lt;/SPAN&gt;)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;else&lt;/SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TaskDialog.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"Revit"&lt;/SPAN&gt;,&lt;SPAN&gt;"Elements Selected."&lt;/SPAN&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 22:56:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6814951#M60897</guid>
      <dc:creator>stever66</dc:creator>
      <dc:date>2017-01-18T22:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6816523#M60898</link>
      <description>&lt;P&gt;The exception&amp;nbsp;you're getting is caused by calling a method on an invalid object.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get your code working you need to do the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Import the &lt;FONT face="courier new,courier"&gt;System.Collection.Generic&lt;/FONT&gt; library&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Create a ElementId List object and add the element id's to it - in IronPython the syntax is &lt;FONT face="courier new,courier"&gt;List[&lt;EM&gt;class&lt;/EM&gt;]()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;3. Get the active UI document then pass the ElementId list to the &lt;FONT face="courier new,courier"&gt;SetElementIds&lt;/FONT&gt; method&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a working example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import clr

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from System.Collections.Generic import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

element = UnwrapElement(IN[0])

elementIdList = List[ElementId]()
elementIdList.Add(element.Id)

sel = uidoc.Selection.SetElementIds(elementIdList)&lt;/PRE&gt;&lt;P&gt;Also, you should post these questions on the Dynamo.org forum as you would get a quicker response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HighlightModelElement.gif" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/312911i315E8D75DD100D28/image-size/large?v=v2&amp;amp;px=999" role="button" title="HighlightModelElement.gif" alt="HighlightModelElement.gif" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 15:38:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6816523#M60898</guid>
      <dc:creator>thomas</dc:creator>
      <dc:date>2017-01-19T15:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6823784#M60899</link>
      <description>&lt;P&gt;MD - Briliant thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see the problem was the use of an 'ICollection', I've not come across one of those before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whats the difference between an ICollection and a list?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 10:39:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6823784#M60899</guid>
      <dc:creator>Kevin.Bell</dc:creator>
      <dc:date>2017-01-23T10:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6825145#M60900</link>
      <description>&lt;P&gt;An &lt;A href="https://msdn.microsoft.com/en-us/library/92t2ye13(v=vs.110).aspx" target="_blank"&gt;ICollection &lt;/A&gt;is an interface that defines a small set of properties and methods that are useful for manipulating a collection of objects: &amp;nbsp;Count, Add(), Remove(), Clear(), etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A .net &lt;A href="https://msdn.microsoft.com/en-us/library/6sh2ey19(v=vs.110).aspx" target="_blank"&gt;List &lt;/A&gt;is a class that contains a list of objects. &amp;nbsp;It implements the ICollection interface, as well as a couple of others.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not familiar with python so I'm not sure what .net type, nor the interfaces it implements, this&amp;nbsp;translates too:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;sellist = []&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in thomas's example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;elementIdList = List[ElementId]()&lt;BR /&gt;elmentIdList.Add(element.Id)&lt;/PRE&gt;&lt;P&gt;a new List object for holding ElementId's is instantiated and an ElementId is added to it. &amp;nbsp;Since the List object implements ICollection, it can be passed as an argument to the Selection.SetElementsIDs() method since it expects an ICollection as its argument.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 18:57:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6825145#M60900</guid>
      <dc:creator>BobbyC.Jones</dc:creator>
      <dc:date>2017-01-23T18:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6825492#M60901</link>
      <description>&lt;P&gt;Thanks Bobby!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 20:50:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/6825492#M60901</guid>
      <dc:creator>Kevin.Bell</dc:creator>
      <dc:date>2017-01-23T20:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/7215931#M60902</link>
      <description>&lt;P&gt;I tried this method and it works for me when i select a single element in revit, but i would like to select multiple elements instead...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that possible or the script doesn't work for multiple selection?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought it should because you make a list and just add all the id's to the list and it will select them all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;F Verwoert&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 08:26:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/7215931#M60902</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-07-10T08:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/9078765#M60903</link>
      <description>&lt;P&gt;Thanks for this explanation Thomas!&lt;/P&gt;&lt;P&gt;ps. you might want to change point 1 in your explanation to make the word Collection plural.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;P&gt;Paolo&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 13:26:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/9078765#M60903</guid>
      <dc:creator>paolomod3nese</dc:creator>
      <dc:date>2019-10-10T13:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/9503164#M60904</link>
      <description>&lt;P&gt;Hello i am currently having problem selecting multiple elements using python. Could you please help me with a code&lt;/P&gt;</description>
      <pubDate>Sat, 09 May 2020 01:35:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/9503164#M60904</guid>
      <dc:creator>asaleem.cem19</dc:creator>
      <dc:date>2020-05-09T01:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11961808#M60905</link>
      <description>&lt;P&gt;Related to selection objects using python:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use python using a hotkey in revit to take my active selection (probably grab the x,y?) and move it to a point that I select in a viewport,. such as another object.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2023 18:03:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11961808#M60905</guid>
      <dc:creator>CWagnerLYWJP</dc:creator>
      <dc:date>2023-05-13T18:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11961920#M60906</link>
      <description>&lt;P&gt;It really depends on how your running the Python code... if its in Dynamo, then you could use Dynamo player to do this... or you could try PyRevit (I've not used that) perhaps create a command, I'd suggest that C# would be the best method (if you know how to use that) as it would be easy to create a command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure you can assign a hot key in Dynamo player though, but in c# or PyRevit you can use the keyboard shortcuts to run your command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Upon running, it would grab the current selection (using&amp;nbsp;&lt;SPAN&gt;uidoc.Selection.&lt;/SPAN&gt;&lt;SPAN&gt;GetElementIds&lt;/SPAN&gt;&lt;SPAN&gt;() as per the above posts), then use ElementTransformUtils to move the elements to a new location.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://www.revitapidocs.com/2015/3cf8c9dc-f4d1-12f0-d7a9-e126331cd858.htm" target="_blank"&gt;https://www.revitapidocs.com/2015/3cf8c9dc-f4d1-12f0-d7a9-e126331cd858.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope thats of use!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2023 20:03:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11961920#M60906</guid>
      <dc:creator>Kevin.Bell</dc:creator>
      <dc:date>2023-05-13T20:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11965632#M60907</link>
      <description>&lt;P&gt;Thanks for the suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've decided to just start with grabbing the info or rather recognizing what elements I have selected when I run the graph in Dynamo.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Figured to start with the starting point haha&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For whatever reason, Dynamo doesn't actually run the graph again or rather it doesnt refresh the data when I rerun it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the list of elements I had selected when the graph was ran, but when I select something else or even simply have nothing selected, the output doesn't change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I even added a random number generator just to see if it generates a new number when the graph is ran again and in fact it doesn't!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my starting point. (Works but the output doesn't change when ran again.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...btw I used chatGPT to generate the code haha.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CWagnerLYWJP_0-1684182941349.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1214739iB03455640C155763/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CWagnerLYWJP_0-1684182941349.png" alt="CWagnerLYWJP_0-1684182941349.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 20:38:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11965632#M60907</guid>
      <dc:creator>CWagnerLYWJP</dc:creator>
      <dc:date>2023-05-15T20:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11965739#M60908</link>
      <description>&lt;P&gt;The reason that you can't rerun the graph is that Dynamo doesn't bother to run if nothing has changed... I've had this problem in the past...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The simplest way I managed to 'fix' the issue was to add a bool to the graph, it doesn't have to do anything, but by changing it Dynamo will rerun.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the Python Script node, click the plus button to add a new input (you won't need to change your code as it doesn't have to do anything), add a Bool (i.e. True / False selector) to that. That should work, but you'll have to change the True / False each time...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at the code, PRINT wont work as there is no where to print to...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before the for element in selected_Elements bit create a blank list called, say, results:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;results = []&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then change the PRINT statement to add the output to the results list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;results.append("Element ID" + element_id)&lt;/P&gt;&lt;P&gt;results.append("Element Name" + element_name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then add the results list to output, replace OUT = selected_elements with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OUT = results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best of luck!&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 21:18:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11965739#M60908</guid>
      <dc:creator>Kevin.Bell</dc:creator>
      <dc:date>2023-05-15T21:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting objects with Python</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11965850#M60909</link>
      <description>&lt;P&gt;Yea the code needs to be cleaned up for sure.&lt;BR /&gt;&lt;BR /&gt;What I want to do is use the Dynamo Player. The graph/code works now as is but again it can't be reran because Dynamo doesn't notice any changes.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 12:33:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selecting-objects-with-python/m-p/11965850#M60909</guid>
      <dc:creator>CWagnerLYWJP</dc:creator>
      <dc:date>2023-05-16T12:33:22Z</dc:date>
    </item>
  </channel>
</rss>

