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 ??
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
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
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
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
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 ?
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
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 ??
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
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
Hi Remy,
did you resolve this? I seem to have the same problem. - thanks, Peter