Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get base and top level of a selected column.

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
annp_mth
2608 Views, 3 Replies

Get base and top level of a selected column.

Hello everyone,

I'm a Revit API newbie. How can I get base and top level of a selected column? The following codes don't work:

 

UIDocument uidoc = new UIDocument(Document);
Document doc = uidoc.Document;
ElementSet col = uidoc.Selection.Elements;
foreach(Element e in col)
{
Parameter pB = e.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_PARAM);
Parameter pT = e.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_PARAM);
TaskDialog.Show("Column Levels", pB.AsString()+" & "+pT.AsString());
}

 

I'm using Revit One Box 2013. Thank for any help!

3 REPLIES 3
Message 2 of 4
jeremytammik
in reply to: annp_mth

Dear annp_mth,

 

As a newbie, I would recommend installing and using RevitLookup before you try anthing else at all.

 

If you do not know how, please work through the getting started materials before that:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

Once you have RevitLookup up and running, you can insert a column manually through the user interface and explore its parameters in RevitLookup to answer this question and the unending list of other questions that arise on a daily , hourly or even per-minute basis during any add-in development.

 

For a more powerful approach still, install an interactive interpreted programming shell for deeper and more intimate database exploration, e.g. like this:

 

http://thebuildingcoder.typepad.com/blog/2013/11/intimate-revit-database-exploration-with-the-python...

 

Good luck, and have fun!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4
annp_mth
in reply to: jeremytammik

Hello Jeremy,

Your blog at TheBuildingCoder is one of my favourite blogs about Revit API. The 2 built in parameters in my codes were found out by using Snoop Current Selection. After reading your reply, I've studied deeper and found out why I were wrong. My new code doesn't look professionally but it worked (C# is not my field):

 

	   UIDocument  uidoc = new UIDocument(Document);
            Document doc = uidoc.Document;
            ElementSet colcot = uidoc.Selection.Elements;
            foreach(Element e in colcot)
    		{
				Parameter pB = e.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_PARAM);
				Element mB = doc.GetElement(pB.AsElementId());
				Parameter pT = e.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_PARAM);
				Element mT = doc.GetElement(pT.AsElementId());
				TaskDialog.Show("aaa",mB.Name+"&"+mT.Name);
    		}

 Thank you very much! 🙂

Message 4 of 4
jeremytammik
in reply to: annp_mth

Dear annp_mth,

 

Great!

 

Thank you very much for the appreciation!

 

I am glad you find the blog useful, and are using RevitLookup.

 

Your code looks perfectly fine to me.

 

Congratulations on solving it!

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community