Something About AllRef

Something About AllRef

nitinjambhale
Advocate Advocate
1,053 Views
6 Replies
Message 1 of 7

Something About AllRef

nitinjambhale
Advocate
Advocate

Hello all,

I m developing app with revit API 2016. And i m having some issues with 

ConnectorObj.AllRef property.

 

Previously i thought it will return the connector of its attached element, but in some cases i was wrong.

 

As per API metadata, it says,

 

// Summary:
// All references of the connector.
//
// Remarks:
// A set of connectors that the connectors is connected to, including both physical
// connection and logical connection.

public ConnectorSet AllRefs { get; }

 

------------------------------------------------------

In some cases i m getting AllRef count as 2 and in some it is 1(as i expected).

 

Can you guys explain about this behaviour?

 

Thanks & Regards,

-Nitin J.

 

 

 

 

0 Likes
Accepted solutions (1)
1,054 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk
Accepted solution

Afaik, the count includes both logical and physical connectors.

 

Check their properties to tell them apart:

 

https://github.com/jeremytammik/AdnRme/blob/master/AdnRme/CmdElectricalConnectors.cs

 

Cheers,

 

Jeremy



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

Message 3 of 7

nitinjambhale
Advocate
Advocate

ok.. that was what i need to confirm...

 

Thank you for the reply..

0 Likes
Message 4 of 7

PerryLackowski
Advocate
Advocate

Sorry to resurrect this thread, but I'm wondering if one of you could explain the differences between the logical and physical connectors. I'm looking at segments of duct/pipe/cable tray/conduit. They just have two end connectors, and if the end is connected, connector.AllRefs will return two connectors - it appears to be returning itself, plus the connector on whatever element it is linked to. Both have their ConnectorType as End, so I'm thinking these are physical connectors.

  1. Is it possible to have more than these two physical connections at the connector?
  2. When would I encounter a logical connector?

For some context, I'm trying to get the connector for the attached element, but I want to make sure my script doesn't accidently get more connectors than it's expecting.

0 Likes
Message 5 of 7

jeremy_tammik
Alumni
Alumni

The only really safe way to proceed is to collect every single possible case that can occur in all the models you are working with and incorporate unit testing to ensure that you capture and properly handle all possibilities. With that in hand, you could let the community know for sure what is valid and what not. Meanwhile, a also asked the development team for you.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 6 of 7

PerryLackowski
Advocate
Advocate

I suppose that makes sense, given all the other ways connectors could be used. For now I have taken the same approach from your CmdElectricalConnectors.cs (see python below). However, I could see it only returning the last end connector in the list if there were somehow more than two. I have had no problems using it for duct/pipe/conduit/cable tray so far, but I'll let you and the community know if I encounter any challenges. Thanks!

def get_attached_connector(connector):
    # Returns the connector attached to the provided connector

    referenced_connectors = connector.AllRefs
    attached_connector = None
    for referenced_connector in referenced_connectors:
        if referenced_connector.Owner.Id.Equals(connector.Owner.Id) or \
            referenced_connector.ConnectorType != DB.ConnectorType.End:
            continue
        attached_connector = referenced_connector
    return attached_connector

 

0 Likes
Message 7 of 7

jeremy_tammik
Alumni
Alumni

Thank you! The development team replied to your questions above:

   

  • No, not possible to connect with two different physical connectors. One connector can be unconnected or connect to another physical connector. Be careful about the reference to the other end of the same element.
  • The logical connector represents the connection to the hvac or piping system. These systems are automatically created with logical connectors to reference the boundary physical connectors. So the open end physical connectors and the system logical connectors are referenced to each other, just like the physically connected elements where two physical connectors are referenced to each other.
  • There are other ConnectorTypes, such as Curve (Connecting to takeoffs from the main segment), Reference (Connecting to Insulation/Lining element), Surface (special surface mounting of certain electrical family instances), and etc. Be sure to limit the returned reference connector type in your script, based on the application context.

   

Hope this helps.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes