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: 

How to get duct shape?

8 REPLIES 8
Reply
Message 1 of 9
sr
Contributor
1242 Views, 8 Replies

How to get duct shape?

 

有没有简单的办法直接获得风管的DuctShape?

 

我知道接口可以获得shape

8 REPLIES 8
Message 2 of 9
Revitalizer
in reply to: sr

Hi,

 

I really, really want to help anybody, but don't expect everyone to understand your mother tongue.

http://forums.autodesk.com/t5/revit-api/problema-na-instalacao-do-revit-2015/m-p/6047166/highlight/t...

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 9
jeremytammik
in reply to: sr

Dear Sr,

 

Thank you for your query.

 

Unlike Revitalizer, I understand you perfectly, thanks to Google translate.

 

You say: "There is no simple way to directly get Duct Shape Duct? I know the user interface can be obtained shape."

 

You are asking how to determine the cross sectional shape of a duct element.

 

This used to be a pretty hard question, once upon a time, and several different approaches could be taken, e.g. geometrical analysis, as you can see from these discussions on The Building Coder:

 

 

Another way to achieve this is to open the duct fitting family and query the DuctConnector element for its Shape property:

 

http://adndevblog.typepad.com/aec/2013/03/how-to-get-the-duct-section-shape-for-duct-type-object.htm...

 

Unfortunately, opening the family is quite a costly operation.

 

From Revit 2015 onwards, the simplest an most effective method to achieve what you need is to query the ElementType.FamilyName property:

 

http://thebuildingcoder.typepad.com/blog/2014/04/whats-new-in-the-revit-2015-api.html#4.05

 

In your case, that might look like this:

 

 

  /// <summary>
  /// Determine element shape from its 
  /// element type's family name property.
  /// </summary>
  static public string GetElementShape4(
    Element e )
  {
    string shape = "unknown";

    ElementId tid = e.GetTypeId();

    if( ElementId.InvalidElementId != tid )
    {
      Document doc = e.Document;

      ElementType etyp = doc.GetElement( tid )
        as ElementType;

      if( null != etyp )
      {
        shape = etyp.FamilyName;
      }
    }
    return shape;
  }

 

I added this code to The Building Coder samples release 2016.0.126.3, in the module CmdMepElementShape.cs, in lines 719-744:

 

https://github.com/jeremytammik/the_building_coder_samples

 

https://github.com/jeremytammik/the_building_coder_samples/releases/tag/2016.0.126.3

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...

 

I hope this helps.

 

Best regards,

 

Jeremy



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

Message 4 of 9
Charles.Piro
in reply to: Revitalizer

Hi,

 

like Revitalizer, I'm not sure, of that you want. With the title of your post, I understand that you want find the shape of a duct.

The solution is with the connector.

 

public ConnectorProfilType GetShape (Duct _duct)
{
  ConnectorProfilType ductShape = null;
foreach(Connector connect in _duct.ConnectorManager.Connectors) { if (connect.ConnectorType == ConnectorType.End) { ductShape = connect.Shape; break; } }
return ductShape; }

Smiley Wink



PIRO Charles
Developer

PIRO CIE
Linkedin


Message 5 of 9
Revitalizer
in reply to: Charles.Piro

Dear Charles,

 

sr is the author of the thread, not me.

And yes, that's the way to get the Shape, just using the connectors.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 6 of 9
jeremytammik
in reply to: sr

Thank you, Charles, for chiming in.

 

I published a summary of these suggestions here:

 

http://thebuildingcoder.typepad.com/blog/2016/02/ifc-import-levels-and-mep-element-shapes.html#3



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

Message 7 of 9
Charles.Piro
in reply to: jeremytammik

You're welcome.

 

thank you too Jeremy.

 

Smiley Wink

 

 



PIRO Charles
Developer

PIRO CIE
Linkedin


Message 8 of 9
matteoWNPXW
in reply to: Charles.Piro

From Revit 2019 onwards there is also a `Shape` property on the `MEPCurveType`: https://www.revitapidocs.com/2022/06152f02-9c8c-7f53-8e0b-a0d2adac505a.htm

Message 9 of 9
teocomi
in reply to: sr

From Revit 2019 onwards there is also a `Shape` property on the `MEPCurveType`: https://www.revitapidocs.com/2022/06152f02-9c8c-7f53-8e0b-a0d2adac505a.htm

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