Change Duct Element paramater, "System Type" from "Undefined" to "Supply Air"

Change Duct Element paramater, "System Type" from "Undefined" to "Supply Air"

MehtaRajesh
Advocate Advocate
1,319 Views
2 Replies
Message 1 of 3

Change Duct Element paramater, "System Type" from "Undefined" to "Supply Air"

MehtaRajesh
Advocate
Advocate

Hi,

In Revit MEP

We are trying to update Duct Element paramater, "System Type" from "Undefined" to "Supply Air" programatically.

 

The code is written as below

 

;;Duct Selection

UIApplication app = commandData.Application;

Document doc = app.ActiveUIDocument.Document;

Selection sel = app.ActiveUIDocument.Selection;

Reference ref1 = sel.PickObject(ObjectType.Element, "please pick a duct");

Duct objDuct = doc.GetElement(ref1) as Duct;

 

;; Filter

List<ElementId> DuctSystemTypelst = new FilteredElementCollector(doc).OfCategory

(BuiltInCategory.OST_DuctSystem).ToElementIds().ToList();

 

;;Getting the parameter value of System Type

Parameter systy = objDuct.get_Parameter(BuiltInParameter.RBS_DUCT_SYSTEM_TYPE_PARAM);

 

;;Setting the Parameter value of "System type"  to "Supply Air", as "Supply Air" is at second position of DuctSystemTypelst

systy.Set(DuctSystemTypelst[1]);    (RETURNING TRUE)

 

Afterwards when we check value of "System type" parameter of selected duct using

systy.asElementid();

 

Returning {-1}  means Undefined

 

Please help to solve the issue

Thanks in advance for your kind support in this regards

0 Likes
1,320 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

Dear Mehta Rajesh,

 

Thank you for your query.

 

You are retrieving the list of duct system types in DuctSystemTypelst and using [1] to access the second entry in the list.

 

You are not checking how many entries it contains, nor what the value of the second entry happens to be.

 

Is that intentional?

 

Maybe the second value is exactly ElementId.Undefined, e.g., -1.

 

How about assigning it to an intermediate value and having a look in the debugger, e.g.,

 

  ElementId systemTypeId = DuctSystemTypelst[1];

 

Maybe you actually want

 

  ElementId systemTypeId = DuctSystemTypelst[0];

 

Here is a Chinese article on editing ducts that may be of interest to you:

 

http://www.cnblogs.com/zhangchen-87/articles/2385250.html

 

Google translate will happily translate it for you.

 

It includes a snippet of code showing how to set the value of the RBS_DUCT_SYSTEM_TYPE_PARAM built-in parameter.

 

You may also be interested in taking a look at the AdnRme sample, which show lots of other interesting duct related stuff:

 

https://github.com/jeremytammik/AdnRme

 

I hope this helps.

 

Best regards,

 

Jeremy



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

0 Likes
Message 3 of 3

MehtaRajesh
Advocate
Advocate

Hi Jeremy,

Thanks for your quick reply.

There are three duct system types  "Exhaust Air", "Return Air" and "Supply Air" hence ElementId.Undefined is not be the case.

Whille Debugging also we are getting  the required duct system type in DuctSystemTypelst list at second element DuctSystemTypelst(1)

Regards,
Rajesh






0 Likes