Returning to a problem that has plagued me before, and hoping someone can help me with it.
I am trying to renumber elements in Revit (rooms in this instance). I have managed to create room numbers that have the unit number as a prefix, however the actual room number is just a random number assigned by Revit.
I am trying to give all numbers with the same prefix a unique number in sequence from 0 to 10. So any numbers with prefix AAAAA. will read AAAAA.01 AAAAA.02 AAAAA.03 etc. to complicate the matter, the list is not ordered. I could reorder it, export it to excel and try renumbering it there, but that messes up my selected order and the numbers no longer correspond to their element locations.
Any help would be greatly appreciated.
I’d recommend using a mix of booleans and RunMe’s. Try reading the first letter then using a comparison of some sort if(A=B) = true, then use the And node (will return true if all inputs are true aka all letters match the first).
I wish I had time to play around with it, but see if that gets you somewhere. I’ll pop back later to test it out. Cheers!
That’s pretty sweet. Unfortunately I think i’ve been looking at this too long and have gone wrong somewhere. My ordering has gone out of whack now.
My brain is a bit fried at the moment, I’ll have to look at it in the morning.
People can probably make this alot more efficient than I did now just on a whim, but I wrote a python script into which you can put a set of strings, and get them out like you wanted, in sequence 0 to what ever.
Note: if you want the numbering to be 001 or 0001 and so on, just change the value in “zfill( )” in the code to the amount of integers you want to show.
Also note: Unique values in this script will not get an index number. If you want all values to get indexed, just change the “if count > 1:” into “if count > 0:” and you will get all values indexed.
This is the code you put into the script
OUT = []
initstrings = []
indices = []
count = 0
outputstring = IN[0]
for string in IN[0]:
initstrings.append(len(string))
for i in range(0, len(IN[0])):
currentstring = IN[0][i]
if not len(outputstring[i]) > initstrings[i]:
for string in range(0, len(IN[0])):
if currentstring == IN[0][string]:
count += 1
indices.append(string)
if count > 1:
x = 0
for i in indices:
outputstring[i] = IN[0][i]+"."+str(x).zfill(2)
x += 1
x = 0
count = 0
indices = []
OUT = outputstring
You’re right, I managed to to get it to work this morning.
I can’t seem to export just the zoomed part of the screen, have to do the whole workflow. I’ve tried cropping the resulting image. Hopefully its readable.
Python is really easy to learn, I have been selfstudying python and use of the RevitAPI whenever I have had the time for something like the last 6 months. I can already get alot of use from it even though I am quite the novice! Go for it! Feel free to mark the solution to your question
Well I started with https://learnpythonthehardway.org, but I have been recommended not to use that as a startingpoint after I had gone through it. So I am not sure what would be the best place to start I think it worked for me, but then again, I probably don’t write the best code either