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: 

How to render families in 3d - ObjectViewer example used as basis

8 REPLIES 8
Reply
Message 1 of 9
emil
835 Views, 8 Replies

How to render families in 3d - ObjectViewer example used as basis

I was wondering if anyone could point me in the right direction. I looked at the Objectviewer sample in the SDK, and incorporated the viewer for objects there into my project, but I have two questions.
 
1. Can it be used to render previews that are of "better" quality than wireframe ?
2. The demo only accepts one object, I tried with a window FamilyInstance and that didnt render properly only came out gray, I tried with a wall and that looked ok, and I could move it about.
 
what I am trying to do is previewing/rendering a view of a familyInstance.
 
Any thoughts, suggestions ?
 
Regards,
Emil
 

 

8 REPLIES 8
Message 2 of 9
jeremytammik
in reply to: emil

Dear Emil,

 

Since you have the source code included in the Revit SDK, you can basically answer these questions yourself.

 

For your convenience, I'll state that the ElementViewer and ObjectViewer samples make use of an extremely simple little custom renderer that only draws lines.

 

You would have to replace that and also implement hidden line removal and a bunch of other stuff to do anything more complex.

 

I would not recommend using this at all for any professional application. 

 

There are tons of better rendering options around.

 

To start with, you might be able to make use of the Revit API PreviewControl:

 

http://thebuildingcoder.typepad.com/blog/2013/09/appstore-advice-and-zooming-in-a-preview-control.ht...

 

For more advanced rendering interaction outside of Revit, there is also the Autodesk View and Data API:

 

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

 

We also implemented a simpler WebGL and three.js based viewer at the AEC Hackathon last year, basically a simpler version of the 

Autodesk View and Data API, called vA3C:

 

http://thebuildingcoder.typepad.com/blog/2014/08/threejs-aec-viewer-progress-on-two-fronts.html

 

These are just three possibilities out of many.

 

I hope this helps.

 

Cheers, Jeremy.

 

 



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

Message 3 of 9
emil
in reply to: jeremytammik

Hi Jeremy and thank you for pointing me in the right direction.

 

After trying out several things, I figured that the external web viewer is overkill for my needs and the objectviewer example as you stated isnt suited for my needs.

I managed to display a 3d view of selected objects with the previewcontrol, but I dont seem to get the perspective I want or the current perspective in revit.

 

I was wondering if there was a simpler way to achieve the preview window you get when you try to export in gbxml format ?

This is what Im aiming for, because Im adding properties to families and the user has to be able to name those properties from visual cues seen in the 3d preview of the family. 

 

and since im writing an addin (winforms) I would rather not use a webpage.

 

Regards,

Emil

 

Message 4 of 9
jeremytammik
in reply to: emil

Dear Emil,

 

Thank you for your appreciation, taking a look at the possibilities and further explaining your goals.

 

I summarised our discussion so far for general consumption on The Building Coder, and added a response to your update there as well:

 

http://thebuildingcoder.typepad.com/blog/2015/01/3d-viewing-va3c-and-revitlookup-updates.html#4

 

In the same post, I also present some vA3C news that may be interesting for you to exlore further:

 

http://thebuildingcoder.typepad.com/blog/2015/01/3d-viewing-va3c-and-revitlookup-updates.html#2

 

I actually think that both the Revit API PreviewControl and a simple WebGL viewer may both easily be used to fulfil your needs.

 

I think it is really your choice which way you prefer to go.

 

Cheers, 

 

Jeremy



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

Message 5 of 9
emil
in reply to: jeremytammik

To finish of this subject and if anyone else has the same problem.

 

 

what I set out to do :

 

Display all families of categories door, window and furniture in the open project.

Allow the user to click on the names of the families and display a picture of the family, open plan of doors and 3d of window and furniture.

 

Originally I planed to have 3 preview windows one for each category, this turned out to be impossible since revit doesnt allow multiple preview windows.

So I had to change the design of my app to reflect this.

 

Currently I solved my problems by opening the family file from disk

with

 

familyDoc = this.revitApplication.Application.OpenDocumentFile(filename);

 

and previewing either with the first view for doors or first 3d view for window/furniture. This works fine if the family files exist on disk or if I know the paht to the files.

 

And now for my questions 🙂

 

I was wondering if there is a way to load the families from the open project/document ? instead of from disk.

 

something instead of this : familyDoc = this.revitApplication.Application.OpenDocumentFile(filename); 

I didnt find OpenDocumentFromProject or anything similar. 

it would simplify things a hell of a lot for me if I could just open the families from the project since Im already showing a list of families in the project.

 

any ideas ?

 

 

Regards,

Emil

 

Message 6 of 9
jeremytammik
in reply to: emil

Dear Emil,

 

Maybe the OpenAndActivateDocument method will do what you need.

 

Cheers,

 

Jeremy



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

Message 7 of 9
arnostlobel
in reply to: jeremytammik

OpenAndActivateDocument does not do that either, Jeremy. It opens an unopened document too just like OpenDocumentFile does, only it makes it the active document also. It seems that what Emil wants is the Document.EditFamily method. It does what the Edit Family command does when invoked via Revit UI. The method returns the family document of the family to be edited. Just keep in mind that the opened family document is not the same family that exists in the host model. It is a copy of it. Changes may be made there, but they stay only there unless the family is loaded back to the host model by invoking the LoadFamily method.

Arnošt Löbel
Message 8 of 9
emil
in reply to: arnostlobel

Arnost is right.

 

the reason this is a problem

familyDoc = this.revitApplication.Application.OpenDocumentFile(filename); 

 

is because filename is a path + filename, that is it has to exist physicly on disk somewhere, thus I need to save the family from the document to the disk.

If there was a Application.OpenDocumentStream(stream); 

I could simply save the family to a memorystream and load it from there.

 

Regards,

Emil

 

Message 9 of 9
arnostlobel
in reply to: emil

Emil,

 

Like I said, the Document.EditFamily is what you seem to need. It does create a documement of the existing family in memory. In fact, it does not require an existing fammily file - it may be long gone. However, Revit cannot give you access to the "live" stream of the family data. It can only give youa copy to play with. If you make changes there, you need to loaded back to the host document - that will replace the existing family there, naturally. 

Arnošt Löbel

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