DATAKIT SDK  V2026.2
How to use Attributes

Generalities about entity attributes

You can retrieve attributes from many Datakit objects, any class inheriting from Dtk_Entity or Dtk_DocElement being eligible.
This includes various data :

  • General : name, color, visibility, layer informations
  • Metadata : PDM file properties, generic custom properties (named values)
  • Rendering : Surface lighting and texturing information.
  • Material : Definition of physical properties of used material (name, density, conductivity, strength...)

Common entities on which attributes can be found are :

Sample code

Dtk_NodePtr layerInfoSetNode;
Dtk_LayerInfosSetPtr layerSet = layerInfoSetNode->GetDtk_LayerInfosSetPtr();
Dtk_NodePtr inNode;
/* Get Dtk_InfoPtr class */
Dtk_InfoPtr infos = inNode->GetInfos();
/* Retrieve inNode blanked status : -1 = undefined, 0 = Visible, 1=Invisible, 2=Construction Geometry */
int NodeBlankedStatus = infos->GetBlankedStatus();
/* Retrieve inNode activation status : 1 = Activated (Shown), 0 = Disable (Not Shown)*/
int ActivationStatus = infos->GetActivationFlag();
/* Retrieve inNode name */
Dtk_string name = infos->GetName();
/* Retrieve inNode color RGB */
Dtk_RGB color = infos->GetColor();
/* Retrieve inNode layer */
int layer = infos->GetLayer();
/* Retrieve inNode layer name */
Dtk_string layerName;
auto error = layerSet.GetLayerByID( layer, out );
if ( error == dtkNoError )
layerName = out.GetName();
/* Retrieve inNode list of layer it appears in */
/* Retrieve inNode render information (Lights, texture data) */


Focus on layers

Calling Dtk_Info::GetLayer() provides a layer identifier, of which the entity belong.
For format allowing an entity to be listed in multiples layers, Dtk_Info::GetlayerList() allow to retrieve the list of layers the entity belong to.
If the said entity appears in only one layer, this call is equivalent to Dtk_Info::GetLayer().

In case the format allows more information relative to layers, such as name assignment or layer filtering, Dtk_LayerInfosSet allows to retrieve those information.
They live in the context of a Dtk_Component.
See Dtk_LayerFilterInfos and Dtk_LayerInfosSet interface and detailed description for more information.

Dtk_LayerInfosSet sample code

/* Set creation */
Dtk_LayerInfosSetPtr in = Dtk_LayerInfosSet::Create();//Creates a layer set.
in->AddLayer( Dtk_LayerInfosSet::Layer( 42, L"42" ) );
in->AddLayer( Dtk_LayerInfosSet::Layer( 50, L"Layer fifty" ) );
in->AddLayer( Dtk_LayerInfosSet::Layer( 1025 ) );
in->SetCurrentLayer( 2 ); //The layer with index 2 becomes the current layer.
auto const& createdFilter = in->CreateLayerFilterInfos( L"simple filter", L"A simple filter", DTK_FALSE, DTK_TRUE );//Creates a filter that is the default, where none of the set's layers are selected.
createdFilter->SelectLayer( 1 );
createdFilter->SelectLayer( 2 );
/* Browse through layers */
for ( Dtk_LayerInfosSet::Layer layer : in.GetLayers() )
{
Dtk_string LayerName = layer.GetName();
Dtk_ID LayerID = layer.GetID();
}
/* Find a specific layer */
auto status = in->GetLayerByID( 50, layerWithID50 );//Get layer with ID 50
if( status != dtkNoError )
std::cout << "Layer 50 not found" << std::endl;
else
std::cout << layerWithID50.GetName() << std::endl;//prints "Layer fifty"
/* Find current layer */
Dtk_Size_t currentIndex = 0;
Dtk_Size_t indexCount = 0;
status = in->GetCurrentLayer( currentIndex );
if( status == dtkNoError )
{
for ( Dtk_LayerInfosSet::Layer layer : in.GetLayers() )
{
if( indexCount == currentIndex )
std::cout << layer.GetID() << std::endl; //prints 1025
indexCount++;
}
}
/* Browse through layer filters */
for( Dtk_Size_t i = 0; i < in->GetNumLayerFilters(); ++i )
{
auto const& filter = in->GetLayerFilterByPos( i );
Dtk_tab<Dtk_Size_t> outIndexes;
filter->GetSelectedLayers( outIndexes );
for( Dtk_Size_t j = 0; j < outIndexes.size(); ++j )
{
Dtk_string selectedLayerName; Dtk_ID selectedLayerID;
in->GetLayerName( outIndexes[ j ], selectedLayerName );
in->GetLayerID( outIndexes[ j ], selectedLayerID );
}
}
/* Find default layer filter */
Dtk_Size_t defaultFilterIndex = 0;
Dtk_string defaultFilterLayerName, defaultFilterLayerDescription;
status = in->GetDefaultLayerFilter( defaultFilterIndex );
if( status == dtkNoError )
{
auto const& defaultFilter = in->GetLayerFilterByPos( defaultFilterIndex );
defaultFilter->GetName( defaultFilterLayerName );
defaultFilter->GetDescription( defaultFilterLayerDescription );
std::cout << defaultFilterLayerName << " : " << defaultFilterLayerDescription << std::endl;//prints "simple filter : A simple filter"
}
Dtk_ID
uint32_t Dtk_ID
Definition: define.h:681
Dtk_Info::GetName
Dtk_string GetName() const
Retrieves the entity name.
Dtk_Info::GetBlankedStatus
int GetBlankedStatus() const
Retrieves the entity Blanked Status.
Dtk_LayerInfosSet::Layer
Definition: util_ent_dtk.hpp:519
DTK_TRUE
#define DTK_TRUE
Definition: define.h:719
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:704
Dtk_Info::GetColor
Dtk_RGB GetColor() const
Retrieves the entity color as Dtk_RGBA values.
Dtk_Info::GetActivationFlag
int GetActivationFlag() const
DTK_FALSE
#define DTK_FALSE
Definition: define.h:720
Dtk_Node::GetDtk_LayerInfosSetPtr
Dtk_LayerInfosSetPtr GetDtk_LayerInfosSetPtr()
Retrieves the Dtk_Node as a Dtk_LayerInfosSetPtr - if exists -.
Dtk_DocElement::GetInfos
Dtk_InfoPtr GetInfos() const
Retrieves the Dtk_DocElement Dtk_InfoPtr - read only -.
Dtk_Info::GetLayer
int GetLayer() const
Retrieves the entity layer.
Dtk_Info::GetRenderInfos
Dtk_RenderInfosPtr GetRenderInfos() const
Retrieves the entity RenderInfos of the entity.
Dtk_SmartPtr< Dtk_Node >
Dtk_DumpXml_Dtk_RenderInfos
Dtk_ErrorStatus Dtk_DumpXml_Dtk_RenderInfos(FILE *F, const Dtk_RenderInfosPtr &inRender)
Definition: util_xml_dtk.cpp:3697
Dtk_tab< Dtk_Int32 >
Dtk_LayerInfosSet::Create
static Dtk_LayerInfosSetPtr Create()
Calls default constructor to allocate a new object.
Dtk_tab::size
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:503
Dtk_Info::GetlayerList
Dtk_tab< Dtk_Int32 > GetlayerList() const
Retrieves the layers in which the entity is assigned.
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:149
Dtk_RGB
Definition: dtk_rgb.hpp:7
Dtk_LayerInfosSet::Layer::GetName
Dtk_string const & GetName() const
Definition: util_ent_dtk.hpp:544