Skip to content

Commit

Permalink
implemented CmdMepElementShape.GetProfileTypes returing all duct conn…
Browse files Browse the repository at this point in the history
…ector shapes
  • Loading branch information
Jeremy Tammik committed Feb 24, 2016
1 parent a508b37 commit 91f2cbd
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 5 deletions.
69 changes: 66 additions & 3 deletions BuildingCoder/BuildingCoder/CmdMepElementShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
Expand Down Expand Up @@ -721,7 +722,7 @@ public void Duct_from_AutoCad()
/// Determine element shape from its
/// element type's family name property.
/// </summary>
static public string GetElementShape4(
static string GetElementShape4(
Element e )
{
string shape = "unknown";
Expand All @@ -742,6 +743,49 @@ static public string GetElementShape4(
}
return shape;
}

/// <summary>
/// Return shape of first end connector on given duct.
/// </summary>
static ConnectorProfileType GetShape( Duct duct )
{
ConnectorProfileType ductShape
= ConnectorProfileType.Invalid;

foreach( Connector c
in duct.ConnectorManager.Connectors )
{
if( c.ConnectorType == ConnectorType.End )
{
ductShape = c.Shape;
break;
}
}
return ductShape;
}

/// <summary>
/// Return shape of all duct connectors.
/// </summary>
static ConnectorProfileType[] GetProfileTypes(
Duct duct )
{
ConnectorSet connectors
= duct.ConnectorManager.Connectors;

int n = connectors.Size;

ConnectorProfileType[] profileTypes
= new ConnectorProfileType[n];

int i = 0;

foreach( Connector c in connectors )
{
profileTypes[i++] = c.Shape;
}
return profileTypes;
}
#endregion // MEP Element Shape Version 4

public Result Execute(
Expand Down Expand Up @@ -777,14 +821,33 @@ public Result Execute(
break;
}

Util.InfoMsg( string.Format(
string s = "Not a duct.";

Duct duct = e as Duct;

if( null != duct )
{
ConnectorProfileType[] profileTypes
= GetProfileTypes( duct );

n = profileTypes.GetLength( 0 );

s = string.Format( "{0} connectors:\r\n", n )
+ string.Join( "\r\n", profileTypes
.Select<ConnectorProfileType, string>(
a => a.ToString() ) );
}

string msg = string.Format(
//"{0} is {1} {2} ({3})",
"{0} is {1}-{2} ({3})",
Util.ElementDescription( e ),
//MepElementShapeVersion3.GetElementShape( e ),
GetElementShape4( e ),
MepElementShapeVersion2.GetElementShape( e ),
MepElementShapeV1.GetElementShape( e ) ) );
MepElementShapeV1.GetElementShape( e ) );

Util.InfoMsg2( msg, s );

if( preselected ) { break; }
}
Expand Down
5 changes: 3 additions & 2 deletions BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
// 2015-12-22 2016.0.126.1 cleaned up for publication
// 2016-01-08 2016.0.126.2 incremented copyright year
// 2016-02-24 2016.0.126.3 implemented CmdMepElementShape.GetElementShape4 and break selection loop if element is preselected
// 2016-02-24 2016.0.126.4 implemented CmdMepElementShape.GetProfileTypes returing all duct connector shapes
//
[assembly: AssemblyVersion( "2016.0.126.3" )]
[assembly: AssemblyFileVersion( "2016.0.126.3" )]
[assembly: AssemblyVersion( "2016.0.126.4" )]
[assembly: AssemblyFileVersion( "2016.0.126.4" )]

0 comments on commit 91f2cbd

Please sign in to comment.