v2.25
How to change objects visibility and visual style

Overview

Renga API allows developers to obtain and change visibility and visual style of objects in model views. To work with visibility and visual style, obtain the IView interface via IApplication::GetActiveView() and cast it to the IModelView interface. Visibility can only be set for objects, however, visual style can be set for a whole view as well.

How to obtain current project view

The code below demonstrates how to obtain the current project view.

C++

Renga::IApplicationPtr pApplication = Renga::CreateApplication();
Renga::IViewPtr pView = pApplication->GetActiveView();

C#

Renga.IApplication application = new Renga.Application();
Renga.IView view = application.GetActiveView();

How to change visibility of objects

The code below demonstrates how to set visibility of the object with ID equal to 8.

C++

void ChangeVisibility(Renga::IViewPtr pView)
{
Renga::IModelViewPtr pModelView;
pView->QueryInterface(&pModelView);
if (pModelView)
{
ATL::CComSafeArray<int> ids(1);
ids[0] = 8;
pModelView->SetObjectsVisibility(ids, VARIANT_TRUE);
}
}

C#

public void ChangeVisibility(Renga.IView view)
{
Renga.IModelView modelView = view as Renga.IModelView;
if (modelView != null)
{
int[] ids = new int[] { 8 };
modelView.SetObjectsVisibility(ids, true);
}
}

How to change the visual style of an object

The code below demonstrates how to set the visual style of objects with identifiers 20, 21, 22.

C++

void ChangeVisualStyle(Renga::IViewPtr pView)
{
Renga::IModelViewPtr pModelView;
pView->QueryInterface(&pModelView);
if (pModelView)
{
ATL::CComSafeArray<int> ids(3);
ids[0] = 20;
ids[1] = 21;
ids[2] = 22;
pModelView->SetObjectsVisualStyle(ids, VisualStyle_Color);
}
}

C#

public void ChangeVisualStyle(Renga.IView view)
{
Renga.IModelView modelView = view as Renga.IModelView;
if (modelView != null)
{
int[] ids = new int[] { 20, 21, 22 };
modelView.SetObjectsVisualStyle(ids, VisualStyle.VisualStyle_Color);
}
}

How to change the visual style of a view

The code below demonstrates how to set the visual style of a view.

C++

void ChangeViewVisualStyle(Renga::IViewPtr pView)
{
Renga::IModelViewPtr pModelView;
pView->QueryInterface(&pModelView);
if (pModelView)
pModelView->VisualStyle = VisualStyle_Monochrome;
}

C#

public void ChangeViewVisualStyle(Renga.IView view)
{
Renga.IModelView modelView = view as Renga.IModelView;
if (modelView != null)
modelView.VisualStyle = VisualStyle.VisualStyle_Monochrome;
}

See also

Related samples

  • VisualStyleAndVisibility
VisualStyle_Color
@ VisualStyle_Color
Colored visual style.
Definition: VisualStyle.idl:21
VisualStyle
VisualStyle
An enumeration type for supported visual styles.
Definition: VisualStyle.idl:17
VisualStyle_Monochrome
@ VisualStyle_Monochrome
Monochrome visual style.
Definition: VisualStyle.idl:20