Extract Rivet Data to windows Form

Extract Rivet Data to windows Form

Anonymous
Not applicable
697 Views
1 Reply
Message 1 of 2

Extract Rivet Data to windows Form

Anonymous
Not applicable

Hi,

 

I want to extract rivet data such as room ID, room name, level on which rooms belong etc. using a button on windows from.

 

I have gone through Rivet API addin procedure added a manifest file &  successfully able to open a window in Rivet software.

 

If anyone can just help me with syntax to be used to extract say just one type of data like room ID and display into a listview on the window using click of a button rest of other data I will do it myself.

 

I have attached below the code to open my window in Rivet.

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
 
 
namespace Trial
{
   
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    public class Class1 : IExternalCommand
    {
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
           ref string message, ElementSet elements)
        {
            try
            {
                Form1 f1 = new Form1();
                f1.Show();
               
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
               
            }
                       
            return Autodesk.Revit.UI.Result.Succeeded;
        }
    }

}
  

 

Below is the screen shot for the window opened in Rivet.

Widow open in rivet.jpg

 

 

I have gone through many posts & tutorials  but I could not find the solution for the above problem.

 

Thanks in advance for your help.

 

Regards

-Faisal

0 Likes
Accepted solutions (1)
698 Views
1 Reply
Reply (1)
Message 2 of 2

FlorisvdG
Advocate
Advocate
Accepted solution

You can use the FilteredElementCollector to collect loads of data from an open file.
http://www.revitapidocs.com/2015/263cf06b-98be-6f91-c4da-fb47d01688f3.htm

for example:


List<View> lstAllViews = new FilteredElementCollector(doc).OfClass(typeof(View)).Cast<View>().ToList();

 

Where doc is the current opendocument, and View is what I want the collector to collect.

The collector returns Elements, so I always cast the elements back to what I'm searching for.

 

There's almost certainly an example in the Revit SDK, you can check that out too.