Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.

Revit API Forum

Reply
Post 1 of 5
Accepted Solution

Use a form in Revit API

414 Views, 4 Replies
04-13-2016 07:30 AM

Hi,

 

I'm new in Revit API and i recently realese some simple API.

 

I'm now trying to do an API  which use a forms to ask some parameters value to the user in order to set this parameter value to the selected objects. I created the forms with visual studio.

 

I'm already not able to open the form...

 

This is my part of code called by pressing the button in revit ribbon panel :

 

Public Class CommandHTPOT
    Implements IExternalCommand

    Public Function Execute(
      ByVal commandData As ExternalCommandData,
      ByRef message As String,
      ByVal elements As ElementSet) _
    As Result Implements IExternalCommand.Execute

        Dim uiapp As UIApplication = commandData.Application
        Dim app As Application = uiapp.Application

        Dim windowsform As New Form1()
        Dim result = windowsform.ShowDialog()

    End Function
End Class

My research has so far not helped me... When i execute that code I have a transaction error (French language so can't tell you exactly the terms).

 

 Hoping some help !

 

Thanks a lots

 

 

Dear Justin,

 

Yes, the automatic transaction mode is deprecated and has been so for a long time:

 

http://thebuildingcoder.typepad.com/blog/2012/12/extra-transaction-or-regeneration-required.html

 

"automatic transaction mode is unofficially deprecated, and manual mode is recommended for all cases nowadays. Automatic transaction mode is considered obsolete."

 

http://thebuildingcoder.typepad.com/blog/2012/05/read-only-and-automatic-transaction-modes.html

 

Your add-in is probably not properly set up.

 

The getting started material will show you how to do so.

 

So will the Revit SDK samples.

 

There is absolutely nothing special you need to do to run display a Windows form.

 

Cheers,

 

Jeremy

Post 2 of 5

Re: Use a form in Revit API

04-13-2016 09:52 AM in reply to: sylvain14d

Dear Justin,

 

First of all, as a beginner, I strongly recommend that you take a close look at the Revit API getting started material, especially the DevTV and My First Revit Plugin tutorials.

 

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

That will already answer your question.

 

You can also look at the Revit SDK samples. Several of them display forms as well. 

 

Good luck and have fun!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Post 3 of 5

Re: Use a form in Revit API

04-13-2016 11:50 PM in reply to: jeremytammik
Hi Jeremy,

Thanks a lot for this good tip ! I already use Revit SDK Sample. I just found information about Taskdialogue... But nothing about a windows form wich would have created with visual studio allowing to get back some informations.

I think that it's not so really complex. Maybe i have an error with this :

<Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)>

I do not really know how to go further

Really hoping some help

Best regards,

Sylvain
Post 4 of 5

Re: Use a form in Revit API

04-13-2016 11:57 PM in reply to: sylvain14d

Dear Justin,

 

Yes, the automatic transaction mode is deprecated and has been so for a long time:

 

http://thebuildingcoder.typepad.com/blog/2012/12/extra-transaction-or-regeneration-required.html

 

"automatic transaction mode is unofficially deprecated, and manual mode is recommended for all cases nowadays. Automatic transaction mode is considered obsolete."

 

http://thebuildingcoder.typepad.com/blog/2012/05/read-only-and-automatic-transaction-modes.html

 

Your add-in is probably not properly set up.

 

The getting started material will show you how to do so.

 

So will the Revit SDK samples.

 

There is absolutely nothing special you need to do to run display a Windows form.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Post 5 of 5

Re: Use a form in Revit API

04-14-2016 06:36 AM in reply to: jeremytammik
Thank you Jeremy,





In fact it was not a Revit API programation problem but a classic vb.net problem.


I just use this and it works great.


Dim wf As New Form1
wf.ShowDialog()
Thanks a lot !
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post

Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.