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: 

Importing specific views from a .RVT file

8 REPLIES 8
Reply
Message 1 of 9
SomeBuddy
1685 Views, 8 Replies

Importing specific views from a .RVT file

Hi there,

While I am in a Revit 2012 document, I need to import a number of specific views from another RVT file.

Is this possible? Des anyone already made it work?

Please provide some feedback. Code chunks would be great

TIA,

Buddy

8 REPLIES 8
Message 2 of 9
chekalin-v
in reply to: SomeBuddy

View is a... just view of model. There is another model in another RVT file. So it is impossible and cannot be possible.

Or may be you mean somthing else. Please explain. 

Message 3 of 9
SomeBuddy
in reply to: chekalin-v

Hi,

 

See attachment.

 

Buddy

Message 4 of 9
chekalin-v
in reply to: SomeBuddy

Ok. Now I can see that you mean.

Document.Import(...) method doesn't contain overloaded methods that allows to import views from other revet document.

Also, I've tried to do it using following

var doc = commandData.Application.ActiveUIDocument.Document;
                            
            var ofd = new OpenFileDialog();
            ofd.DefaultExt = "rfa";
            ofd.Filter = "Templates (*.rfa)|*.rfa|Projects (*.rvt)|*.rvt";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var fileName = ofd.FileName;
                
                Document newDoc = 
                    commandData.Application.Application.OpenDocumentFile(fileName);

                FilteredElementCollector collector2 = 
                    new FilteredElementCollector(newDoc);
                var sheets =
                    collector2.OfClass(typeof (ViewSheet))
                        .OfType<ViewSheet>();
                

                foreach (var viewSheet in sheets)
                {
                    // insert view from other document to current
                }
            }

 

1) Open revit document

2) Get specific views (in my code - ViewSheets)

3) Try to insert views to the current document. But I didn't find any methods to insert view in document... Sorry. But may be you can find this method.

 

Good luck, Victor. 

Message 5 of 9
SomeBuddy
in reply to: chekalin-v

Hi Victor,

 

Thanks anyway. I will get back to you with some feedback.

 

Buddy

Message 6 of 9
skeletank
in reply to: SomeBuddy

It would be wonderful to get feedback from an Autodesk specialist on this question.  At AU 2012 they said that they are trying to make it so that everything that you can do with the UI can also be done with the API.

 

My only alternative thought on how to do this for a drafting view would be to do export/import commands for dwf/image formats but then you would be stuck with a dumb image view.

 

Document.ExportImage(ImageExportOptions options);

Document.Import(string file, DWGImportOptions options, View pDBView, out ElementId elementId);

 

I don't know if this would work but it would be what I would try.

 

 

Message 7 of 9
arnostlobel
in reply to: skeletank

Hello skeletank;

What you had heard at AU2012 is correct. We, at Autodesk are really trying to make the Revit API as rich and powerful so that everything what is possible through the UI would also be possible to do via the API. We are trying and will continue trying going forward (though I do not think we can ever reach 100% coverage, simply for technical reasons.) We are getting closer with every major release. We do have a decent coverage in Revit 2013 (comparing to, say 2012 and 2011 – you can do the math), and with Revit 2014 just behind the corner we are getting closer still. What you asked for (copying a view from a document to a document) is not yet possible in 2013. We know, however, it sits quite high on our users’ priority lists, so we’ve made it our priority too. Please be patient.

 

Note: Please realize that copying a view and copying elements from a view to another is not the same thing. I assume that both would be desirable features to have in the API.

 

Thank you

Arnošt Löbel

Autodesk Revit R&D

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

Thank you for the quick response Arnošt.  Since there is no magic button to copy a view from document to document then would there be a way to duplicate this by copying individual element properties?  In my case I'm only dealing with drafting views so I would think that there would be a way as such:

 

You have Document 1 w/Drafting View A and you have Document 2.

 

  1. Create a new blank drafting view in Document 2
  2. Name it the same as the Drafting View A from Document 1
  3. Recreate/copy any required line styles from Document 1 to Document 2
  4. Recreate/copy any required line weights from Document 1 to Document 2
  5. Recreate any detail lines, detail components, text, etc. by creating new versions of them in Document 2 and copying the properties directly from the versions in Document 1

Would this be possible or are there any major hiccups that would prevent it outright?

Message 9 of 9
arnostlobel
in reply to: skeletank

Yes, that would be the generic approach. However, I do not think the View API 2013 is powerful enough to allow replicating settings entirely from one view to another. Therefore, you may get adequate results in some scenarios, but not in all. Recreating elements is also limited, although you ought to be covered if you work with lines only. Copying all kinds of elements is complicated because some of them are not even represented in the API (well, yet.) Therefore a true copy (from_doc, to_doc) could probably be the only way that can be guaranteed to give 100% satisfactory results (not considering any bugs, that is 😉 Like I said, we know this has been a priority and we’re trying to do our best. (On the other hand, we do not like releasing features unless we are reasonably sure they work as expected and intended.)

 

Thank you

Arnošt Löbel

Autodesk Revit R&D

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