Modify View Template's V/G Overrides Model

Modify View Template's V/G Overrides Model

EATREVITPOOPCAD
Collaborator Collaborator
968 Views
1 Reply
Message 1 of 2

Modify View Template's V/G Overrides Model

EATREVITPOOPCAD
Collaborator
Collaborator

Can somebody point me in the right direction here... I would like to hide/show object types in the V/G Overrides Model for a specific View Template, (for which I have the ViewTemplateID)

 

The definition of insanity is doing the same thing over and over again and expecting different results
0 Likes
Accepted solutions (1)
969 Views
1 Reply
Reply (1)
Message 2 of 2

EATREVITPOOPCAD
Collaborator
Collaborator
Accepted solution

So I was brain farting a bit while burning the midnight fuel and couldn't figure out that View Templates are the same class as Views...

 

 

            UIApplication uiapp = commandData.Application;

            Document doc = uiapp.ActiveUIDocument.Document;
            Selection sel = uiapp.ActiveUIDocument.Selection;

            View cView = doc.ActiveView;
            View viewTemplate = doc.GetElement(cView.ViewTemplateId) as View;

            Reference sourceReference = sel.PickObject(ObjectType.Element, "Select object type");

            Element sourceElement = doc.GetElement(sourceReference.ElementId);

            using (Transaction t = new Transaction(uiapp.ActiveUIDocument.Document))
            {
                t.Start("It's about to hide!");

                viewTemplate.SetCategoryHidden(sourceElement.Category.Id, true);

                t.Commit();
            }

 

The definition of insanity is doing the same thing over and over again and expecting different results
0 Likes