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 can we set the value of Specific Loss in API

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Anonymous
792 Views, 8 Replies

How can we set the value of Specific Loss in API

Good Morning,

 

I'm an HVAC Engineer and I'm working on Revit 2016-17-18 and I use Visual Studio to develop a software.

I would like to know how can I set the value of the specific loss in duct fittings. I've already managed to set the "Loss Method" to "Specific loss" but I can't find a way to set the value. I'm sure that it's possible because the user can manually set the value in the parameter window which pops up when he clicks on "Modify".

I thought that it was linked to the RBS's BuiltInParameter but I couldn't do anything.

For instance I would like something like this:

 

Parameter pressureLoss = fitting.specificLossPressure.Set(10); in the API

 

And in Revit it should write 10Pa in the Pressure loss field of the fitting

 

Anyone can help me with this please ?

 

Best Regards,

 

Guillaume Mayette

8 REPLIES 8
Message 2 of 9
matthew_taylor
in reply to: Anonymous

Hi @Anonymous,

I think AssignedPressureDrop is what you're looking for. It's a property of the connector class.

 

You may want to make it a more holistic solution and use a server.

Not my area of expertise, but check out this help link:

http://help.autodesk.com/view/RVT/2017/ENU/?guid=GUID-6708486B-6D46-49DF-8438-14EAAA6F0818

 

To quote the pertinent section: 'Third party developers can develop additional loss methods for fittings and accessories which may appear in this list.'

 

I think these are the API interfaces to research:

IDuctFittingAndAccessoryPressureDropUIServer

IDuctFittingAndAccessoryPressureDropServer

 


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 3 of 9
Anonymous
in reply to: matthew_taylor

Dear Mattew,

 

Thank you for your answer. I'll try your solution and let you know if it works.

 

Kind regards,

 

Guillaume Mayette

Message 4 of 9
Anonymous
in reply to: Anonymous

Mattew,

 

I've tried your solution but I'm not a developper and I don't know how I can get the list of connectors linked to the element selected by the user. I've tried to use something like a getConnector method but it doesn't exist. It seems more complicated than I thought.

 

Kind regards,

 

Guillaume Mayette

Message 5 of 9
matthew_taylor
in reply to: Anonymous

Hi @Anonymous,

Everything is tough without the right tool for the job! Have you installed RevitLookup yet? It is an invaluable tool. If you haven't installed it, drop everything and do it now.

 

Here's a snippet to help get some connectors:

Dim fitting As DB.MEPModel = famInstance.MEPModel
Dim fittingConnector0 As DB.Connector = _
   fitting.ConnectorManager.Lookup(0)
Dim fittingConnector1 As DB.Connector = _
   fitting.ConnectorManager.Lookup(1)

Also, refer here for help on getting started:

https://forums.autodesk.com/t5/revit-api-forum/check-out-the-self-paced-guide-my-first-plug-in/m-p/3032684#U3032684

 


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 6 of 9
Anonymous
in reply to: matthew_taylor

Hi Mattew,

 

Thank you for your help, I tried your code to get the connectors and it worked well !

However the problem is still there because I can't access to the pressure drop value. When I try to set the value I've got an exception "Failed to set assigned pressure drop". I've already try with another way to access that value (with the BuiltInParameter) but Revit told me that the parameter is a readonly value . However I know that the user can set the value of the pressure drop by choosing the loss method "Specific Loss" and set the value via a window.

I'm sure that we can do this in the API. 

It would be great because sometimes Revit provides wrong values. (Like hundred of billions Pascals wich is huge)

I'm looking the RevitLookup, thanks a lot for that.

 

 

PS : In the API I've set the loss method to "Specific Loss" and I was also unable to set the value of the pressure drop.

 

PS2 : I've put an example of Revit pressure calculation and how the user can set the value.

 

Guillaume Mayette

 

 

Message 7 of 9
matthew_taylor
in reply to: Anonymous

Hi @Anonymous,

Have you seen this blog post?:

http://thebuildingcoder.typepad.com/blog/2015/12/external-services.html#5

It provides example source code to show how to add your own calculations.


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 8 of 9
Anonymous
in reply to: matthew_taylor

Hi @matthew_taylor

 

I've download the file and tried to use it in Revit but even if I can see it in the Addins Ribbon, it doesn't do anything when I try to use it.

Maybe we can't set the pressure loss parameter of a fitting. If any Autodesk developer can help me with this (just telling me how to use the AssignedPressureDrop) it would be great.

 

Here is a sample of my code :

 

foreach (ElementId eleId in uidoc.Selection.GetElementIds())
{

    Element element = doc.GetElement(eleId);
    FamilyInstance fitting = doc.GetElement(eleId) as FamilyInstance;
    MEPModel MEPModelFitting = fitting.MEPModel;

    Connector fittingConnector1 = MEPModelFitting.ConnectorManager.Lookup(1);

 

    using (Transaction t = new Transaction(doc, "Test 1"))
    {
        try
        {
             t.Start();
             fittingConnector1.AssignedPressureDrop= 20;
             t.Commit();
        }
        catch (Exception ex)
        {
             t.RollBack();

             System.Windows.Forms.MessageBox.Show("Erreur Assigned Pressure Drop : " + ex.Message);
        }

    }

}

 

I've got the following error message : "Fail to set assigned pressure drop" without any explanations. I must tell you that it worked for another parameter like "Angle".

I have the same type of error using the BuiltInParameter.

 

I would be very thankful if someone could fix it.

 

Kind regards,

 

Guillaume Mayette

 

 

 

Message 9 of 9
Anonymous
in reply to: Anonymous

Just found the solution about the problem of values.

Go to Region setting of your computer (Start menu) and set the format : English (United States)

The strange values of pressure drop disappear but they are still incorrect. Nevertheless you can more or less trust Revit's pressure drop values. I advise everyone who whants to use Revit in order to calculate pressure drops to verify the values (especially Tees).

 

Kind regards,

 

Guillaume Mayette

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