Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ShowDialog

8 REPLIES 8
Reply
Message 1 of 9
bthatcher
1113 Views, 8 Replies

ShowDialog

I'm trying to simply show a dialog, here is my code...

 

[code]

namespace HelloWorld

{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)]
public class Class1 : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
ref string message, ElementSet elements);

public void ShowMyDialogBox()
{
Form1 frm = new Form1();
frm.ShowDialog();
}
}
}

[/code]

 

I've started with the HelloWorld sample. The debugger is getting caught on
'Execute' (see attached). Any ideas? Thanks.

8 REPLIES 8
Message 2 of 9
ollikat
in reply to: bthatcher

I think it is just as it says...you don't have a body for Execute(...). You must have implementation for it because it is declared in IExternalCommand interface which you are inheriting.

Message 3 of 9
bthatcher
in reply to: ollikat

I'm learning. Can you give me an example. It works fine when calling a TaskDialog. Thank you.

 

Message 4 of 9
ollikat
in reply to: bthatcher

Hmmm...it sounds strange that it works with something other.

 

But what the error refers is the missing function body for Execute().

 

See Method body

Message 5 of 9
bthatcher
in reply to: ollikat

that link is broken

Message 6 of 9
ollikat
in reply to: bthatcher

That's strange...let's try again 🙂

 

(with pure copy-paste)

 

http://msdn.microsoft.com/en-us/library/aa664437%28v=vs.71%29.aspx

Message 7 of 9
DMadhuri
in reply to: ollikat

Exectue is a method in class1-- meaning that it should have a method body which is missing .
You are endin the class with a semicolon without immplementation

Please change the code as below and you can call your method here :

 

public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
ref string message, ElementSet elements)
{
	// Call to your method 
	ShowMyDialogBox()
}

 

Hope this helps..

Message 8 of 9
bthatcher
in reply to: DMadhuri

i HI have followed that up with...

 

   

publicvoid ShowMyDialogBox()

            {

           

Form1 frm = newForm1();

            frm.ShowDialog();

            }

       

 

Is that correct?

 

Also, how do I use a Code tag here? Thanks.

Message 9 of 9
DMadhuri
in reply to: bthatcher

Hi bthatcher

 

I'm assuming that you are trying to call a window  in the external command.. and Form1 is the name of your window

 You can also direclty call these two lines direclty in the External command method

namespace HelloWorld

{
	[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)]
	public class Class1 : IExternalCommand
	{
		public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
			ref string message, ElementSet elements)
		{
			Form1 frm = new Form1();
			frm.ShowDialog();
		}
	}
}

 

And to answer your Second Query "Also, how do I use a Code tag here? "

 

In the reply : Please click on the insert Code button and plac your code..

Hope this helps

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community