General Questions

General Questions

Q: How do I reference an element in Revit?

A: Each element has an ID. The ID that is unique in the model is used to make sure that you are referring to the same element across multiple sessions of Revit.

Q: Can a model only use one shared parameter file?

A: Shared parameter files are used to hold bits of information about the parameter. The most important piece of information is the GUID (Globally Unique Identifier) that is used to insure the uniqueness of a parameter in a single file and across multiple models.

Revit can work with multiple shared parameter files but you can only read parameters from one file at a time. It is then up to you to choose the same shared parameter file for all models or a different one for each model.

In addition, your API application should avoid interfering with the user's parameter file. Ship your application with its own parameter file containing your parameters. To load the parameter(s) into a Revit file:

Q: Do I need to distribute the shared parameters file with the model so other programs can use the shared parameters?

A: No. The shared parameters file is only used to load shared parameters. After they are loaded the file is no longer needed for that model.

Q: Are shared parameter values copied when the corresponding element is copied?

A: Yes. If you have a shared parameter that holds the unique ID for an element in your database, append the Revit element Unique ID or add another shared parameter with the Revit element unique ID. Do this so that you can check it and make sure you are working with the original element ID and not a copy.

Q: Are element Unique IDs (UID) universally unique and can they ever change?

A: The element UIDs are universally unique, but element IDs are only unique within a model. For example, if you copy a wall from one Revit project to another one, the UID of the wall is certain to change to maintain universal uniqueness, but the ID of the wall may not change.

Q: Revit takes a long time to update when my application sends data back to the model. What do I need to do to speed it up?

A: Make sure you only call Document.Regenerate() as often as necessary. Although this method is required to make sure the elements in the Revit document reflect all changes, it can slow down your application. Keep in mind, too, that when a transaction is committed there is an automatic call to regenerate the document.

Q: What do I do if I want to add shared parameters to elements that do not have the ability to have shared parameters bound to them? For example, Grids or Materials.

A: If an element type does not have the ability to add shared parameters, you need to add a project parameter. This does make it a bit more complicated when it is time to access the shared parameter associated with the element because it does not show up as part of the element's parameter list. By using tricks like making the project shared parameter a string and including the element ID in the shared parameter you can associate the data with an element by first parsing the string.

Q: How do I access the saved models and content BMP?

A: The Preview.dll is a shell plug-in which is an object that implements the IExtractImage interface. IExtractImage is an interface used by the Windows Shell Folders to extract the images for a known file type.

For more information, review the information at Revit API Developers Guide.

CRevitPreviewExtractor implements standard API functions:

             STDMETHOD(GetLocation)(LPWSTR pszPathBuffer,
                                                DWORD cchMax,
                                                DWORD *pdwPriority,
                                                const SIZE *prgSize,
                                                DWORD dwRecClrDepth,
                                                DWORD *pdwFlags);
                STDMETHOD(Extract)(HBITMAP*);

It registers itself in the registry.