Hi all, I want to arrange string values in increasing order. Is there anyway to that ?
the order should be for example - C1, C2,…
Hi all, I want to arrange string values in increasing order. Is there anyway to that ?
the order should be for example - C1, C2,…
Hi @Draxl_Andreas thanks for the response.
It is not working for me, I have already tried it. but the result was the same
Hi @sovitek I have a problem like as shown in below
Nomenclature for concrete columns begin with “C” and steel columns begin with “SC” so how should I use separator in string.split
It is like the columns are grouped based on type (“groups”)
The following python code will help overcome issues with C2 being after C10 for example.
# Created By Brendan Cassidy
cGroup=[]
scGroup=[]
OUT=[]
for a in IN[0]:
if a.startswith("SC"):
scGroup.append(a)
elif a.startswith("C"):
cGroup.append(a)
cGroup=sorted(cGroup, key = lambda x: int(x[1:]))
scGroup=sorted(scGroup, key = lambda x: int(x[2:]))
OUT=cGroup,scGroup
@Brendan_Cassidy thanks for your response. which version of dynamo and revit are you using ?
As I have checked with Revit api docs for 2020 Revit version, this method is not defined. So I have changed some what like this but still it is not working for me.
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
cGroup=[]
scGroup=[]
OUT=[]
for a in IN[0]:
if a.Contains("SC"):
scGroup.append(a)
elif a.Contains("C"):
cGroup.append(a)
cGroup=sorted(cGroup, key = lambda x: int(x[1:]))
scGroup=sorted(scGroup, key = lambda x: int(x[2:]))
TransactionManager.Instance.TransactionTaskDone()
OUT=cGroup,scGroup
Can you please tell me how to resolve this ?
Hi @Brendan_Cassidy it was not working for me but I found the solution.
Thank you all for your support
The code uses general Python principles and therefor you was complicating matters via assuming everything in python is Revit based. Easiest way is to see that there is no “Revit” based imports therefore it is not using revit methods.
When you submit issues it is worth indicating more of your graph, what the error messages(if any) and any other information. We have to speculate on what the issue is or what the input possibly could be.
I assumed you had a list of string prior to you joining them together with the “String from List” node. Which i assume you tried to put the single string into the python node. This single string was the root cause of your errors and adding many complications when not necessary. Put in the list of strings to generate a new organised list of items, then you use the string from list(if you still need it) would have been your answer.
Hi @Brendan_Cassidy I understand that but due to organisation privacy I can’t paste the full graph but I was getting the error as below
I was feeding the list of string values only. For the reference I am attaching the snip
Flatten that list so it is not a list of a list of strings.
Eg Watch node > Flatten Node > Python Node
What is the code within the Python Node and is everything out of the flatten node a single list of values(eg SC1, C1, etc)
The output from the flatten node, is everything fairly right that they are all beginning with C or SC? Are any with a SCC1(eg incorrect type marking)? Only beginning with C?
Good evening,
Here is a solution, necessarily improvable,
I begin
If you can’t find the String.GetNumber node, you have the one in the GeniusLoci package
(see picture 2)
Cordially
christian.stan
essai de classemnt ascendant.dyn (17.3 KB)
Good evening, you have the Swiss army knife node, List SortNatural from the GeniusLoci package
even faster
cordially
christian.stan
There used to be a fuzzy logic package.
Even more fun
Don’t know if it’s still there, or even works, I’m talking a few years back here