v2.37
 
General principles

In order to better understand the API of the Renga system, it is useful to read about the basic principles of the organization and internal mechanisms of the Renga API.

Additional interfaces

In order to develop the API without breaking binary compatibility with already released plugins, interface inheritance should not be used. Therefore, to extend some basic Renga API interface with additional functionality an "additional" interface is used.

What is additional interface?

Additional interface is an interface that can be obtained from a certain base interface by type casting through Renga internal mechanisms, rather than through standard mechanisms of object-oriented language. Another words developer receives some Renga object as a basic interface and tries to receive additional interface from it. If the object supports this additional interface the cast will succeed.

Since the Renga API is built using COM technology, the standard method QueryInterface() is used to obtain "additional" interfaces. In C#, the use of this method is hidden behind the standard language casting methods.

The interface from which a particular interface can be obtained is described in the Renga API documentation.

Examples

Receive Assembly model

In order to get Assembly model objects, you can get an assembly instance as a basic IEntity interface and cast it to the IModel interface.

C++

auto pAssembly = pProject->Assemblies->GetById(assemblyId);
auto pAssemblyModel = Renga::IModelPtr{};
pAssembly->QueryInterface(&pAssemblyModel);
if (pAssemblyModel != nullptr)
{
// work with assembly objects model
}

C#

var assembly = project.Assemblies.GetById(assemblyId);
var assemblyModel = assembly as Renga.IModel;
if (assemblyModel)
{
// work with assembly objects model
}

Receive Material properties

In order to get Material properties, you can get a material instance as a basic IEntity interface and cast it to the IPropertyContainer interface.

C++

auto pMaterial = pProject->Materials->GetById(materialId);
auto pMaterialProperties = Renga::IPropertyContainerPtr{};
pMaterial->QueryInterface(&pMaterialProperties);
if (pMaterialProperties!= nullptr)
{
// work with material properties
}

C#

var material = project.Materials.GetById(materialId);
var materialProperties = material as Renga.IPropertyContainer;
if (materialProperties)
{
// work with material properties
}

Receive object level settings

In order to get object level settings, you can get an object instance as a basic IModelObject interface and cast it to the ILevelObject interface.

C++

auto pModelObjects = pProject->Model->GetObjects();
for (int i = 0; i < pModelObjects->Count; i++)
{
auto pModelObject = pModelObjects->GetByIndex(i);
Renga::ILevelObjectPtr pLevelObject;
pModelObject->QueryInterface(&pBeamParams);
if (pLevelObject)
{
// Work with object position on level
}
}

C#

var modelObjects = project.Model.GetObjects();
for (int i = 0; i < modelObjects.Count; i++)
{
var modelObject = modelObjects.GetByIndex(i);
var levelObject = modelObject as Renga.ILevelObject;
if (levelObject)
{
// Work with object position on level
}
}