Select Levels from drop down list of revit 3D view

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I want to create drop down list in windows form which contain all levels from the project which is used in that project(ground floor, first floor like that..).
For that I create a windows form(as I attached image ) which is the addin application for revit.
How I load all the levels in form load event when we click on revit addin for a particualr project.
Example:-
1st drop down has a string
2nd drop down conatins levels(if I select 1st floor level)
If I select both item from drop down list then click on join button the it join only first floor elements(wall and column) .It could not join other levels element(wall and column).
This is the code I using without selecting levels(not contain level drop down list)
Form Code:-
using System;
using System.Windows.Forms;
using Autodesk.Revit.UI;
namespace JoinGeometry
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public partial class Form2 : Form
{
ExternalCommandData commandData;
public Form2(ExternalCommandData commandDatax)
{
commandData = commandDatax;
InitializeComponent();
}
//------------------------JOIN------------------------------------------------------------------------
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedItem == "Wall" && comboBox2.SelectedItem == "Column")
{
try
{
WCjoin wcj = new WCjoin();
wcj.Execute(commandData);
label2.Text = "WALL COLUMN JOINED";
}
catch (Exception g)
{
TaskDialog.Show("revit", "error is occured" + g);
}
}
}
WCjoin code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace JoinGeometry
{
[Transaction(TransactionMode.Manual)]
class WCjoin
{
bool check;
public Result Execute(ExternalCommandData commandData)
{
UIApplication uiApp = commandData.Application;
UIDocument uidoc = uiApp.ActiveUIDocument;
Document doc = uidoc.Document;
//--get walls on the active view-----------
FilteredElementCollector collWalls = new FilteredElementCollector(doc, doc.ActiveView.Id);
collWalls.OfClass(typeof(Wall));
foreach (Wall w in collWalls)
{
FilteredElementCollector collColumnsOnThisWall = new FilteredElementCollector(doc, doc.ActiveView.Id);
collColumnsOnThisWall.OfClass(typeof(FamilyInstance));
collColumnsOnThisWall.OfCategory(BuiltInCategory.OST_StructuralColumns);
BoundingBoxXYZ bb = w.get_BoundingBox(doc.ActiveView);
Outline outline = new Outline(bb.Min, bb.Max);
BoundingBoxIntersectsFilter bbfilter =
new BoundingBoxIntersectsFilter(outline);
collColumnsOnThisWall.WherePasses(bbfilter);
foreach (FamilyInstance column in collColumnsOnThisWall)
{
using (Transaction t = new Transaction(doc, "Join All Walls/Column"))
{
t.Start();
check=JoinGeometryUtils.AreElementsJoined(doc, w, column);
if(check==true)
{
}
else
{
JoinGeometryUtils.JoinGeometry(doc, w, column);
}
t.Commit();
}
}
}
return Result.Succeeded;
}
}
}
And how should I extarct levels from revit to dropdown list
In this code what changes should I do for achieve my goal