using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data; using System.Data.OleDb; using Autodesk.Revit; using Autodesk.Revit.Parameters; using System.Threading; namespace Integration { public class Class1 : IExternalCommand { public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { string myConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0;" + @"Data Source = C:\Documents and Settings\aaa222\Desktop\demmy.mdb"; // select everything from the following tables in the database string mySelectQuery = "SELECT * FROM doors"; OleDbConnection myConnection = new OleDbConnection(myConnectionString); OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(mySelectQuery, myConnection); DataTable doors = new DataTable("Doors"); //MessageBox.Show("Starting accessing Access database"); try { myConnection.Open(); myDataAdapter.Fill(doors); Multitables.Tables.Add(doors); } catch (Exception) { } finally { myConnection.Close(); } // Make a list of items to be called in a temporary storage // door list List intListd = new List(); for (int i = 0; i < doors.Rows.Count; i++) { intListd.Add(int.Parse(doors.Rows[i]["Id"].ToString())); List stringListd = new List(); stringListd.Add("Comments"); } // Get the handle of current document. Document document = commandData.Application.ActiveDocument; // create a new id ElementId id = new ElementId(); //get element from document //Autodesk.Revit.Element myelement = document.get_Element(ref id); // Get the comment parameter of the element instance //Autodesk.Revit.Parameter Para = myelement.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS); // set id value and try intListd for (int i = 0; i < doors.Rows.Count; i++) { id.Value = int.Parse(intListd[i].ToString()); // MessageBox.Show(id.Value.ToString()); //get element from document Autodesk.Revit.Element myelement = document.get_Element(ref id); // MessageBox.Show( myelement.ToString() ); // Get the comment parameter of the element instance Autodesk.Revit.Parameter Para = myelement.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS); Para.Set(" This needs maintenance"); } return IExternalCommand.Result.Succeeded; } } }