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: 

Viewport error with linked project

4 REPLIES 4
Reply
Message 1 of 5
t.galland.demanneville
310 Views, 4 Replies

Viewport error with linked project

Hello everyone,

 

I'm using the revit API to create some views (floor, ceilling and sections) wand put them on viewsheet with the following code :

 

dimensionsvue.Clear();
ViewSheet vs; vs = FichesSheets.Sheets(doc, fiche_locaux.nom, fiche_locaux.nomlocal, nbfeuille, Locaux.tx); iddebut = 0; idfin = FichesViews.vuescoupe.Count - 1; Viewport viewport = Viewport.Create(doc, vs.Id, FichesViews.vuescoupe[i].Id, new XYZ(fiche_locaux.PointRef[0].X + largeur / 2, fiche_locaux.PointRef[0].Y - (hauteur / 2), 0)); dimensionsvue.Add(new dimensions( viewport, Math.Abs(viewport.GetBoxOutline().MaximumPoint.X - viewport.GetBoxOutline().MinimumPoint.X), Math.Abs(viewport.GetBoxOutline().MaximumPoint.Y - viewport.GetBoxOutline().MinimumPoint.Y)));

it's working great but if I use linked project it dosn't work anymore. When debuging, it just go until Viewport.create and directly jump to getname.

I don't know why ?

 

Thanks for your help.

Thibaud

 

4 REPLIES 4
Message 2 of 5

Hi Thibaud,
Linked documents are read-only.
Perhaps that is the issue?
If not, please provide more data.

Cheers,

-Matt

Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 3 of 5

Thank you for your help but still not working.

 

What I tried last is to create a small project with few element. I tried my add-on and it worked as expected.

So I created a second empty project and I linked it to the first one and try again the plug-in. Here my code juste crashed at viewport.create.

What would help you to help me ?

 

Thank you

 

Thibaud

Message 4 of 5

I just saw this error in the list of every parameters : 

Outline = 'new System.Collections.Generic.Mscorlib_CollectionDebugView<Autodesk.Revit.DB.ViewSection>(FichesViews.vuescoupe).Items[0].Outline' threw an exception of type 'System.AccessViolationException' in all my section views. But I can' find from where it comes.

 

sorry for the double post, I can't edit my last one.

 

Thibaud

Message 5 of 5

Hi Thibaud,

 

To help further, I would need more code.

If you don't show what your objects are initialised as, or what your personal functions do, the code you posted actually makes little sense. (Certainly not to an English speaker like me!)

 

If you're passing a document to a function, that has to be the modifiable document. You also need to pass elementIds from that document to that function. You can't mix and match, if that's what you're trying to do. And you can't modify a linked document.

 

To be clear though, if you cannot do what you're trying in the Revit UI, I doubt you would be able to do it using the API

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?

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