I want to create wall in the active view. Wall.Create() method has levelId. So how can I retrieve a level id in active view?
Thanx
Solved! Go to Solution.
Solved by Troy_Gates. Go to Solution.
Here is a quick macro I wrote that gets the active view's level id
public void ViewLevel() { Document doc = ActiveUIDocument.Document; View active = doc.ActiveView; ElementId levelId = null; Parameter level = active.LookupParameter("Associated Level"); FilteredElementCollector lvlCollector = new FilteredElementCollector(doc); ICollection<Element> lvlCollection = lvlCollector.OfClass(typeof(Level)).ToElements(); foreach (Element l in lvlCollection) { Level lvl = l as Level; if(lvl.Name == level.AsString()) { levelId = lvl.Id; //TaskDialog.Show("test", lvl.Name + "\n" + lvl.Id.ToString()); } } }
If I want to add level name form the active view to the drop down list of the windows form How I do that?
for example:- I creating addin after clicking the addin button it open the windows form.It contains the dropdown list. I want to add the name of the levels from the active view of the revit.
I'm not sure why you would want to use a drop down list when there can only be one level per view. But in the example above, you can use the first part to get the active view's level name...
Document doc = ActiveUIDocument.Document; View active = doc.ActiveView; Parameter level = active.LookupParameter("Associated Level"); String levelName = level.AsString();
I am using drop down list because I creating addin which contains 2 dropdown list and one button. First drop down contains item "Join wall and column" and second drop down contain levels like (first floor level, second floor level etc)
If I select both item and click on button it only joins those wall and column which is in that level which I have been selected.
Hi, I'm using a French version of Revit so I have to use "Niveau associé" in place of "Associated level". Is there a builtin parameter I can use?
Thanks,
André
Hi, I'm using a French version of Revit so I have to use "Niveau associé" in place of "Associated level". Is there a builtin parameter I can use?
Thanks,
André
Hi, you should install Revit lookup plugin. You will snoop your wall parameters and then snoop the parameter you want, you will find a BuiltInParameter correspondance.
You can do that whithout using LookupParameter method using only API methods and properties. No language problem.
Document doc = uiapp.ActiveUIDocument.Document;
View activeView = doc.ActiveView;
Level level = activeView.GenLevel;
ElementId levelId = level.Id;
string levelName = level.Name;
Can't find what you're looking for? Ask the community or share your knowledge.