Replicate "Connect To" MEP button

Replicate "Connect To" MEP button

jorge_morente
Participant Participant
566 Views
4 Replies
Message 1 of 5

Replicate "Connect To" MEP button

jorge_morente
Participant
Participant

Hi everyone, I've reviewed the forum and haven't found the exact case I want to discuss.

 

I'm trying to replicate the 'Connect To' button using the Revit API. For example, if we have a duct and a grille nearby, when I select the grille, click 'Connect To', and then select the duct, it automatically draws a small section of duct that connects the grille and the duct perpendicularly. This can only be done one at a time, so I want to create a script that allows you to select a group of grilles and have them all connect to the same duct.

 

Initially, I thought that if something can be done in Revit, it can be done with the API, but I already found out that’s not the case when it comes to splitting walls. So, it's possible this might not be feasible either, and I might need to find an alternative.

 

Before exploring other options, I've been researching the API and came across this method of MEPAnalyticalConnection Class: 

public static ISet<ElementId> CreateMultipleConnections(
	Document doc,
	ElementId typeId,
	IList<Connector> equipmentOpenConnectors,
	IList<ElementId> curveIdsToConnect
)

 

I've tried it, but I can't get it to work. Has anyone tested it before?

 

Thank you in advance.

 

0 Likes
567 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni

I asked the development team for you.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 5

jeremy_tammik
Alumni
Alumni

The development team replies:

   
What the user is trying to do will be challenging if the duct they are connecting to is split, so a tee can be placed as part of the solution. They will need to also include the new duct they trying to connect the other grills to. That was part of the reasoning for the way ‘Connect to’ was implemented.

  

The method `CreateMultipleConnects` is for the Analytical Pipe Connection element:

  

  

That element is not yet available for the duct domain.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 4 of 5

MarryTookMyCoffe
Collaborator
Collaborator

It is possible to do it(I did a prototype in past so it can be done) but it will be a lots of work, and for many connection it will work slow.
There is no good method in api to connect one object to another so all calculation will be on you.
If you know api and are reasonably good on math it can take like 1 -2 weeks.

It hard to just say in short how to start with it but here are some tips:


the biggest problem will be following what new pipes was made and if pipe that we star with was remove(it can happen for some tee creating).


SubTransaction are your friend use them to roll back some failures wit out losing everything

You can try using default api method like 'NewTransitionFitting', NewElbowFitting, NewTeeFitting , just take in to account limitation of this methods(like angle, length of pipes), most annoying will be tee because first and second connector is from the same pipe.

There is no big difference between place holder and pipe so if you gonna make method for pipe place holder work the same way.

 

There is a big bug in setting Radius for Connector, so if you live in coutry where you use ',' as decimal revit will give you out of range exception, so set up culture of dll to "en"

 

when you transform elements you will need to regenerate document for connectors to have a proper value of origin.

 

 

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 5 of 5

jorge_morente
Participant
Participant

Thank you very much, @jeremy_tammik and @MarryTookMyCoffe , for your contributions.

 

As Jeremik rightly pointed out, for now, that function is not implemented, and it needs to be done manually. First, I wanted to ask if there was any way to do it and save myself a few lines of code. Too bad.

 

I've already done it, and it seems to work well in all the scenarios I've tested: whether they are separated or directly vertical to the conduit, either above or below it, and even when the conduit has a slope.

 

Thank you, Marry, for the advice on dealing with the challenge. As you mentioned, there are certain problems that need to be solved. From my point of view, here are the most important considerations:

 

1. Create a method for intersecting a plane and a curve to obtain the intersection point on the conduit.
2. Initially, you will only have one conduit, but you need to regenerate that list each time you introduce a tee fitting.
3. If the conduit has a slope and you are connecting it to a conduit that is NOT perpendicular, you first need to create an auxiliary perpendicular conduit to create the tee, then delete the conduit, and depending on the case, rotate the tee along its axis and adjust the connector angle.

 

I believe these are the three most complex points to consider.

 

So far, I haven't encountered the decimal problem you mentioned with the radius. I assume it's because I'm not manually specifying a radius but rather using the one from an existing conduit. For example, when you create a pipe, there are two ways (actually three): connector + point, or point +point. When using connector + point, it creates the pipe with the diameter defined by the connector, and that’s what I use to define the diameter for the rest of the pipes. Maybe that's why.

 

If anyone reading this post has any questions about how to approach any of the steps I mentioned above, feel free to ask.

 

Best regards, and thanks again.

 

PS: Conduit = pipe or duct.

---