Revit command - go to URL

Revit command - go to URL

Anonymous
Not applicable
1,588 Views
5 Replies
Message 1 of 6

Revit command - go to URL

Anonymous
Not applicable

Good afternoon

I would like to find a way to have a link to a website on the Revit ribbon.

Are there any recommendations on how to achieve this?

 

This video is exactly what I am looking to do, but there is no explanation:

https://www.youtube.com/watch?v=wfMzmuJ2xfA

 

Thank you!!

0 Likes
1,589 Views
5 Replies
Replies (5)
Message 2 of 6

studio-a-int
Advocate
Advocate

you need to open a process using Process class from System.Diagnostics

just need to insert in your code something like this:

 

string url = "http://www.autode.sk";
System.Diagnostics.Process.Start(url);

 

and depends on how system is configured on machines where your addin will run, you need to catch specific exceptions.

 

0 Likes
Message 3 of 6

Anonymous
Not applicable

@studio-a-int, thank you so much for your response! It is much appreciated!

 

I am very new to the concept of what I am assuming is coding.

I honestly am not too sure what your answer means.

 

Do I need to use a Revit API kit of some sort?

I found a few posts and blogs, but it looks so daunting and nothing appeared in my "for dummies" search string...

 

I have considered re-routing F1 from Revit help to my intranet knowledge base, or creating a keyboard shortcut.

But I know my team. They need something right there or they will find a workaround to get a result and never ask me to show them how to do it properly...

0 Likes
Message 4 of 6

studio-a-int
Advocate
Advocate

you will need to create a ribbon, add a push button to it, and trigger the command in the button using a simple class in your namespace, something like this:

 

    public class yourCommand : IExternalCommand
    {
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData ecd, ref string rs, ElementSet es)
        {
            string url = "http://www.autode.sk";
            System.Diagnostics.Process.Start(url);
            return Autodesk.Revit.UI.Result.Succeeded;
        }
    }

here is the API documentation for RibbonPanel Class w/ methods:

 

https://www.revitapidocs.com/2020/544c0af7-6124-4f64-a25d-46e81ac5300f.htm

 

 

Message 5 of 6

marcusss_
Contributor
Contributor

Thanks for this, it helped me out.

 

Thought i would mention also just as an FYI to anyone else if it may help them as i had to figure this part out.

 

I had to add 

[TransactionAttribute(TransactionMode.ReadOnly)]

before the class in the code, as a...

 

"TransactionMode must be applied to your implementation class of the IExternalCommand interface to control transaction behavior for the external command."

 

Cheers

https://help.autodesk.com/cloudhelp/2018/ENU/Revit-API/Revit_API_Developers_Guide/Introduction/Add_I...

 

0 Likes
Message 6 of 6

ridaabderrahmane
Enthusiast
Enthusiast

You might consider to do it with on F1 click, it should be like this : 

ContextualHelp contextHelp = new ContextualHelp(ContextualHelpType.ChmFile,"https://www.autode.sk");

yourButton.SetContextualHelp(contextHelp);