Revit API

Reply
Valued Mentor
SomeBuddy
Posts: 372
Registered: ‎06-07-2010
Message 1 of 9 (966 Views)

Importing specific views from a .RVT file

966 Views, 8 Replies
12-06-2011 01:40 PM

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

Active Member
chekalin-v
Posts: 10
Registered: ‎07-20-2011
Message 2 of 9 (960 Views)

Re: Importing specific views from a .RVT file

12-07-2011 12:50 AM 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. 

Valued Mentor
SomeBuddy
Posts: 372
Registered: ‎06-07-2010
Message 3 of 9 (955 Views)

Re: Importing specific views from a .RVT file

12-07-2011 07:54 AM in reply to: chekalin-v

Hi,

 

See attachment.

 

Buddy

Active Member
chekalin-v
Posts: 10
Registered: ‎07-20-2011
Message 4 of 9 (943 Views)

Re: Importing specific views from a .RVT file

12-07-2011 07:48 PM 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. 

Valued Mentor
SomeBuddy
Posts: 372
Registered: ‎06-07-2010
Message 5 of 9 (930 Views)

Re: Importing specific views from a .RVT file

12-08-2011 06:57 AM in reply to: chekalin-v

Hi Victor,

 

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

 

Buddy

Active Contributor
skeletank
Posts: 26
Registered: ‎08-25-2010
Message 6 of 9 (619 Views)

Re: Importing specific views from a .RVT file

01-17-2013 12:48 PM 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.

 

 

Employee
arnostlobel
Posts: 133
Registered: ‎05-20-2011
Message 7 of 9 (601 Views)

Re: Importing specific views from a .RVT file

01-18-2013 07:52 AM 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
Sr. Principal Engineer
Autodesk, Revit R&D
Active Contributor
skeletank
Posts: 26
Registered: ‎08-25-2010
Message 8 of 9 (596 Views)

Re: Importing specific views from a .RVT file

01-18-2013 08:09 AM 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?

Employee
arnostlobel
Posts: 133
Registered: ‎05-20-2011
Message 9 of 9 (588 Views)

Re: Importing specific views from a .RVT file

01-18-2013 11:27 AM 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
Sr. Principal Engineer
Autodesk, Revit R&D

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


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.

Connect with Revit

Twitter

Facebook

Blogs

Youtube