<?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: Error in program in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5747163#M71296</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please ignore above reply,i got your point and solved as per your instruction in above reply from you, one more error in the program can you look at that.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"The name 'Utils' does not exist in the current context"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;how to solove this error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Amith&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jul 2015 14:06:34 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-07-29T14:06:34Z</dc:date>
    <item>
      <title>Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5744809#M71288</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am devoioping one document change event but i am struct at errors and warnings, looking suggestions from api experts.&lt;/P&gt;&lt;P&gt;for the same i have attached code and error image for all of yours reference.&lt;/P&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

namespace Event Manager
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]

public class Class1 : IExternalCommand
{
       void ControlledApplication_DocumentChanged(object sender, Autodesk.Revit.DB.Events.DocumentChangedEventArgs e)
        {
            string file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "CommandLogging.csv");
            using (StreamWriter sw = new StreamWriter(file, true))
            {
                foreach (string transactionName in e.GetTransactionNames())
                {
                    sw.Write(DateTime.Now + "," + Utils.username + "," + transactionName);
                    sw.Write(",ADDED," + idCollectionToString(e.GetDocument(), e.GetAddedElementIds()));
                    sw.Write(",DELETED," + idCollectionToString(e.GetDocument(), e.GetDeletedElementIds()));
                    sw.Write(",MODIFIED," + idCollectionToString(e.GetDocument(), e.GetModifiedElementIds()));
                    sw.Write(Environment.NewLine);
                }
            }
        }

        private string idCollectionToString(Document doc, ICollection&amp;lt;ElementId&amp;gt; coll)
        {
            string ret = "";
            foreach (ElementId id in coll)
            {
                Element e = doc.GetElement(id);
                string name = "";
                if (e != null)
                {
                    string catName = "";
                    if (e.Category != null)
                        catName = e.Category.Name;
                    if (e.Name != "" &amp;amp;&amp;amp; catName != "")
                        catName += ": ";
                    name = "(" + catName + e.Name + ")";
                }
                ret += id.IntegerValue.ToString() + name + ",";
            }
            return ret;
        }
    }
}&lt;/PRE&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Amith&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 13:21:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5744809#M71288</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-28T13:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5745022#M71289</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;first, your need to add an object that support the IExternalCommand interface.&amp;nbsp;&lt;/P&gt;&lt;P&gt;example :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public class Class1 : IExternalCommand {
public Result Execute(ExternalCommand commandData, ref string message, ElementSet elementset){

//CODE//

return Result.Succeeded;
}
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and you need to add : using&amp;nbsp;System.IO; &amp;nbsp;for use StreamWriter&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 14:55:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5745022#M71289</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-28T14:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5745036#M71290</link>
      <description>&lt;P&gt;Dear Amith,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After checking your screenshot and reproducing your code I can see the cause of your errors being triggered.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I added a screenshot with comments on how to solve them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope it helps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 15:01:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5745036#M71290</guid>
      <dc:creator>rosalesduquej</dc:creator>
      <dc:date>2015-07-28T15:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5746399#M71291</link>
      <description>&lt;P&gt;Thanks alot for both of your reply i tried with solution its working but now facing another error, for the same i am reattaching updated code with error screen shot please sugest me to solove the issue&lt;/P&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using System.IO;
using System.Data;
using System.Configuration;

namespace event

{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
   
   
    public class Class1 : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet Elements)
        {
        }
        void ControlledApplication_DocumentChanged(object sender, Autodesk.Revit.DB.Events.DocumentChangedEventArgs e)
        {
            string file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "CommandLogging.csv");
            using (StreamWriter sw = new StreamWriter(file, true))
            {
                foreach (string transactionName in e.GetTransactionNames())
                {
                    sw.Write(DateTime.Now + "," + Utils.username + "," + transactionName);
                    sw.Write(",ADDED," + idCollectionToString(e.GetDocument(), e.GetAddedElementIds()));
                    sw.Write(",DELETED," + idCollectionToString(e.GetDocument(), e.GetDeletedElementIds()));
                    sw.Write(",MODIFIED," + idCollectionToString(e.GetDocument(), e.GetModifiedElementIds()));
                    sw.Write(Environment.NewLine);
                }
            }
        }

        private string idCollectionToString(Document doc, ICollection&amp;lt;ElementId&amp;gt; coll)
        {
            string ret = "";
            foreach (ElementId id in coll)
            {
                Element e = doc.GetElement(id);
                string name = "";
                if (e != null)
                {
                    string catName = "";
                    if (e.Category != null)
                        catName = e.Category.Name;
                    if (e.Name != "" &amp;amp;&amp;amp; catName != "")
                        catName += ": ";
                    name = "(" + catName + e.Name + ")";
                }
                ret += id.IntegerValue.ToString() + name + ",";
            }
            return ret;
        }
    }
}&lt;/PRE&gt;&lt;P&gt;That identifier error in namespace and i dont know what is warnings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Amith&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2015 09:06:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5746399#M71291</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-29T09:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5746423#M71292</link>
      <description>Hi,&lt;BR /&gt;yes, you cannot use "event" for your namespace, writte another word</description>
      <pubDate>Wed, 29 Jul 2015 09:29:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5746423#M71292</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-29T09:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5746440#M71293</link>
      <description>&lt;P&gt;i got your point after changing the name it will show me other errors for the same i attached another screen shot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;amith&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2015 09:46:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5746440#M71293</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-29T09:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5746555#M71294</link>
      <description>&lt;P&gt;because &amp;nbsp;public Result Execute is empty&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;public Result Execute(ExternalCommandData commandData, ref string message, ElementSet Elements)
{

//CODE//

return Result.Succeeded;
}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2015 12:14:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5746555#M71294</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-29T12:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5746630#M71295</link>
      <description>&lt;P&gt;Dear&amp;nbsp;neoris&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As per your above reply i will tried but i am getting struct on somewhere if you dont mind can you change wherever it required in above mentioned program because i am new to this api ,i cannot undersatnd where to give&amp;nbsp;return Result.Succeeded in this program,its my request to you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;amp;Regards&lt;/P&gt;&lt;P&gt;amith&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2015 12:56:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5746630#M71295</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-29T12:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5747163#M71296</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please ignore above reply,i got your point and solved as per your instruction in above reply from you, one more error in the program can you look at that.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"The name 'Utils' does not exist in the current context"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;how to solove this error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Amith&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2015 14:06:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5747163#M71296</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-29T14:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5747169#M71297</link>
      <description>&lt;P&gt;"return Result.Succeeded;" is always in the end of your public Result Execute(...), because this method&amp;nbsp;need to return something for work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your program is not complete for what you want .&lt;BR /&gt;I invite you to read the sample in Revit SDK named " documentChanged " , it show you how to track changes in the Revit application.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2015 14:10:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5747169#M71297</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-29T14:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5747195#M71298</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That one is now soloved but i have another error&amp;nbsp;&lt;STRONG&gt;"The name 'Utils' does not exist in the current context" &lt;/STRONG&gt;what is this error, how to solove this one&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Amith&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2015 14:18:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5747195#M71298</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-29T14:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5747590#M71299</link>
      <description>&lt;P&gt;Utils.username is a function created for retrieve the username of your revit session but here you just call the function whitout writte the method in your code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Utils is a class , username is a function, it's like a shortcut , in Utils class you writte a lot of function/method that you need in all your programs, and when you want you call the function in your app.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;delete Utils.username for solve your program, but as i say on top, your program isn't complete for work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;sw.Write(DateTime.Now + "," + transactionName);&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Jul 2015 14:31:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5747590#M71299</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-29T14:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Error in program</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5749579#M71300</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After debug i will created manifest file in notepad and save as addin file format&amp;nbsp; but after checking with revit there is no external command in addin what is the reason for cause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Amith&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 11:06:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/error-in-program/m-p/5749579#M71300</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-30T11:06:53Z</dc:date>
    </item>
  </channel>
</rss>

