Anuncios

Los Foros de la Comunidad de Autodesk tienen un nuevo aspecto. Obtén más información sobre los cambios en el tablón de anuncios de la comunidad.

TraversePipeSystem

reylorente1
Advocate

TraversePipeSystem

reylorente1
Advocate
Advocate

Hola

Estoy haciendo un recorrido de tubería en este ejemplo,y utilice parte del código de TraverseSystem del SDK y tambien MepSystemSearch del the_building_coder_samples-master y obtuve este resultado.

 Cuando ejecuto el addin, obtengo la tabla del recorrido del tanque -l lavamano ,click escape y cuando lo vuelvo ejecutar, obtengo la tabla, pero esta vez del tanque - ducha, y si repito, entonces, obtengo, Tanque-Inodoro. La pregunta es cómo puedo obtener de un solo click ,el camino Tanque-Ducha. Alguna idea.

Aquí están mis archivos.

Hello
I'm doing a pipeline traversal in this example, and I used some of the code from TraverseSystem from the SDK and also MepSystemSearch from the_building_coder_samples-master and got this result.
 When I run the addin, I get the tank run table -l sink ,click escape and when I run it again, I get the table, but this time from tank - shower, and if I repeat, then I get Tank-Toilet. The question is how can I get the Tank-Shower path with a single click. Any ideas.
Here are my files.
0 Me gusta
Responder
245 Vistas
2 Respuestas
Respuestas (2)

snajjar
Contributor
Contributor

From what I understand from the translation and reading the code is that you are trying to find a path between 2 nodes in a network by defining the number of elements in-between? (int y=21;) this is not efficient and could easily give you the wrong path if there are multiple paths in the network with the same number of elements. The code has no way to decide which end (shower in this case) it should find, you should think of providing a selection of 2 ends and try to find the path between them.

 

The code has a bunch of problems, it would be a lot of work to correct it, but I've made some comments that might help:

        public List<ElementId> RunStepThroughElements(List<ElementId> eIds)
        {
            eIds = m_lVistited; //Overwriting the functions parameter eIds means that you don't need the parameter in the first place
            if (pPrev != null)
            {
                ConnectorSet pConnset = GetConnectors(pPrev);
                foreach (Connector pConn in pConnset)
                {
                    if (pConn.IsConnected)
                    {
                        // Get the connector connected to current connector
                        c = GetConnectedConnector(pConn);
                        if (c != null)
                        {
                            Element prNext = c.Owner;
                            m_lVistited.Add(prNext.Id);
                            pPrev = prNext;
                        }
                    }
                }

                m_iLoops++; //using a class member as a counter does not seem like a good practice
            }
            int y = 21; //hard coded value? what if you have more that 21 elements?
            if ((m_lVistited.Count <= m_lSelectedElts.Count)
                       && (m_iLoops <= MAX_LOOPS))
            {
                RunStepThroughElements(eIds); //Running the function again on the same group of elements? This will provide no progress
                if (eIds.Count != y)
                {
                    RunStepThroughElements(eIds);
                }
            }
            return m_lVistited;
        }

 

Also it might be worth a while to read up on Inorder Traversal Of an N-ary Tree

 

Hope this helps!

0 Me gusta

reylorente1
Advocate
Advocate
Thanks for your answer, really the correct method (function) is this..., 

 

 

public List<ElementId> RunStepThroughElements()
        {
            if (pPrev != null)
            {
                ConnectorSet pConnset = GetConnectors(pPrev);
                foreach (Connector pConn in pConnset)
                {
                    if (pConn.IsConnected)
                    {
                        // Get the connector connected to current connector
                        c = GetConnectedConnector(pConn);
                        if (c != null)
                        {
                            Element prNext = c.Owner;
                            m_lVistited.Add(prNext.Id);
                            pPrev = prNext;
                        }
                    }
                }
                m_iLoops++;
            }
            if ((m_lVistited.Count < m_lSelectedElts.Count)
                       && (m_iLoops < MAX_LOOPS))
            {
                RunStepThroughElements();
            }
            return m_lVistited;
        }

 

although I know that m_iLoops++;
....
 && (m_iLoops < MAX_LOOPS)) is not recommended, That value of 21, is a test, to see if the Shower Tank node was selected.
Thanks for your suggestion
 
0 Me gusta