Thank you Joshua, for spilling these beans: What secrets? - spill the beans… 1. Never initiate your coding project from an external IDE. Rather use Revit Macro Manager then switch to a third party IDE such as Visual Studio. This process sets everything up for you with relative paths which is critical if end user has not installed Revit on C drive. 3m:55s 2. Use ‘invoke’ to run external commands instead of embedding references. This will prevent many hours watching the Revit splash screen when restarting. 6m:55s 3. Always use ‘modeless’ forms rather than ‘modal’ forms. This allows for freedom of movement for the end user and opens the potential for creating a dockable panel in the future. 12m:40s 4. Like Russian dolls encase your database interactions inside transactions, which are in turn encased inside a try-catch, which in turn is encased inside an external event. This nesting is the hardest thing to get your head around but absolutely necessary. 17m.15s 5. Iterate rapidly, and seek peer review as early in the project as possible. I've found canvasing somebody else’s opinion, early, can radically change the initial design intent or 'mental image' you had of your addin.
@cddsindia6 жыл бұрын
Thanks Jeremy. And your blog is awesome. Congrats on your 10th year.
@kalleodenthal49913 жыл бұрын
I think, it's first time I comment a youtube video EVER. But this time you soooo much deserved it! Best tutorial I've ever seen. Well prepared, well explained AND: If I would have seen it months ago, it would have saved me sooo much time. I can't believe it is just watched 12000 times and other tutorials that lead you to the process creating modules via Visual Studio (wich is indeed a pain, because you have to restart Revit each time you build the code) have much more. THANKS!!!!
@jlumley3 жыл бұрын
I appreciate your kind words. Revit API is niche...the view count isn't as important as the quality of the audience. And my audience is the best.
@Susel19813 жыл бұрын
I can't be silent. Thank you so much for this video. You saved probably month's of trying and failing for me.
@jlumley3 жыл бұрын
Your welcome comrade.
@marceloromero88962 жыл бұрын
Thanks, Joshua! You are a C# beast!
@piebepost88872 жыл бұрын
Holy shit dude, you're an absolute HERO!! 😁👊
@trommeltill9904 жыл бұрын
Awesome Video, it helped me so much to understand how to use Modeless Forms inside Revit
@danielswearson13606 жыл бұрын
You explained this so well, thank you so much Joshua!
@hopahope26092 жыл бұрын
Really it is Best tutorial I've ever seen, it is short direct , full of information , thank you very much for that amazing tutorial , I'm too happy that I found that amazing tutorial . I believe that every developer should watch this tutorial . thank you again
@adl35643 жыл бұрын
This really helps a lot. Your a legend!
@AlbrechtJ3 жыл бұрын
Thanks Joshua for an awesome tutorial.
@yushiy91054 жыл бұрын
This is the greatest Video on Revit API! I would take a flight to NZ and Thank you Personally!(if I could)
@jlumley4 жыл бұрын
You generous comment is all I need. "I can live for two months on a good compliment" - Mark Twain
@cddsindia6 жыл бұрын
You are awesome man...! Thanks a lot.
@ChristianSanchezQ3 жыл бұрын
Thanks for your help
@dgshen5 жыл бұрын
Great Tips. You are the man!
@arkplato21863 жыл бұрын
Such lovely way of teaching along with awesome content, ignorance is bliss lol
@jlumley3 жыл бұрын
Glad you think so!
@arkplato21863 жыл бұрын
@@jlumley i am looking through various Revit API videos just to find a way to select a family element by name in revit linked model. Any leads are highly appreciated. I want to learn how to highlight that one element in the drawing and find out where all it is located in the particular view. Please guide.
@arkplato21863 жыл бұрын
I learnt after weeks of research and looking tons of videos that its only possible with API and C# only not otherwise. Still no clue where to start. Havent found step by step c# tutorials for Revit API.
@jlumley3 жыл бұрын
@@arkplato2186 It is very possible, but I don't have any copy code for you. I would start by knowing what the elements id is in the linked file and selecting it that way. Then coding to select by name.
@arkplato21863 жыл бұрын
@@jlumley if you could just guide me that would be enough, its like I am hypothetically trying to find every single item of a particular family spread over the entire drawing. I selected one item from the linked model. Copy pasted it in the model itself and could see its ID but that doesnr help me find other members that are spread over the huge drawing. What is the process for that. Tried copying other items from the same family but they all have different IDs. Even with programming one cant find it. Or what is it that you are trying to tell me. Sorry if its confusing. Kindly guide me. Now I have a fully working visual studio that runs hello world in revit. Highly proud of myself.
@jonasslund6 жыл бұрын
Thanks! This saved med many hours of work! great torturial
@AmidrahSaihan6 жыл бұрын
Thanks a lot. You are awesome man with a big smiley heart.
@jlumley6 жыл бұрын
Your welcome. And your play list "New Me" is awesome {emotional}. I have it going in the background while I'm coding.
@AmidrahSaihan6 жыл бұрын
Joshua, may I ask you extra? Is there any way to read/write the forms label/button properties from external event called class as per example draw lines please help me?
@jlumley6 жыл бұрын
Can you rephrase the question, please. With more specifics on what you are trying to do.
@AmidrahSaihan6 жыл бұрын
Just like the continuation of the above example, 1st I have the label control on the form. 2nd. After drawing the line type/weight I want to invoke method to change this label's text or color ? Thank you.
Hi Joshua, First, many thx for all off your sharing. Hope you'll excuse my poor English I've got a question, I hope you'll understand it : I want to use SharpDevelopp because I want to use debug mode . First question, is it possible with VisualStudio to debug without Close and Open Revit? Other question, with SharpDevelopp, DebugMode with a modless Form is not possible, could you confirm that? Thx Joshua. Pierre
@huiliu97125 жыл бұрын
Thank you so so so much, this is exactly what I want. this tutorial inspired me so much. thanks again! Thank you for your patience and the Russian doll, it helps a lot!!!
@jlumley5 жыл бұрын
Your welcome. Some of my terminology off, when I say 'subroutine' i mean 'method'.
@huiliu97125 жыл бұрын
@@jlumley, It's ok! Thanks! I tend to review the Revit API tutorial book again, I have so many questions when I read it the first time, after your tutorial, I can think about it again. It becomes more clear.
@telliac19463 жыл бұрын
Thanks a lot !!!!
@SirNeshorn6 жыл бұрын
Thank you for sharing your knowledge. This will help alot.
@narrsam4 жыл бұрын
Awesome stuff! Thank you for revealing these precious gems! A couple of questions on when using visual studio instead of SharpDevelop: 1- Can you still step-into the code and debug without the need to restart Revit as well? 2- Can you use modern versions of .net/C# code? because SharpDevelop is not keeping up with the new C# features.
@jlumley4 жыл бұрын
I have had no success with either of those. My other tutorial shows how to switch to visual studio. Sharp develop is really only good for playing around ... an introduction if you will. kzbin.info/www/bejne/iWGwgat4h7FqmZI
@benveasey74745 жыл бұрын
Great tutorial. Would you be able to post the final SLN for creating the Ribbon and Modeless Windows Form? Thanks
@jlumley5 жыл бұрын
will do this in weekend
@benveasey74745 жыл бұрын
@@jlumley Fantastic :)
@jlumley5 жыл бұрын
A new link is in the video description, unzip and drill down on the myModule & myRibbon directories the SLN's are in there. This is the last project I ever did in sharpdevelop.
@benveasey74745 жыл бұрын
@@jlumley Fantastic, thank you. Why the last project? What r u getting up to these days?
@jlumley5 жыл бұрын
sharpdevelop crashes. Now I only use VisualStudio. But sharpdevelop is good for setting up projects at the beginning.
@francoisrobberts39976 жыл бұрын
Hello Joshua, First thank you this is amazing! I have a problem building the myRibbon application. It works fine first run, but if want to run it again, it doesn't work anymore. Error message is: "Could not copy "obj\Debug\myRibbon.dll" to "..\..\Addin\myRibbon.dll". Beginning retry 10 in 1000ms. The process cannot access the file '..\..\Addin\myRibbon.dll' because it is being used by another process. (MSB3026)". If I delete manually the myRibbon.dat and myRibbon.ddl, I can run the modification, but it is not convenient at all. Any ideas what is my mistake here? Best regards
@jlumley6 жыл бұрын
The only purpose of myRibbon is to call myMacro for this very reason. To rebuild myRibbon means you will need to remove the addin file and restart revit. Drag it off onto the desktop and restart revit. Then after you have rebuilt myRibbon drag the addin file back into its directory. But be careful if you make a mistake in the code you will need to repeat the process again. It is the code in myMacro that you can rebuild as much as you wish.
@firzautama11964 жыл бұрын
You're awesome! Cheers.
@jlumley4 жыл бұрын
Cool. This video is getting old, this one is better: kzbin.info/www/bejne/oF6pp2Nua99_pM0
@kongpadintharayota91974 жыл бұрын
Thank a lot for sharing. Could you please Guidelines how to create cable tray or copy cable tray by C#.
@JeremyTammik6 жыл бұрын
thank you very much for sharing this! can you summarise what the five secrets are in writing as well, maybe pointing to relevant time points in the timeline? ta!
@jlumley6 жыл бұрын
New link in the description for supporting text.
@MrNikler6 жыл бұрын
Supper!!! Thanks!
@AlvaroCarnicero3 жыл бұрын
Hi Joshua, this a great video to help everyone wants to learn Revit API. I´m looking forward to watching your next videos. Thank you so much. I´ve been following your instructions very carefully during the video, but at the end of secret #3, all the buttons cause the same error: "The method or operation is not implemented". Later of several hours, and restart from the beginning the secret #3 part, I can´t find out what is wrong. Even I try to follow the part #4 but the error continuous in button "Commom Error Messages" after the very first step. Would you mind to help me? Thank you in advance.
@AlvaroCarnicero3 жыл бұрын
Update: I am using Visual Studio from the beginning. Apparently there is a difference between VS and SharpDevelop. VS creates another file more than SD, called "Form1.Designer.cs". In this file buttons handler code is mentioned too. I realized that the code used in them is just "throw new NotImplementedException();" I replaced the code in buttons #1 and #2 for the mentioned in Form1.cs, which comes from one of the txt files. It´s successful. In the case of button #3, this operation doesn´t work properly, the ShowDialog is exactly the same than before the changes in secret #4 part. I hope to resolve it soon or later and comes here again with the solution.
@AlvaroCarnicero3 жыл бұрын
Update 2: Actually, it was necessary to copy the same code from "Form1.cs" to "Form1.Designer.cs" for button #3 too. The solution is to implement the Usings at the beginnig of the code. Apparently these are the Usings needed: using System; using System.Drawing; using System.Windows.Forms; using Autodesk.Revit.UI; using Autodesk.Revit.DB; Just a doubt, what´s the point of repeat again some code in two files? I am too newbie in VS, maybe some day I´ll understand it.
@jlumley3 жыл бұрын
Good work. Your always going to get code repetitions and this is inefficient because an update to one will need to be applied to the other (unnecessary double handling). We can remove these repetitions by wrapping the code into helper methods...but you can get carried away with too many helper methods and I use them only when the code has reached a stage of maturity. And by 'maturity' I mean the code looks elegant rarely requires updating. A good example of a helper method in my sample is called is 'writeDebug'.
@AlvaroCarnicero3 жыл бұрын
@@jlumley thank you for your answer. Regarding "writeDebug", I was wondering what for it was this part of the code, I will research more about this helpers methods.
@FilipNekic4 жыл бұрын
Hi Joshua, thank you for sharing this, it will save us so many time. Keep the good work going :) I successfully implemented "InvokeMember" tip and it is working great if all my code is in one .dll file. But when I have one project with addin commands and second one with my class Library it will not work, as it does not see .dll from library. I'm getting error "Could not load file or assembly 'Library, Version 1.0.0.0. Culture=natural, PublicKeyToken=null" or one of its dependencies. The system cannot find the file specified." Do you have any advice how to go over that error? Kind Regards, Filip
@jlumley4 жыл бұрын
Yes, there is another level of complexity when using assemblies outside of the default .net libraries. I explore the issue in the video with: kzbin.info/www/bejne/iWGwgat4h7FqmZI The example I use is with the xceed toolkit library.
@vetlecb4 жыл бұрын
So if I understand this right: For debugging purposes and so on you are developing your addin in revit macro manager, and then when it comes to the actual distribution of the tool, you generate the .dll i visual studio so everyone can put it their respective addin folders? (read: i'm new to this :) ) Awesome video, and thank you very much for it.
@jlumley4 жыл бұрын
You could do it like that but no. It is unprofessional to ask users to directly edit system directories like %ProgramData%. I made another video that talks exclusively about distribution via MSI installer kzbin.info/www/bejne/iWGwgat4h7FqmZI.
@JASONMHOLDEN6 жыл бұрын
Hi Joshua. I have found this tutorial amazing so far. Unfortunately when I reach the horrible error message section around the 19 minute mark the message does not display as it does for you. I have opened in VS, added a standard message box to Button 3 code which works but I can get no farther. Can you offer any advice? I am fairly certain I am missing something but not sure what. Thank you. Jason
@jlumley6 жыл бұрын
Yes oddly it is difficult to get error messages to show deliberately, they only happen when you don't want them. The principle is to encase all event code inside the try/catch/finally statement to prevent program crashes. You will not find any shortages of error messages.
@JASONMHOLDEN6 жыл бұрын
thank you Joshua. I decided to proceed without them anyway and got it working without the Error Messages.
@ВладимирЯковлев-ь6р5 жыл бұрын
in sharpDevelop you can fast comment with select lines and "Ctrl+/"
@jlumley5 жыл бұрын
Is there a shortcut key for uncomment?
@ВладимирЯковлев-ь6р5 жыл бұрын
@@jlumley same. "Ctrl+/" for comment / unComment.
@Teachy3 жыл бұрын
This video is just awesome ;) Made it so easy to get into working with the RevitApi. Thank you so much for sharing your work. I just ran into a problem. I split the Ribbon and Module as you did. But how do I add a second button now? I copied the Invoke-Class and renamed the 'strCommandName' to the Name the method in myModule should start with, but it does not seem to be a very clean solution. The copied Version of "ThisApplication" from myModule has a problem with the following code: this.InternalStartup(); if ((this.Startup != null)) { this.Startup(this, System.EventArgs.Empty); } I just commented it out and it works, but it does not seem to be the best solution :( And I ran into the problem that LINQ causes problems while debugging. I changed everything into foreach loops, but most times LINQ is just easier to use. Is there a workaround to keep debugging even when Using LINQ / Lambda?
@jlumley3 жыл бұрын
Add more buttons with code that looks like "RibbonPanelCurrent.AddItem(...." I think you did the right thing by commenting it out :-) Keep trying with LINQ it is indispensable.
@panpudzian4 жыл бұрын
Hello Joshua, thanks for great tutorial. Could you also show how to for example populate listbox/combobox/whatever when Form loads? With lets say sheets names? I cannot get this working. Only a button click raises ext event. Form Load/Show doesnt :(
@jlumley4 жыл бұрын
alright this is quite straight forward, I'll post the solution here as text in the weekend.
@jlumley4 жыл бұрын
Here you go: Paste this after InitializeComponent(); FilteredElementCollector fec = new FilteredElementCollector(doc).WhereElementIsNotElementType().OfClass(typeof(ViewSheet)); myListView_Sheets.ItemsSource = fec; wpf paste (I prefer list views over listboxes):
@panpudzian4 жыл бұрын
@@jlumley oh, this was the first thing I did :) With your help I understood it's the correct way, so I found a solution. It was a matter of accessing Document, so I've created global variable GlobalObjects.myDoc before Form is created and then pass this to local 'doc' public void myMacro(UIDocument uidoc) { TaskDialog mainDialog = new TaskDialog("Fun Secrets of Revit Coding!"); Document doc = uidoc.Document; GlobalObjects.myDoc = uidoc.Document; FormTest.Form1 myForm1 = new FormTest.Form1(); myForm1.doc = uidoc.Document; myForm1.Show(); return; } And in Form1: public Form1() { InitializeComponent(); doc = GlobalObjects.myDoc; collector(doc)..... } probably not the best way, but actually works :D I should probably rename 'doc' too to sth else like "_doc". Thank you for help!
@jlumley4 жыл бұрын
@@panpudzian Well done.
@yushiy91054 жыл бұрын
Hi Joshua, first of all thanks.Great video. I followed the video and could make all the Macros. However, when I want to edit the code in Visual Studio I have to upgrade to .Net v4.5 Client profile and on top of that the solution will not build. There are all kinds of Revit API missing References. Going back to Revit, Macro won't run because .Net is v4.7 now. Do you need to do anything after creating a Macro to be able to edit it in Visual Studio? Or am I doing something horribly wrong?
@jlumley4 жыл бұрын
Assuming your user Revit 2019 add a references to : C:\ProgramData\Autodesk\Revit\Macros\2019\RevitAPI.dll C:\ProgramData\Autodesk\Revit\Macros\2019\RevitAPIUI.dll Note: In the video I said that relative paths were good I have since changed my mind.
@ScottRosenbloom6 жыл бұрын
Can the "InvokeMember" workaround for not having to restart Revit each time you make a code change work if you're coding within Visual Studio? If so, how? I tried but, understandably, the Error List shows the dll as in use by Revit when I click Build.
@jlumley6 жыл бұрын
Remove it from macro manager, then restart revit.
@Patrycjusz2116 жыл бұрын
I'm also struggling to make this work. I keep getting error "error MSB3021: Unable to copy file "obj\Debug\ConcreteQTO.dll" to "bin\Debug\ConcreteQTO.dll". The process cannot access the file 'bin\Debug\ConcreteQTO.dll' because it is being used by another process." I've been trying to work out the file paths but I think I keep doing something wrong.
@Patrycjusz2116 жыл бұрын
and also I don't get the "removing it from macro manager" tip. If one codes in Visual Studio from start, he/she doesn't have this project in the macro manager in the first place
@yafimski4 жыл бұрын
@Joshua Lumley Hi, Thanks for the video. I'm running into the same error as Patryk. Do you have a way to explain what to do in this situation?
@spazieren993 жыл бұрын
very helpful video, thanks a lot! I have an error when i'm trying to build at 13:24 : "The typ or namespace name 'DrawLines' could not be found..." In the downloaded PDF handout at page 23 of 38 is the same error shown. has anybody an idea, how to solve the issue?
@jlumley3 жыл бұрын
Can you find DrawLines method with search tool?
@dineshpothedar45685 жыл бұрын
Thanks a lot.. :)
@hazemelamir20835 жыл бұрын
many thanks for your support and help but the supporting download link not working please help
@jlumley5 жыл бұрын
It works now. Sorry I did cleaned out my dropbox account, thankfully they give you 30 day grace period to restore accidentally delete files.
@hazemelamir20835 жыл бұрын
@@jlumley many thanks sir for your fast replay and very valuable tutorial i have followed your video step by step and its amazing but the application class is not modified unless the addin file is removed & revit is restarted, is there any way to modify it with out the restart of revit? could you also make video for dockable windows? many many thanks again for your very fantastic effort
@jlumley5 жыл бұрын
@@hazemelamir2083 Hi myRibbon can't be built while Revit is open this because this contains the 'invokemember' that calls myModule (which can be built). myModule is for rapid iteration, myRibbon is not.
@hazemelamir20835 жыл бұрын
@@jlumley thanks again for your concern Actully it's very very good method Many thanks
@jlumley5 жыл бұрын
@@hazemelamir2083 the next video I am going to make is about how to turn your plugin into an installer msi. I've made dockable windows in the past I"m less motivated to make them because they are in direct competition properties windows and project browser for screen space and the user has to invest time customizing their interface. A discrete and well designed modeless form has an immediacy and is easily closed when not in use. Question: Is the dockable window you have in mind for the purpose of presenting a listview or datagrid of indeterminate size? in which case I think there usage is justified.
@hazemelamir20835 жыл бұрын
Many thanks for your valuable secrets It's working with me for single dll command but when my command consists of more than one dll it throw error He says he can't find the second dll How can that be solved Many thanks
@jlumley5 жыл бұрын
Make sure the file path is correct.
@hazemelamir20835 жыл бұрын
@@jlumley many thank for your fast replay The both dll of the plug-in in the same directory He read the first one refered in the invoke method but can't read the second dll that used by the first one
@jlumley5 жыл бұрын
Using Xceed as an example, this line must appear in startup for both dll: Assembly.Load(File.ReadAllBytes(stringTargetDirectory + "\\Xceed.Wpf.Toolkit.dll"));
@hazemelamir20835 жыл бұрын
@@jlumley it seems that when first dll load by invoke method, it don't have location I passed location as you did in vedio as parameter and load the second dll as you advised me Till now it's fine but when take instance of any class in the second dll, it gives error again This is too hard for me to follow
@jlumley5 жыл бұрын
This is cheating buy try putting a copy of the second dll in C:\Program Files\Autodesk\Revit 2019
@amirael-saeed68816 жыл бұрын
i couldn't find the files
@jlumley6 жыл бұрын
Click, the link then it says ".zip files can't be previewed", so click Open and it will download. Unzip this onto your Desktop or Documents directory. There is nothing special about the code it is fairly generic. Happy New Year (-:
@erik....6 жыл бұрын
2h to install VS? lol your internet connection is too slow then. It took me like 20 minutes.
@jlumley6 жыл бұрын
This was Visual Studio Enterprise, not community and it was on a 8 year old rig on ADSL. Since then I've installed VS Community on a fast machine with a fibre optic connection and like you it took only 20 minutes.