Revit API C# Add a Tab and Button

  Рет қаралды 23,464

Danny Bentley

Danny Bentley

Күн бұрын

Пікірлер: 55
@antengineer4989
@antengineer4989 2 жыл бұрын
Hi Danny Bently, the text is hardly visible, can u record in big fonts size
@HippieP629
@HippieP629 6 жыл бұрын
Thank you so much for sharing your knowledge both here and on your blog! As a coding noob, it's really helpful to see how c# is applied to Revit.
@gutibokeron
@gutibokeron 3 жыл бұрын
Great video! thanks! May I suggest use fullscreen for easy following!
@BittuGhosh-o2e
@BittuGhosh-o2e Жыл бұрын
Hi Danny, I have already been through all your c# videos, has really helped to get a better understanding of the Revit Api. I would really like to try to have buttons on the other which i have crated for panel2 in a RibbonPanel. Any chance you can make a video of that or explain the logic. I have managed to get it working, but not sure if copying and pasting code is really a sustainable method. Cheers
@หนังสยองขวัญผี
@หนังสยองขวัญผี 7 жыл бұрын
#Danny Bentley Can you zoom CODE ?
@Lichtschalter
@Lichtschalter 7 жыл бұрын
Hey Danny... where would i post the code for example if i want to press the Button and the Message "Hello World" would pop out.
@DannyBentley
@DannyBentley 7 жыл бұрын
Here is some sample code for "Hello World" Popup. public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { TaskDialog.Show("Revit", "Hello World"); return Result.Succeeded; }
@Lichtschalter
@Lichtschalter 7 жыл бұрын
but i want to paste it in the "Tab and the Button"-code to pop out the message after pressing the Button
@DannyBentley
@DannyBentley 7 жыл бұрын
When you push the button the App.cs file which is the button will go through the code action/event trigger. PushButton button = panel.AddItem(new PushButtonData("Button", "Test Button", thisAssemblyPath, "MyTest.Command")) as PushButton; The action will run Command.cs file that is the class Command. This will start of your wonderful Hello World program. public class Command : IExternalCommand { public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { TaskDialog.Show("Revit", "Hello World"); return Result.Succeeded; }
@Lichtschalter
@Lichtschalter 7 жыл бұрын
thank you very much!
@หนังสยองขวัญผี
@หนังสยองขวัญผี 7 жыл бұрын
Thank Danny Bentley .I hope you will make many new lesson .
@DannyBentley
@DannyBentley 7 жыл бұрын
If you have any suggestion or things you'd like to learn on the Revit API please let me know.
@bimconsaultantshawaii
@bimconsaultantshawaii 7 жыл бұрын
Thanks for this video. It was blurry as heck. Can you post a link or copy of that code as an example?
@DannyBentley
@DannyBentley 7 жыл бұрын
Hello Kristofer, I'm working on getting better software for the videos, but I've also increased the size of the font in newer videos. I have a blog where I post my code here: revitdynamoapi.blogspot.com/2017/02/beginners-guide-to-adding-tab-and.html If you need more help feel free to reach out to me. DB.
@wojciechtecaw5937
@wojciechtecaw5937 5 жыл бұрын
Thanks for sharing! Is it possible to compile python code to get similar result? How to compile that code?
@ricardozepeda1428
@ricardozepeda1428 7 жыл бұрын
Thanks Danny great video! keep posting! one small question, any particular reason why the icon its not visible when you add the button to the quick access tool bar ?
@DannyBentley
@DannyBentley 7 жыл бұрын
Hi Ricardo, Yes you're correct. The image will not show up on a quick access toolbar. The reason I used a large image of 32x32 pixels. For quick access, you need a 16x16 pixel or else it will not show up.
@jamessteele53
@jamessteele53 6 жыл бұрын
Hi Danny, I have already been through all your c# videos, has really helped to get a better understanding of the Revit Api. I would really like to try to have multiple buttons in a RibbonPanel. Any chance you can make a video of that or explain the logic. I have managed to get it working, but not sure if copying and pasting code is really a sustainable method. Cheers
@DannyBentley
@DannyBentley 6 жыл бұрын
Hi Frederich, You are starting to move from beginner to advance. To add another button to a panel you would just do something like this. PushButton button1 = panel.AddItem(new PushButtonData("Button1", "API Button", thisAssemblyPath, "MyTest.Command1")) as PushButton; PushButton button2 = panel.AddItem(new PushButtonData("Button2", "API Button", thisAssemblyPath, "MyTest.Command2")) as PushButton; If you have a seprate project which most of the time this happens just call for the same panel then add your button. I hope this helps.
@sarahassan9895
@sarahassan9895 6 жыл бұрын
hi i'm already make a Tab and Button, but i want give Action to Button, like i want to make it open CMD after press on it, i'm already have another project using C# able me to open CMD so how can i connect them by each other , how can make this button active to open another project or specific CMD ?????????
@DannyBentley
@DannyBentley 6 жыл бұрын
Hi Sara, If you are using WPF then double click on the button. You should get an event handler code. It should look something like this. private void CMD_Click(object sender, RoutedEventArgs e) { // This will run when your button is clicked. // Add logic here or call this in a separate class to keep code clean. }
@albobball
@albobball 7 жыл бұрын
Danny, I cannot figure out why my image is not pulling up. The rest of the code is working just fine however. I saved my .png image in the debug folder where my dll is. am i supposed to reference somewhere in my addin? I guess I am not really understanding how the 'globePath' line of code is searching for this image. Please help me out. Thanks.
@DannyBentley
@DannyBentley 7 жыл бұрын
Hi I've setup my project to copy all the items to my add in folder, but you may have to do this manually on your project. This is where my image is located plus my .dll and .addin C:\Users\danny.bentley\AppData\Roaming\Autodesk\Revit\Addins\2018
@albobball
@albobball 7 жыл бұрын
Thank you for responding, Danny! I am still having issues. I am playing with it and still can't get it to work. I got my .npg file i my addins folder for 2017, as well as my debug folder for the project. I thought I had it set up so all files copied over when I built my code but I still just copied the image manually but I am still getting this error and I am not sure how to fix it. An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll but was not handled in user code Additional information: Could not find file 'C:\Users\abonilla\AppData\Roaming\Autodesk\Revit\Addins\2017\Pokeball.npg'.
@DannyBentley
@DannyBentley 7 жыл бұрын
this exception is just a null file not found. It's common when the compiler is looking for a file and it can't find it. Double check that the path and file name match. You might also do a break point and a try catch with exemption message to read what might be causing the problem.
@albobball
@albobball 7 жыл бұрын
Took me almost 2 hours to realize that I had typed the extension '.npg' instead of '.png' Got it to work! Thank you so much, your videos are great
@DannyBentley
@DannyBentley 7 жыл бұрын
happy it worked out. This has happened to me several times as well.
@memetbatu
@memetbatu 6 жыл бұрын
"PushButton button = panel.AddItem " gives an error "RibbonPanel does not contain definition.." why ?
@DannyBentley
@DannyBentley 6 жыл бұрын
I would check that "MyTest.Command" is what your project name is example "projectname.Command" also the Command is the name of my class which runs the IExternalCommand. Also check to make sure your ribbon is initiated.
@lgsevero
@lgsevero 6 жыл бұрын
Hi, nice work. How I set up multiple "RibbonPanel's": like Eletrical, AC, Arch ...
@DannyBentley
@DannyBentley 6 жыл бұрын
Hi Lucas, This is great means you have lots of addins. yes just try something like this. RibbonPanel panelMEP = a.CreateRibbonPanel(tab , "testMEP"); RibbonPanel panelAC = a.CreateRibbonPanel(tab , "testAC"); Most of the time projects are created for each individual add-in just test to see if the panel exist and if it doesn't create it. So see if testMEP is added if not it creates it. //*****************************ribbonPanel()***************************** public RibbonPanel ribbonPanel(UIControlledApplication a) { string tab = "By Danny Bentley"; // Tab name // Empty ribbon panel RibbonPanel ribbonPanel = null; // Try to create ribbon tab. try { a.CreateRibbonTab(tab); } catch { } // Try to create ribbon panel. try { RibbonPanel panelMEP = a.CreateRibbonPanel(tab , "testMEP"); } catch { } // Search existing tab for your panel. List panels = a.GetRibbonPanels(tab); foreach(RibbonPanel p in panels) { if (p.Name == "test") { ribbonPanel = p; } } //return panel return ribbonPanel; }
@nicholasjacobson5618
@nicholasjacobson5618 7 жыл бұрын
Hey thanks for the tutorial. I'm getting a weird warning message... any help would be appreciated. There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "RevitAPI", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
@DannyBentley
@DannyBentley 7 жыл бұрын
Nicholas Jacobson check your framework to be .NET 4.5 or higher. It’s in the properties. I think the XAML library need this new .NET
@nicholasjacobson5618
@nicholasjacobson5618 7 жыл бұрын
What solved this was actually changing the platform target from all computers to x64. All seems well but still getting one error on loading to revit. Says Mytest.app cannot be located. Wonder if in trying to change names this got screwed up. Can you explain how the mytest.app is created and used?
@DannyBentley
@DannyBentley 7 жыл бұрын
Great to hear. Check the .addin file and see if the mytest.dll. Also check App.cs PushButton alignViewportToCell_Button = alignViewsPanel.AddItem(new PushButtonData ("Translation", "mytest", thisAssemblyPath, "mytest.Command")) as PushButton;
@nicholasjacobson5618
@nicholasjacobson5618 7 жыл бұрын
it appears that the namespace 'name' and name.app' just need to be consistent.
@nicholasjacobson5618
@nicholasjacobson5618 7 жыл бұрын
ah yes good catch. Thanks. Last question... can you point me to where I can load the button with my custom script? Maybe I missed this part but still unsure how a script gets attached.
@jacoblong5553
@jacoblong5553 6 жыл бұрын
Great videos man, But PLEASE hold control and move your mouse wheel. ZOOOOOOOOOOOOOOOOOOOOOOOOOOOOM in Lol so hard to see.
@DannyBentley
@DannyBentley 6 жыл бұрын
Jacob Long these are my first attempts to make videos so I was still trying to figure out how to use my Mac and recorder. Other videos have larger font
@nvalet
@nvalet 5 жыл бұрын
Thank you!
@IknowRicky
@IknowRicky 3 жыл бұрын
the text is so small i can't read anything
@HatStand1000
@HatStand1000 7 жыл бұрын
Nice tutorial - just can't read any of the text you're writing...
@DannyBentley
@DannyBentley 7 жыл бұрын
Hi Kevin, You're correct these are my first videos and the font size is small, but here is the source code on my github. github.com/dannysbentley/MyTest The App.cs is where Revit add the tab and button github.com/dannysbentley/MyTest/blob/master/App.cs Best of luck.
@HatStand1000
@HatStand1000 7 жыл бұрын
Perfect - thanks. Do you have a version with the icons embedded in the DLL?
@DannyBentley
@DannyBentley 7 жыл бұрын
The icon is on my git. github.com/dannysbentley/MyTest/blob/master/LACMA%20DOORS.png You can add it to the Debug and in your addin folder.
@Ayazis1
@Ayazis1 6 жыл бұрын
never mind
@lokeshv7575
@lokeshv7575 3 жыл бұрын
The video quality is not good
Revit API C# Select Elements
8:10
Danny Bentley
Рет қаралды 18 М.
Revit API : Button and Tab in Revit
12:28
Jacobian Dev
Рет қаралды 17 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 27 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
Revit API 04 - Ribbon Button
20:14
KrispCAD
Рет қаралды 12 М.
OAuth 2.0 and OpenID Connect (in plain English)
1:02:17
OktaDev
Рет қаралды 1,8 МЛН
Revit API C# Get and Set Parameters
7:56
Danny Bentley
Рет қаралды 21 М.
So You Think You Know Git - FOSDEM 2024
47:00
GitButler
Рет қаралды 1,3 МЛН