& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
New to programming in C# and the Revit API and I think implementing some MVVM will help solve a lot of the complications my programs are running into.
First basic question, would implementing a MVVM allow me to quickly see, say a list of beams in revit, and if the beam type names get updated in revit, the beam list would update dynamically?
See below in the gif, the current setup does not know that the initial selected types names changed, would an MVVM solution solve this?
Secondly, are there any good examples of Revit and MVVM? This is a sea of syntax I have not seen before, so some examples would be very helpful. I assume I could also follow any MVVM example and the lessons learned would still apply, but if there are good Revit examples, that would be helpful.
I have the non-working test code (shown in the .gif above) up on github:
https://github.com/retug/LearningCSharp/tree/main/MVVM
My Model - RevitFramingModel.cs
My ViewModel - MainViewModel.cs
My View - MainWindow.cs
Most of this was put together with chatgpt, but if you see any issues regarding the datagrid not dynamically updating with the updated Revit beam type names, I would appreciate the pointer.
Thanks!
Dear retug_austin:
if u want learn more revit MVVM project , u can read the hermmy @jeremy_tammik and nice3point @nice3point 's github , the RevitLookUp , this is a great project to learn MVVM and Revit.
Microsoft MVVM samples: https://github.com/CommunityToolkit/MVVM-Samples
Desktop app with samples: https://apps.microsoft.com/detail/9nklcf1lvz5h?hl=en-us&gl=US
Revit MVVM samples: https://github.com/Nice3point/RevitTemplates/tree/develop/samples
@scgq425 Thanks for this, to my surprise, when using the revit lookup, snoop selection tool, it does not appear to be dynamic if the selected object has changed.
Just so I'm clear, using something like MVVM would allow me to know that the element type and other parameters associated with the change have been updated, correct?
Dear retug_austin:
the first MVVM data use notfity implention to modify data , but in revit cant has this , so need to use some event to chang data to u data serives.
in lookup project , when user changed the element type . data cant trigged data, so u can add document type changed event , if u want to modify data ,u can monitor the type changed . use the documentchanged to record and modify this data.
but if one element has more constraints , u need to create a function to clean the data , so if u wan to make up u idea u can use this event in MVVM.
Hola,Aqui te comparto un ejemplo,de como usar MVVM en Revit.Es un ejemplo sencillo,espero que te sirva o te ayude.
El ejemplo consiste en seleccionar un elemento,y muestra el nombre y el ID en un TexBox(WPF) y tambien te permite borrarlo y volver a elegir otro elemento
Hello, Here I share an example of how to use MVVM in Revit. It is a simple example, I hope it is useful or helps you.
The example consists of selecting an element, and shows the name and ID in a TexBox (WPF)and also allows you to delete it and choose another element again.
@reylorente1 Thanks for the file, any chance you upload the files outside of a .rar? Github or individual files? I'm not allowed to to interact with .rar files on the work computer. Our IT guy has been burned too many times.
Disculpa, no sé cómo guardar el archivo en el Git.... Tengo que aprenderlo. Pero si quieres, escríbeme tu email. y te lo reenvió.
Sorry, I don't know how to save the file in Git... I have to learn it. But if you want, write me your email. and forwarded it to you.
Revisa, mira ver si puedes abrirlo (Check to see if you can open it)
@reylorente1 , thank you and welcome to github 🙂
I will review.
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name