How to "Highlight in Model" using the API's?

How to "Highlight in Model" using the API's?

0001des
Enthusiast Enthusiast
1,378 Views
5 Replies
Message 1 of 6

How to "Highlight in Model" using the API's?

0001des
Enthusiast
Enthusiast

Anyone know the API's for "Highlight in model," or is that not exposed?

1,379 Views
5 Replies
Replies (5)
Message 2 of 6

stever66
Advisor
Advisor
0 Likes
Message 3 of 6

karim.djenkal
Explorer
Explorer

Hi,

Have you found anything interesting since?

Thanks.

0 Likes
Message 4 of 6

0001des
Enthusiast
Enthusiast
Lol. No.

That project ended ages ago and i stopped asking Autodesk for help.
Message 5 of 6

karim.djenkal
Explorer
Explorer

ElementId elementId = new ElementId(id);
List<ElementId> ids = new List<ElementId>();
ids.Add(elementId);
UIDocument uiDoc = app.ActiveUIDocument;
uiDoc.Selection.SetElementIds(ids);
uiDoc.ShowElements(ids);

0 Likes
Message 6 of 6

joshua.lumley
Advocate
Advocate

Try This:

                Element myElement = doc.GetElement(uidoc.Selection.GetElementIds().First());

                using (Transaction tx = new Transaction(doc))
                {
                    tx.Start("Manual Color Override");

                    OverrideGraphicSettings ogs = new OverrideGraphicSettings();
                    OverrideGraphicSettings ogsCheeck = doc.ActiveView.GetElementOverrides(myElement.Id);
                    FillPatternElement myFillPattern = new FilteredElementCollector(doc).OfClass(typeof(FillPatternElement)).Cast<FillPatternElement>().First(a => a.Name.Contains("Solid fill"));

                    ogs.SetSurfaceBackgroundPatternId(myFillPattern.Id);
                    ogs.SetSurfaceBackgroundPatternColor(new Autodesk.Revit.DB.Color(255, 255, 0));

                    if (ogsCheeck.SurfaceBackgroundPatternId.IntegerValue != -1) 
                    {
                        doc.ActiveView.SetElementOverrides(myElement.Id, new OverrideGraphicSettings()); //if it already has overwrites, this removes it.
                    }
                    else
                    {
                        doc.ActiveView.SetElementOverrides(myElement.Id, ogs);
                    }

                    uidoc.ActiveView.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set(myElement.Id.IntegerValue.ToString());
                    tx.Commit();
                }
0 Likes