« Revit 2011 API Webcast | Main | Plug-In Migration Steps »

April 21, 2010

Comments

Wow good summary. Must admit not sure why this is causing so much angst. I vote for automatic to be deleted ASAP. Performance is everything and Manual beats Automatic hands down.

Throwing an exception is hardly a problem if you're doing things in a try-catch (doesn't everyone?). Maybe a better solution for beginners is to regenerate for the user and write a comment to the journal.

The 2 points I think summarise it nicely are:

"""It is needed when such changes are made that could affect elements of which properties are needed to be read again""" (Regenerate/ AutoJoin / ViewRefresh

"""committing a transaction will always invoke regeneration and auto-joining"""

The sooner Automatic mode goes the better...

Cheers,
Guy

Hi Guy,

Wow to you too, I am very glad you like it and thank you very much for your valued opinion! Seriously!

Cheers, Jeremy.

Hello Jeremy:

Is it possible to regenerate model in 2010?

I have this requirement to update the parameters of some family types and would like to regenerate the model to effect the changes in my program.

Would that be possible?

Thanks,
-Saro

Dear Saro,

Yes, in 2010 you can often update the model by either closing and committing a transaction or, in an extreme case, by saving the model.

An example of the former is given by

http://thebuildingcoder.typepad.com/blog/2010/01/extra-transaction-required.html

In another sample, I saw an application saving the entire model using the Document.Save method to ensure that a view was updated in between various sequential steps performed by the application.

Cheers, Jeremy.

A friend and I am trying to write an add-on that will loop through a list of families, open each family extract a list of type names and parameters values and close it without saving.

The code I have post below works for a small number of families (less that 100) but Revit crashes when we process a large number (more than 100)
it displays a dialog saying there was a “memory corruption”. It would happen during the opening of a file “OpenDocumentFile()”(see code below).
Is there a better way to loop through families opening and closing them?
Could we have an external application fire up Revit and run my plugin. The external application could keep track of which file was next.

Thank you very much any help would be much appreciated.
void LoadFamily(Autodesk.Revit.ApplicationServices.Application app,
ExternalCommandData commandData, string filename, StreamWriter writer)
{
try
{
if (string.IsNullOrEmpty(filename))
return;

if (!File.Exists(filename))
return;

Document activeDoc =
commandData.Application.ActiveUIDocument.Document;

if (activeDoc != null)
activeDoc.Close();

activeDoc = app.OpenDocumentFile(filename);

if (activeDoc == null)
return;

//process the document and add data to an external file
}
catch (Exception e)
{
MessageBox.Show(e.Message + "\n" + filename);
}
}

Dear Nicholas,

I guess this is a follow-up to your previous question:

http://thebuildingcoder.typepad.com/blog/2010/03/using-processstart-to-open-a-project-or-family.html?cid=6a00e553e168978833013483b6bad8970c#comment-6a00e553e168978833013483b6bad8970c

As I said there, you are trying to close the active Revit UI document, which is not possible, and not closing the document you opened yourself.

In the first couple of lines, your variable activeDoc is set to point to the current active document in the Revit user interface and trying to close that:

Document activeDoc
= commandData.Application.ActiveUIDocument.Document;

if (activeDoc != null)
activeDoc.Close();

Since the Revit API cannot close the active document, this call will have no effect.

Thereafter, you are setting the same variable to point to a completely different new document, opened n the background:

activeDoc = app.OpenDocumentFile(filename);

This will obviously consume memory, and is never closed, as far as I can tell, so the memory will never be freed.

You will need to make sure that you really close the documents that you open.

Cheers, Jeremy.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

Jeremy Tammik

AboutTopicsIndexSource