<?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: My first basic script in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/my-first-basic-script/m-p/9300675#M36882</link>
    <description>&lt;P&gt;Thanks for your Replay!&lt;/P&gt;&lt;P&gt;It will help me a lot, I spend so much time to find why that didnt work and i think&amp;nbsp; it was this line:&lt;/P&gt;&lt;PRE&gt;param.Append(par);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;And it&amp;nbsp;&lt;SPAN&gt;should be:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;param.Add(par);&lt;/PRE&gt;&lt;P&gt;Thats a reason why script can not build a list of parameters.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2020 12:02:37 GMT</pubDate>
    <dc:creator>Maciej_Darmochwal</dc:creator>
    <dc:date>2020-02-06T12:02:37Z</dc:date>
    <item>
      <title>My first basic script</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/my-first-basic-script/m-p/9292581#M36880</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi,I have a probably simple problem.I want select many elements and add to paramaeter "Comments" value "Something".I dont know where the problem is ;/.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;using System;&lt;BR /&gt;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
namespace Lab1PlaceGroup
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class Class1 : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uiapp.ActiveUIDocument.Document;

            IList&amp;lt;Reference&amp;gt; pickedobj = uidoc.Selection.PickObjects(ObjectType.Element, "SELECT").ToList();
            IList&amp;lt;Parameter&amp;gt; param = new List&amp;lt;Parameter&amp;gt;();
            for (int i = 0; i &amp;lt; pickedobj.Count; i++)
            {
                Element elemm = uidoc.Document.GetElement(pickedobj.ElementAt(i));
                Parameter par = elemm.LookupParameter("Comments");
                param.Append(par);
            }
            using (Transaction t = new Transaction(doc, "ASD"))
            {
                t.Start("TRANS");
                try
                {
                    int a = 0;
                    foreach (Parameter x in param)
                    {
                        param.ElementAt(a).Set("Something");
                        a++;
                    }
                }
                catch { }
                t.Commit();
            }
            return Result.Succeeded;
        }

    }

}&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Feb 2020 13:48:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/my-first-basic-script/m-p/9292581#M36880</guid>
      <dc:creator>Maciej_Darmochwal</dc:creator>
      <dc:date>2020-02-03T13:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: My first basic script</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/my-first-basic-script/m-p/9300167#M36881</link>
      <description>&lt;P&gt;Dear&amp;nbsp;Maciej,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome to the Revit API!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at your code, I would suggest that you simplify it significantly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the error will probably go away by itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The BIM element has one single comment filed that you wish to set a value on, so there is no need to maintain a list of different parameters named "Comment" and loop through all of the with the call to Set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pick the one single parameter you need instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best way to do so is to not use the "Comment" display name, but the built-in parameter enumeration value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may or may not be&amp;nbsp;BuiltInParameter.ALL_MODEL_MARK.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To find out what it is, you should first of all install RevitLookup and explore the element that you wish to set the comment on to find the&amp;nbsp;built-in parameter enumeration value corresponding to the parameter you wish to modify.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say its value is B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can simply say:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  elemm.get_Parameter(B).Set("Something");&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way,&amp;nbsp;I would suggest that you make it simple for yourself: before doing anything else, work through the standard Revit API getting started material, the training videos, and the initial walkthroughs in the developer guide:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#2" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That will explain all the fundamentals and get you up and running smoothly with less hassle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have done that read about how to research to solve a Revit API programming task:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-ontology.html#3" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-ontology.html#3&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck and have fun!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 07:27:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/my-first-basic-script/m-p/9300167#M36881</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-02-06T07:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: My first basic script</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/my-first-basic-script/m-p/9300675#M36882</link>
      <description>&lt;P&gt;Thanks for your Replay!&lt;/P&gt;&lt;P&gt;It will help me a lot, I spend so much time to find why that didnt work and i think&amp;nbsp; it was this line:&lt;/P&gt;&lt;PRE&gt;param.Append(par);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;And it&amp;nbsp;&lt;SPAN&gt;should be:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;param.Add(par);&lt;/PRE&gt;&lt;P&gt;Thats a reason why script can not build a list of parameters.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 12:02:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/my-first-basic-script/m-p/9300675#M36882</guid>
      <dc:creator>Maciej_Darmochwal</dc:creator>
      <dc:date>2020-02-06T12:02:37Z</dc:date>
    </item>
  </channel>
</rss>

