Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.

Revit API Forum

Reply
Highlighted
Participant sr
Post 1 of 7

How to get duct shape?

180 Views, 6 Replies
02-23-2016 11:16 PM

 

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

 

我知道接口可以获得shape

Post 2 of 7

Re: How to get duct shape?

02-24-2016 12:16 AM 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


Don't forget to say 'thank you', it's just one click on the Kudos button.
Post 3 of 7

Re: How to get duct shape?

02-24-2016 01:27 AM 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

Post 4 of 7

Re: How to get duct shape?

02-24-2016 01:36 AM 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

Post 5 of 7

Re: How to get duct shape?

02-24-2016 01:40 AM 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


Don't forget to say 'thank you', it's just one click on the Kudos button.
Post 6 of 7

Re: How to get duct shape?

02-24-2016 03:05 AM 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

Post 7 of 7

Re: How to get duct shape?

02-24-2016 04:59 AM in reply to: jeremytammik

You're welcome.

 

thank you too Jeremy.

 

Smiley Wink

 

 



PIRO Charles
Developer
PIRO CIE
Linkedin

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post

Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.