Warm tip: This article is reproduced from serverfault.com, please click

How to access View Template Properties for Revit and compare them in Real Time?

发布于 2018-06-08 18:42:55

I am trying to list the view template’s properties so we can compare them with another old template. For example what model elements are hidden or have overrides in a given template or which Revit links have been hidden or overridden in a given template.

View Template (https://www.google.com/search?q=view+template+revit&rlz=1C1GGRV_enUS770US770&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjLndrd2cTbAhVESq0KHX1cAPwQ_AUICygC&biw=1536&bih=824#imgrc=Q0v-pV7Nxl4kfM:)

I’m looking to devise a View Template Compare tool and access to the owner and creator of them.

public void ApplyViewTemplateToActiveView()
{
    Document doc = this.ActiveUIDocument.Document;
    View viewTemplate = (from v in new FilteredElementCollector(doc)
        .OfClass(typeof(View))
        .Cast<View>()
        where v.IsTemplate == true && v.Name == "MyViewTemplate"
        select v)
        .First();
    using (Transaction t = new Transaction(doc,"Set View Template"))
    {
        t.Start();           
        doc.ActiveView.ViewTemplateId = viewTemplate.Id;
        t.Commit();
    }
}

With Revit API you can access with: GetTemplateParameterIds Method / ViewTemplateId Property

Questioner
Alberto Tono
Viewed
12
konrad 2018-06-13 03:27:15

Yes, and no.

Yes, I guess you can use Forge Model Derivative API to export RVT file and then build a dashboard around the View Templates data. That's assuming that View Templates data actually gets exported when the model is translated. That data is not attached to any geometry so I would not be surprised if it was skipped. The question here is why? This is like renting a 16-wheel truck to move a duffel bag across the street.

No, if your intention is to directly interact with the RVT model. Forge can view it, but to push anything back or request changes to the model, is not available yet. Then again, I am not even sure that the view template data is available via model derivative exports.

This brings me another alternative. Why not just collect the data using Revit API, the standard way and then push it out to a Database and build on top of that? There is no reason to employ Forge for any of that.