Revit Server API Lib, Truss Members and Layers
Originally Published inToday, we proudly present:
- NuGet Revit Server REST API Library
- RevitLookup Updates
- Truss Members and FamilyInstance Sub-Components
- GeometryObject Layer Name
NuGet Revit Server REST API Library
Eric Anastas posted a comment on the discussion of Andrey Bushman’s NuGet Revit API package:
I created another Revit related Nuget package you and your readers may be interested in. It’s a .NET library that wraps the Revit Server REST API:
Many thanks to Eric for implementing and sharing this!
RevitLookup Updates
I integrated another couple of pull requests into RevitLookup.
Today, I added Einar Raknes ↗’ simple but significant one-liner to display the UnitType
or a parameter Definition
class instance ↗:
data.Add( new Snoop.Data.String( "Unit type",
paramDef.UnitType.ToString() ) );
Thanks to Einar for spotting this and creating the pull request #21 ↗ for it!
Here it is with a little bit more context:
private void
Stream( ArrayList data, Definition paramDef )
{
data.Add( new Snoop.Data.ClassSeparator( typeof( Definition ) ) );
data.Add( new Snoop.Data.String( "Name", paramDef.Name ) );
data.Add( new Snoop.Data.String( "Parameter type", paramDef.ParameterType.ToString() ) );
data.Add( new Snoop.Data.String( "Parameter group", paramDef.ParameterGroup.ToString() ) );
data.Add( new Snoop.Data.String( "Unit type", paramDef.UnitType.ToString() ) );
ExternalDefinition extDef = paramDef as ExternalDefinition;
if( extDef != null )
{
Stream( data, extDef );
return;
}
InternalDefinition intrnalDef = paramDef as InternalDefinition;
if( intrnalDef != null )
{
Stream( data, intrnalDef );
return;
}
}
Check out the newest release in the RevitLookup GitHub repository ↗.
I am looking forward to your pull requests to add further enhancements that are important for you.
Truss Members and FamilyInstance Sub-Components
I have been pretty active lately in the Revit API discussion forum ↗, and so have Matt Taylor and Frank ‘Fair59’, who provided many important answers that I was not aware of.
I’ll pick up two of Franks nice succinct answers here today.
The first is on retrieving the components of a truss ↗:
Question: I would like to get the components of a truss. Using the API, I tried via the GroupId
property, but it doesn’t work. And in general, the components of a family.
Answer: Components of a truss:
Autodesk.Revit.DB.Structure.Truss _truss;
List<ElementId> _members = _truss.Members.ToList<ElementId>();
In general, for user created families:
FamilyInstance _instance;
List<ElementId> _members = _instance.GetSubComponentIds()
.ToList<ElementId>();
GeometryObject Layer Name
The second nice succinct answer by Frank ‘Fair59’ is on the GeometryObject
Layer Name ↗:
Question: I can loop the objects of a linked CAD file like this:
foreach( GeometryObject geometryObj in
dwg.get_Geometry( new Options() ) )
{
}
How can I access the layer name of the object?
Answer: The information is contained in the GraphicalStyle
element:
GraphicsStyle gStyle = document.GetElement(
geometryObj.GraphicsStyleId ) as GraphicsStyle;
The layer name is provided by gStyle.GraphicsStyleCategory.Name
.