Python Forum
Sorting Elements via parameters pointing to those elements.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting Elements via parameters pointing to those elements.
#1
I am looking for an algorithm or sorting code that does not use function calls such as numpy or scipy. I am working with IronPython in Revit to sort contiguous elements so I cannot make calls to CPython functions. Each contiguous element is numbered, but not consecutively, but each element has two parameters that point to the element next to it. Lets say the parameters are called Point1 and Point2 and the elements are numbered 1-5.

When I sort by element number I get the following:

Point1 Point2 > 0 5,6 4,5 4,2 3,1 3
Element# > 1,2,3,4,5

Where Element# 1 has Point1 = 0 and Point2 = 5, Element# 2 has Point1 = 6 and Point2 = 4, etc.

But this does not represent the actual order of elements.

The actual order looks like the following:

Point1 Point2 > 0 5,1 3,5 4,2 3,6 4
Element # > 1,5,3,4,2

Element 1 is connected to element 5 is connected to element 3, etc., and Point1 and Point2 of each element# indicate what is connected to each side. Realize Point1 does not always show what element is on the left and point2 does not always show what is on the right, they can be reversed. The Point1 values of 0 and 6 indicate element#'s not show to the far left and right. The values of 0 and 6 could be anything other than 1-5 and that is determined by Revit. It is the relationship between the Point1 and Point2 values and the element# that matters. The element numbering and parameter values are determined by Revit which I have no control over, this is why I need to sort element#'s by using the Point parameter values. I am not a great programmer, please have mercy on me.
Reply
#2
please show code for what you have tried.
Reply
#3
(Jan-05-2021, 08:06 PM)Larz60+ Wrote: please show code for what you have tried.

I have only tried a solution in Dynamo before realizing I would need to do recursive in Python to accomplish my goals. I did not attempt any Python code as I am not a good programmer. If you have am idea of the generic looping algorithm I can adapt it.
Reply
#4
I was able to accomplish my goal using Dynamo and a little bit of Design Script. I do not see how to post jpg of my solution here. Thanks for the help.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Extracting Elements From A Website List knight2000 2 206 Jul-20-2021, 10:38 AM
Last Post: knight2000
  Make Groups with the List Elements quest 2 212 Jul-11-2021, 09:58 AM
Last Post: perfringo
  Matching two files based on a spited elements tester_V 5 400 May-30-2021, 07:49 PM
Last Post: tester_V
  I cannot delete and the elements from the list quest 4 605 May-11-2021, 12:01 PM
Last Post: perfringo
  List of lists - merge sublists with common elements medatib531 1 492 May-09-2021, 07:49 AM
Last Post: Gribouillis
  Testing Split elements tester_V 4 461 May-08-2021, 10:54 PM
Last Post: snippsat
  Take first Elements of sublists quest 2 408 Apr-26-2021, 11:32 AM
Last Post: buran
  Find Common Elements in 2 list quest 4 600 Apr-14-2021, 03:57 PM
Last Post: quest
  Group List Elements according to the Input with the order of binary combination quest_ 19 1,395 Jan-28-2021, 03:36 AM
Last Post: bowlofred
  4D array with only elements on one side of the diagonal schniefen 0 417 Dec-24-2020, 11:32 AM
Last Post: schniefen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020