Preview Graphics for Objects created by Add-In

Preview Graphics for Objects created by Add-In

mhillis
Advocate Advocate
918 Views
1 Reply
Message 1 of 2

Preview Graphics for Objects created by Add-In

mhillis
Advocate
Advocate

I want to create preview graphics, both 2D and 3D, for an add-in I am putting together for objects.  The idea is that when a user starts the routine, they will be presented with some sort of dialog with dimensions for objects.  There will be a preview of that object in the Project space and when the user modifies something in the dialog, the preview solid updates accordingly.  

 

Maybe something like the Duct routines in vanilla Revit. When you start the routine to draw straight ductwork in Revit, the routine starts by having you pick a start point and then picking an endpoint.  Between the start and end point selection, you are given a greyed out, preview representation of the duct you are about to draw based on the dimensions of the duct that is entered in the Width/Height textboxes along with snapping to the users cursor.  As far as the Revit API is concerned, what kind of object is this?  Because that kind of object would be perfect.

 

I've tried to look at the DirectContext3D APIs and the DirectShape APIs but the DirectContext3D does not give you any 2D graphics, as cool as the DC3D APIs are, and the DirectShape APIs leave elements that the user can mouse over, select, and interact with.  I do not want the user to be able to interact with the preview in any capacity, I want my dialog/add-in to handle creating, updating, and deleting the preview when necessary.

 

Any suggestions?  Thanks. 

0 Likes
919 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk

Dear Michael,

 

Thank you for your query.

 

You mention several imaginable options to approach this.

 

Other options for temporary graphics include the Analysis Visualisation Framework AVF and the PreviewControl:

 

 

However, neither of these provide the level of interactivity that you are looking for either.

 

Unfortunately, I agree with your assessment and believe that the Revit API currently does not offer any functionality that could help solve this in a satisfactory manner.

 

You could go the way that some of the Revit SDK samples demonstrate in a rudimentary fashion:

 

Display a simplified view of the situation in your own .NET form window, e.g., like the CurtainWallGrid SDK sample.

 

Check out its readme documentation in SDK/Samples/CurtainWallGrid/CS/ReadMe_CurtainWallGrid.rtf.

 

That is not really what you are after either, though. Sorry about that.

 

I hope this helps clarify the situation.

 

Rereading your question, I see hope after all.

 

You could implement your interaction as a modeless form. From that form, you could use external events to make Revit API calls to add real ductwork and modify real properties affecting the real model. Embed the whole sequence in a transaction group. Each individual modification goes into an own transaction that is committed to update the model and refresh the view. Once done, you could either commit or roll back the changes using the transaction group.

 

I hope this helps.

 

Best regards,

 

Jeremy

 



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