ConnectorManager Connectors in Random Order and Id only available in 2016

ConnectorManager Connectors in Random Order and Id only available in 2016

jonathan.umscheid
Participant Participant
1,450 Views
7 Replies
Message 1 of 8

ConnectorManager Connectors in Random Order and Id only available in 2016

jonathan.umscheid
Participant
Participant

I found that ConnectorManager.Connectors (which is a ConnectorSet) returns its list of Connectors in a different order each time the function is called.  I'm not sure what is causing this, but I'm looking for a work-around to always get them in sequential order by Connector.Id.  In 2016, I can use Connector.Id, but in 2015, the Id property doesn't exist.  I also tried using the ConnectorSet.ForwardIterator() but it returns the connectors in random order from one call to the next as well.  One might expect the connectors to be returned by Id order, 0, 1, etc., but that's not the case.  The fact that each time the function is called, they are returned in a different order makes it difficult to use.  Anyone have a solution to this for 2014 & 2015?

0 Likes
Accepted solutions (1)
1,451 Views
7 Replies
Replies (7)
Message 2 of 8

Charles.Piro
Advisor
Advisor

Hello,

 

what is your goal ? what addin do you want achieve ?

I can't help you for find a solution with just your post.

 

Smiley Wink



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 3 of 8

Revitalizer
Advisor
Advisor

Hi,

 

what about sorting them by Origin (XYZ) property ?

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 4 of 8

jonathan.umscheid
Participant
Participant
I have been working with conduit, duct, and pipe. I'm just trying to get a consistent list of connector points from them. It makes it difficult when the list of connectors is returned in a different order each time, so I can't rely on them being ordered from start to end or from end to start for the part.
0 Likes
Message 5 of 8

jonathan.umscheid
Participant
Participant
Thanks for the reply. It is a step in the right direction. I think I will have to rely on the coordinates eventually to solve this one. However, if the user modifies the points, they could be returned in a different order than from a previous call, so the order could still change. I think I'll have to rely on knowledge of the connections to adjacent parts as well to solve this.
0 Likes
Message 6 of 8

Charles.Piro
Advisor
Advisor

Hi,

 

I understand that you want achieve. I created an addin with the same idea (for track a system), and I used the position of connector.

 

Good luck !!

Smiley Wink

 

Charles

 

 



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 7 of 8

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

conduits, ducts and pipes are line based, so you can sort the (two) connectors by comparing their origins with the location of (or the distance to) (pipe.Location as LocationCurve).Curve.GetEndPoint(0)

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 8 of 8

bogdan.scaueru
Explorer
Explorer

Hello,

I have the same issue using the REVIT 2019.2, trying to identify the FamilyInstance of the connector using the following code:

 

     Private Function getEDB_Connector2Family(cLinkSystem As ElectricalSystem, cSizePanelName As stringAs Object
        Dim cPanels = New FilteredElementCollector(_DOC).ofCategory(BuiltInCategory.OST_ElectricalEquipment).WhereElementIsNotElementType().ToList()
        Dim cPanelConnectors As Object
        Dim cPanelConnector As Connector
        Dim cLinkPanel As Object
        Dim cLinkPanelName As String
        
        Dim cLinkConnectors As Object
        Dim cLinkConnector As Connector
        
        cLinkConnectors = cLinkSystem.ConnectorManager.Connectors.GetEnumerator()
        Do While cLinkConnectors.MoveNext()
            
            cLinkConnector = cLinkConnectors.Current()
            For Each cLinkPanel In cPanels
                cPanelConnectors = cLinkPanel.MEPModel.ConnectorManager.Connectors.GetEnumerator()
                Do While cPanelConnectors.MoveNext()
                    
                    cPanelConnector = cPanelConnectors.Current()
                    If cLinkConnector.Id = cPanelConnector.Id Then
                        
                        cLinkPanelName = ParameterValue(cLinkPanel, "CX_NAME")
                        If cLinkPanelName <> cSizePanelName Then
                            Return cLinkPanel
                        Else
                            Exit Do
                        End If
                    End If
                Loop
            Next
        Loop
    End Function

 

The cLinkSystem  contains 2 connectors. The idea is that cLinkConnector.Id returns either "1" or "0" while the cPanelConnector.Id returns a more meaningful value of "5000x"

I'm trying to identify the FamilyInstance of the circuit connector.

 

Kind regards,

Bogdan

0 Likes