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: 

return to main project

18 REPLIES 18
Reply
Message 1 of 19
R.van.den.Bor
471 Views, 18 Replies

return to main project

I have the following situation.

 

I am in a project and I create a new family. After I save the family and close it, I am back in my project file, BUT my ribbon is the ribbon of the family editor (with "create" and not "Architecture"as first panel). It looks like revit still thinks I am in the family.

 

My question is how can I save the family and return to my project with it's own ribbon ?

 

My code looks something like this :

 

Document ProjectDoc = commandData.Application.ActiveUIDocument.Document; //main project I start in

 

Document fdoc = commandData.Application.Application.NewFamilyDocument(templateFileName); //make new family

 

// make the most beautifull family you'd ever seen with sweeps, extrusions ect.

 

SaveAsOptions opt = new SaveAsOptions();
opt.OverwriteExistingFile = true;
fdoc.SaveAs(sfd.FileName, opt);
commandData.Application.OpenAndActivateDocument(ProjectDoc.PathName); //make project active again (If I check active document is project)
fdoc.Close();

 

My ribbon stays the one of the family editor, it even has the "Load family into project" button, which tells me "There are no other projects open to load this project into". 

 

Does anybody know how to get my project ribbon back ? Or what I am doing wrong because apperently revit somehow is under the impression the family document (fdoc) is still opened ??

 

 

 

 

Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
18 REPLIES 18
Message 2 of 19

Hello,

 

I did a little bit of research and do not see any problems with your code. The following blog post for instance has very similar code to yours:

 

http://thebuildingcoder.typepad.com/blog/2011/06/creating-and-inserting-an-extrusion-family.html

 

I dont see any reports about the ribbon context not changing. Do you see the ribbon stay the same even if you are working with elements in the current project?

 

Best Regards

Gopinath

Message 3 of 19

It's strange. Everything is normal, until I use the code to make a family. Sometimes the first time the ribbon is okay, but when I run the code a second time, the ribbon stays as if you are working in the family editor... I will try another computer later on.
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 4 of 19

Dear Remy,

Did you get this resolved?

If not, can you please confirm that you are indeed using the latest update release?

I hope this helps.

Best regards,

 

Jeremy



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

Message 5 of 19
Joe.Ye
in reply to: R.van.den.Bor

As I know there is a exception with the Ribbon. This exception can be fixed by install the web update of Revit 2014. Would you please install the latest Revit update to see if this can be fixed? Update can be download in this page. (http://usa.autodesk.com/adsk/servlet/ps/dl/index?siteID=123112&id=2334435&linkID=21208796)


Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 6 of 19

Hello jeremy, the problem is still there 😞
Everytime I run the code above, the ribbon changes from the Project ribbon to the family editor Ribbon and statys this way until I close the current project and open it (or another project) again.

I'm using version :
20131024_2115(x64)
Update Release 2
Windows 8 64 bits
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 7 of 19
R.van.den.Bor
in reply to: Joe.Ye

The Page You Requested Was Not Found
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 8 of 19

Remove the closing parenthesis:

 

http://usa.autodesk.com/adsk/servlet/ps/dl/index?siteID=123112&id=2334435&linkID=21208796)

 

-->

 

http://usa.autodesk.com/adsk/servlet/ps/dl/index?siteID=123112&id=2334435&linkID=21208796

 

Unfortuneately, that just lists the update releases.

 

It does not mention this specific issue, as far as I can see.

 

However, I do also seem to remember seeing this problem mentioned before and resolved by an UR.

 

Cheers,

 

Jeremy



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

Message 9 of 19

Well I know issues with the ribbon related to in installation of revit LT next to Revit, bu in my case everything works normal, until I use the code above. It's like the family is being created in the background, and after the family is saved, the family document isn't properly closed and statys open.
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 10 of 19

Dear Remy,

Maybe it will help if you can add some suitable code to explicitly cose the family document a bit more, or switch back to the main document a bit more, or add some more transactions, or a transaction group, or something, to definitly force Revit into a stable settled state and really forget about the family for good.

Does the code that Joe pointed to do that successfully for you?

Cheers,

Jeremy



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

Message 11 of 19

Hi Jeremy,

 

I don't see whats different about the Code Joe pointed out and mine. I tried some extra transactions, no result. Is there some kind of way I can refresh or address a certain ribbon panel ?

Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 12 of 19
Revitalizer
in reply to: R.van.den.Bor

Hi Remy,

 

I faced a similar problem some time ago.

 

In the case that my familiy creation has failed, there was a document with no active View still opened in Revit.

This document caused Revit not to show the start screen that should appear in a non-document environment.

Also, ribbon didn't change but remained in family context.

 

I worked around this by closing all documents which have no active view and whose names begin with "Family" respectively "Familie" after doing my family creation stuff.

Thus, all *failed* new families with temporary names like "Family 1", "Family 2" etc. are removed from application.

Since my (successfully) newly created Family has a different name than "Family XY", it is not affected by this workarounding.

 

May this help you ?

 

 

Best regards,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 13 of 19
R.van.den.Bor
in reply to: Revitalizer

Your idea gave me an idea 🙂 I thought, let's see what documents revit thinks are still open after I created the family. So I am in a project, create the family and then use "snoop Application" with revit lookup, I get a .NET error saying "the managed object is not valid". Weird..
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 14 of 19

Well, I am one step closer .. Now snoop doesn't crash anymore and I can see nly one document open (so the created family document is indeed closed). Although I set my project back as active document, even "captured" the active view before creating the family, and afterwards the the active view back to the original. Nothing helps 😞  The ribbon stays like in a family document.

 

No here is the crazy thing, when I am in this "family ribbon" state and I now open revit lookup, choose Snoop application and click on Documents, my ribbon comes back ?? 

Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 15 of 19

Dear Remy,

Please debug.

> I get a .NET error saying "the managed object is not valid".

Please debug, fix it, and submit the fix to GitHub:

https://github.com/jeremytammik/RevitLookup

> I now open revit lookup, choose Snoop application and click on Documents, my ribbon comes back ??

Please debug and examine what is going on.

RevitLookup is an external application, you have all the source code, everything that it does you can do in your own add-in as well.

Please base your exloration on the most up-to-date version:

https://github.com/jeremytammik/RevitLookup

Many thanks to Revitalizer for his valuable experiences, creative ideas and helpful hints!

Best regards,

Jeremy



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

Message 16 of 19

Hello Jeremy, I think you misunderstood me. I hven't found a bug in Revit lookup! The problem I have is I am making a new family through the APi and when I saved the family and close the document, the ribbon stays in "family editor" mode, even when I set my project file active. For an example I gave Revit lookup, since by the procedure I described, suddenly my ribbon is back to "project" mode. I still haven't found out why the ribbon stays in family mode, and why it suddenly changes back to "project" mode, when I use revit lookup.
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 17 of 19

Dear Remy,

Thank you for your update.

I was simply referring to your statement that "I get a .NET error saying 'the managed object is not valid'" and later that "snoop doesn't crash anymore". The reason for such behaviour can be determined using the debugger, and an exception handler added to avoid it.

You don't say whether you were able to successfully make use of the valuable suggestions by Revitalizer... how did it go?

Best regards,

 

Jeremy



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

Message 18 of 19

Tried it, same result 😞 But I am still testing. It seems when I use the code for making 1 family, the ribbon behaves normally. When I use the code to make several families in a loop, it goes wrong. As soon as I solved it, I will post.
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 19 of 19
cig_ad
in reply to: R.van.den.Bor

Hi Remy,

 

did you resolve this? I seem to have the same problem. - thanks, Peter

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