Message 1 of 13
Error in program
Not applicable
07-28-2015
06:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear all,
i am devoioping one document change event but i am struct at errors and warnings, looking suggestions from api experts.
for the same i have attached code and error image for all of yours reference.
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<ElementId> 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 != "" && catName != "")
catName += ": ";
name = "(" + catName + e.Name + ")";
}
ret += id.IntegerValue.ToString() + name + ",";
}
return ret;
}
}
}Thanks & Regards
Amith
