How to get ConnectorSet or Connectors from FamilyInstance correctly?

How to get ConnectorSet or Connectors from FamilyInstance correctly?

gnab
Enthusiast Enthusiast
628 Views
2 Replies
Message 1 of 3

How to get ConnectorSet or Connectors from FamilyInstance correctly?

gnab
Enthusiast
Enthusiast

Hello, everyone. I can't get ConnectorSet of FamilyInstance. I did almost the same thing like with Pipe but I got the Exception with FamilyInstanse. I tried also to get Connectors with LookUp method but sometimes I got the same Exception again. Why? How to get ConnectorSet of FamilyInstance correctly? 

 

gnab_1-1661626840284.png

gnab_0-1661630659434.png

 

 

 

Accepted solutions (1)
629 Views
2 Replies
Replies (2)
Message 2 of 3

gnab
Enthusiast
Enthusiast
Accepted solution

I think I can beat it. After placement of FamilyInstance you need to do doc.Regenerate() and then get Connectors from ConnectorSet with foreach cycle and creation a list of connectors. ConnectorSet and Lookup of FamilyInstance doesn't work correctly (ConnectorSet or one of Connectors provoke the Exception)..It's not normally, I suppose, because all of these methods work very well with Pipe but not with FamilyInstance. Devs should fix it.

0 Likes
Message 3 of 3

reylorente1
Collaborator
Collaborator

Este es un metodo extraido de SDK Revit(

This is a method extracted from Revit SDK

)

 

/// <summary>
        /// Get all the connectors of a specific element
        /// </summary>
        /// <param name="element">the owner of the connector</param>
        /// <returns>if found, return all the connectors found, or else return null</returns>
        private ConnectorSet GetConnectorsElem(Autodesk.Revit.DB.Element element)
        {
            if (element == null) return null;
            FamilyInstance fi = element as FamilyInstance;
            if (fi != null && fi.MEPModel != null)
            {
                return fi.MEPModel.ConnectorManager.Connectors;
            }
            MEPSystem system = element as MEPSystem;
            if (system != null)
            {
                return system.ConnectorManager.Connectors;
            }

            MEPCurve duct = element as MEPCurve;
            if (duct != null)
            {
                return duct.ConnectorManager.Connectors;
            }
            return null;
        }

 

 

0 Likes