Revit API Dimensions

Revit API Dimensions

Anonymous
Not applicable
6,193 Views
17 Replies
Message 1 of 18

Revit API Dimensions

Anonymous
Not applicable

Hi. Is there a way to retrieve the dimensions of beam/wall/column/floor using c#?

I hope that you can help because I was searching the whole forum and didn't find anything related.

Note: Revit 2015

 

Thank you for your time.

0 Likes
6,194 Views
17 Replies
Replies (17)
Message 2 of 18

jeremytammik
Autodesk
Autodesk

I suggest you search a bit more.

 

I see lots of answers, e.g.,

 

 

https://duckduckgo.com/?q=revit+api+wall+width+length+height

 

Cheers,

 

Jeremy

 

 

 



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

Message 3 of 18

Anonymous
Not applicable

Thank you for your response.

Is there a Builtin-parameter definition to get the dimensions of a column and beam.

For example, below is one to get length of a wall.

BuiltInParameter.CURVE_ELEM_LENGTH

 I am new to c# programming as this is a newbie question.

 

Thank you

0 Likes
Message 4 of 18

jamess166
Advocate
Advocate

Hi Jeremy

 

How could you automate the procedure to place the dimensions of all the structures foundations, such as the image. Thank you

 

 

Captura.PNG

0 Likes
Message 5 of 18

RPTHOMAS108
Mentor
Mentor

@Anonymous in Revit 2015 standard section shapes I believe had only just been introduced and therefore their adoption by family authors was likely incomplete or not at all. Perhaps out of the box had them completed, unsure.

 

You can check the families you use and see if the standardised section shape related parameter values have been filled out. In lieu of this you will have to create a fall back mapping system (where you relate the SP GUIDs to their meanings yourself) i.e. can make a generic data grid with SP GUID on the left and meaning to your application on the right.

 

If you are using standardised parameters then you need to refer to the ...Revit.DB.Structure.StructuralSections namespace, pick class that relates to the section shape of the family and use the properties of those sections. You can also still get these parameter values via the standard parameter fetching methods, use their built in parameter id such as: STRUCTURAL_SECTION_COMMON_HEIGHT.

 

Capture1703.PNG

0 Likes
Message 6 of 18

jamess166
Advocate
Advocate
Good day, one what I want, that I want to place the annotations of the dimension (dimensions) for each structural shoe in the view of the plant, like the image shown. I do not want to obtain its parameters or modify them.
0 Likes
Message 7 of 18

RPTHOMAS108
Mentor
Mentor

You should do a search for the Document.NewDimension method, this will offer the best help for you.

 

For anyone to explain the procedure for this would be repeating what already exists on the forum and in the RevitAPI.chm. Do you have a specific question related to a problem you are getting trying to dimension something?

0 Likes
Message 8 of 18

jeremytammik
Autodesk
Autodesk

@jamess166 your question is almost answered by these two discussions on dimensioning parallel walls using two different approaches, iterating their geometry to find appropriate faces, versus shooting a ray through them:

 

 

More discussions on creating dimensioning are listed in the topic group on that:

 

 

In your case, you might want to

 

  • filter for all rectangular foundations
  • determine their two pairs or opposing vertical faces
  • create dimensioning between those

 

Cheers,

 

Jeremy

 



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

0 Likes
Message 9 of 18

Anonymous
Not applicable

when I read Beam Location, Beam Length, Elevation at Top and Elevation at Bottom from Revit by Revit API, The results are wrong

Example: 

on Revit program

Section of Beam = 30 * 60 cm

Beam Length = 4m

Elevation at top = 3 m

Elevation at bottom = 2.4 m

 

The results from Revit API

Start point = (-46.456047677, 38.915098248, 9.842519685)

End point = (-33.332688097, 38.915098248, 9.842519685)

Beam Length = 13.1233595800525m

Elevation at top = 9.84251968503937 m

Elevation at bottom = 7.87401574803149 m

 

Why are the results from Revit API wrong?

 

my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB.Structure.StructuralSections;

 

namespace Plug_In
{
[Transaction(TransactionMode.Manual)]
public class Plug_In : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
// Get Document & UIDocument
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = commandData.Application.ActiveUIDocument.Document;

// Get All BuiltInParameter
IList<BuiltInParameter> allParameter = Enum.GetValues(typeof(BuiltInParameter)).Cast<BuiltInParameter>().ToList();


String InfoBeam = null;

// Get Beams

ElementCategoryFilter beamFilter = new ElementCategoryFilter(BuiltInCategory.OST_StructuralFraming);

IList<Element> allBeams = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).WherePasses(beamFilter).WhereElementIsNotElementType().ToElements();

int BeamCount = allBeams.Count;

// Parameter of Cross Section For Concrete Beam
Parameter beamConcreteHeight = null;
Parameter beamConcreteWidth = null;

foreach (Element ele in allBeams)
{
//Get Element Type
ElementId eleTypeId = ele.GetTypeId();
ElementType eleType = doc.GetElement(eleTypeId) as ElementType;

// Get Height & Width of beam

beamConcreteHeight = eleType.LookupParameter("h");
beamConcreteWidth = eleType.LookupParameter("b");

LocationCurve beamPosition = ele.Location as LocationCurve;

// Get Parameter of Beam
ElementId referenceLevel = null;
ElementId beamMaterial = null;

double startLevelOffset = 0;
double endLevelOffset = 0;
double Length = 0;
double elevationAtTop = 0;
double elevationAtBottom = 0;

Element elementReferenceLevel = null;
Element elementBeamMaterial = null;

foreach (BuiltInParameter bb in allParameter)
{
Parameter p = ele.get_Parameter(bb);

if (p != null)
{
if (p.Definition.Name == "Reference Level")
{
referenceLevel = p.AsElementId();
elementReferenceLevel = doc.GetElement(referenceLevel);
}
if (p.Definition.Name == "Start Level Offset")
{
startLevelOffset = p.AsDouble();
}
if (p.Definition.Name == "End Level Offset")
{
endLevelOffset = p.AsDouble();
}
if (p.Definition.Name == "Length")
{
Length = p.AsDouble();
}
if (p.Definition.Name == "Elevation at Top")
{
elevationAtTop = p.AsDouble();
}
if (p.Definition.Name == "Elevation at Bottom")
{
elevationAtBottom = p.AsDouble();
}
if (p.Definition.Name == "Structural Material")
{
beamMaterial = p.AsElementId();
elementBeamMaterial = doc.GetElement(beamMaterial);
}
}
}

InfoBeam += "Beam Name : " + ele.Name + Environment.NewLine
+ "Beam Category : " + ele.Category.Name + Environment.NewLine
+ "Beam Type Name : " + eleType.Name + Environment.NewLine
+ "Beam Family Name : " + eleType.FamilyName + Environment.NewLine
+ "Beam Id : " + ele.Id + Environment.NewLine
+ "Beam has a curve location." + Environment.NewLine
+ "Start Point : " + beamPosition.Curve.GetEndPoint(0).ToString() + Environment.NewLine
+ "End Point : " + beamPosition.Curve.GetEndPoint(1).ToString() + Environment.NewLine
+ "Beam Height : " + GetParameterValue(beamConcreteHeight) + Environment.NewLine
+ "Beam Width : " + GetParameterValue(beamConcreteWidth) + Environment.NewLine
+ "Beam Level : " + elementReferenceLevel.Name + Environment.NewLine
+ "Start Level Offset : " + startLevelOffset + Environment.NewLine
+ "End Level Offset : " + endLevelOffset + Environment.NewLine
+ "Beam Length : " + Length + Environment.NewLine
+ "Elevation at Top : " + elevationAtTop + Environment.NewLine
+ "Elevation at Bottom : " + elevationAtBottom + Environment.NewLine
+ "Beam Material : " + elementBeamMaterial.Name + Environment.NewLine + Environment.NewLine;

}

// Print The Results
TaskDialog.Show("Information", "Level Count : " + LevelCount + Environment.NewLine + Environment.NewLine
+ "Column Count : " + ColumnCount + Environment.NewLine + Environment.NewLine
+ "Information about Columns : " + Environment.NewLine + InfoColumn + Environment.NewLine
+ "Beam Count : " + BeamCount + Environment.NewLine + Environment.NewLine
+ "Information about Beams : " + Environment.NewLine + InfoBeam + Environment.NewLine
+ "Floor Count : " + FloorCount + Environment.NewLine + Environment.NewLine
+ "Information about Floors : " + Environment.NewLine + InfoFloor + Environment.NewLine);

return Result.Succeeded;

}

public string GetParameterValue(Parameter parameter)
{
switch (parameter.StorageType)
{
case StorageType.Double:
return parameter.AsValueString();

case StorageType.ElementId:
return parameter.AsElementId().IntegerValue.ToString();

case StorageType.Integer:
return parameter.AsValueString();

case StorageType.None:
return parameter.AsValueString();

case StorageType.String:
return parameter.AsString();

default:
return "";
}
}
}
}

0 Likes
Message 10 of 18

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @Anonymous ,

The result of the Revit program is in meters and centimeters.

The result from the Revit API is in feet and inches.

 

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 11 of 18

Anonymous
Not applicable

Thanks For naveen.kumar.t

Results from Revit API are feet for Lengths and pound for forces

1 ton = 2000 ib

when I read force (this force = 1 ton in x-direction) from Revit through Revit API , the result is 32173.9291338583 (Fx = 32173.9291338583)

where is the mistake ?

my code is 

ElementCategoryFilter pointLoads = new ElementCategoryFilter(BuiltInCategory.OST_PointLoads);
IList<PointLoad> allPointLoads = new FilteredElementCollector(doc).WherePasses(pointLoads).ToElements().Cast<PointLoad>().ToList();

int pointLoadsCount = allPointLoads.Count;

foreach (PointLoad pointLoad in allPointLoads)
{
if (pointLoad != null)
{
LoadOrientTo loadOrientTo = pointLoad.OrientTo;

XYZ xyzforce = pointLoad.ForceVector;
XYZ xyzmoment = pointLoad.MomentVector;

InfoPointLoads += "Load case name : " + pointLoad.LoadCaseName + Environment.NewLine
+ "Load category name : " + pointLoad.LoadCategoryName + Environment.NewLine
+ "Load nature name : " + pointLoad.LoadNatureName + Environment.NewLine
+ "Load Orient To : " + loadOrientTo + Environment.NewLine
+ "FX : " + xyzforce.X + Environment.NewLine
+ "FY : " + xyzforce.Y + Environment.NewLine
+ "FZ : " + xyzforce.Z + Environment.NewLine
+ "MX : " + xyzmoment.X + Environment.NewLine
+ "MY : " + xyzmoment.Y + Environment.NewLine
+ "MZ : " + xyzmoment.Z + Environment.NewLine + Environment.NewLine;
}
if (pointLoad == null)
{
throw new Exception("Can't get Point Load.");
}
}

0 Likes
Message 12 of 18

TripleM-Dev.net
Advisor
Advisor

Use ConvertFromInternalUnits Method to convert the internal units to something you need to evaluate.

This way you dont need to "gamble" what the internal units are (the internal and displayed unit do need to be a same type). 

 

- Michel

 

Message 13 of 18

Anonymous
Not applicable

Thanks For you,  @TripleM-Dev.net 

0 Likes
Message 14 of 18

Anonymous
Not applicable

how can read the location of Loads (Point Load, Line Load & Area Load) that drew in Revit through Revit API?

0 Likes
Message 15 of 18

TripleM-Dev.net
Advisor
Advisor

Hi @Anonymous ,

 

I'm not familiar with point loads etc... see the documentation and/or install Revit Lookup to inspect the element.

 

In the documentation for the PointLoad Class there's a Point property is that what you're looking for?

PointLoad.Point Property 

 

and here a source for Lookup: https://github.com/jeremytammik/RevitLookup 

Message 16 of 18

vedant.bopardikar
Community Visitor
Community Visitor

I want a solution or a direction for something similar....any help would be appreciated 

0 Likes
Message 17 of 18

vedant.bopardikar
Community Visitor
Community Visitor
i want a solution or direction for something similar
0 Likes
Message 18 of 18

jeremy_tammik
Alumni
Alumni

Dear @vedant.bopardikar  and  @jamess166 , automatic dimensioning of walls is explained and demonstrated by The Building Coder in the following articles:

  

  

That approach can be easily adapted to create the dimension you require. Please note that FindReferencesByDirection has been renamed to ReferenceIntersector:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes