Python code for Lists.ReplaceItemAtIndex

Hi all,

In our company we have some scripts that rely on the function Lists.ReplaceItemAtIndex (it’s a node from the Archi-lab package). As we have multiple customers with need of use different versions of Revit, we now have to uninstal the package everytime we switch from revit versions.
that’s quite annoying, and time consuming if we take in to account multiple users working on multipe computers.

So what i would like to do is: get rid of the use of Archi-lab by writing the code inside a python script.

this is when opening the script with Revit 2021 with correct version of archi-lab installed.

This is the message shown when opening in Revit 2022 when someone forgot to uninstall–>instal archi-lab

This is what the node to code shows from the node “Lists.ReplaceItemAtIndex”.
Archilab-knop in 2021 die werkt_code

This is what is listed inside the xml document of the package.

These are the xml files(saved as txt) from the package
archilab2021.txt (119.5 KB)
archilab2021_DynamoCustomization.txt (1.6 KB)

So to get back to my question:
Is it possible to write a pythonnode inside our script that works the same as “Lists.ReplaceItemAtIndex”. Or is there maybe someone who already wrote this one?

Thanks in advance

Gr Edward

Hello @1234eddie - Firstly just checking, does the out-of-the-box List.ReplaceItemAtIndex node not do what you are looking for?

1 Like

Rebuilding the hundreds of nodes in the packages you use as python nodes will 100% take more effort than deploying one version of your package library for each Revit build. Why not go that route instead of re-inventing the wheel?

@solamour
Unfortunatly the node “List.ReplaceItemAtIndex” does not what we are looking for. See screenshot and dynamo file below.

We can’t figure out a setting with levels that works, or do you know how to set it?

Dynamo file
Listreplaceitematindex forum.dyn (10.5 KB)

thanks in advance

Gr Edward

hello… try replace at index from clockwork, the ootb node had some problem with multiple replacement…

@sovitek
See picture below. it does the job.

But if there is an solution within the standard nodes without using a package i would like to know.

Because for our company, it’s a risk to use packages. Because if autodesk upgrades to a new revit version, and the owner of the package doesn’t (or loses his life f.e.)
our company scripts are then useless, and whe have to redesign a script from the bottom. Hope some of you do understand our company thoughts about packages.

Thanks in advance

Gr Edward

1 Like

Not with replace at index ootb…probably a other way with nodes…but you could open the node from clockwork and see how he had done it and make your own…btw think its only 5-6 lines in python

1 Like

@sovitek

Thanks for your reply. the node from the clockwork package does contain the python code.

Many Thanks.

Gr Edward