/
Edwar
/
cam-api-examples
Обзор
Документация
Войти
/
Edwar
/
cam-api-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Attributes/ExtensionAttributesManageNet/project/main/AttributesDescriber.cs
54 строки
2 KB
cepera
Example to work with custom attrinutes of different objects inside CAM system
04 фев 2025, 16:30
04 фев 2025, 16:30
9ea2c8a
Код
Авторство
О чём код?
using System.Diagnostics; using CAMAPI.DotnetHelper; using CAMAPI.CustomAttributes; namespace ExtensionAttributesManageNet; /// <summary> /// Prints all attributes inside tree iterator to Debug console /// </summary> internal static class AttributesDescriber { /// <summary> /// Prints all attributes inside tree iterator to Debug console /// </summary> public static void Describe(ICamApiCustomAttributesTreeIterator it, int indentCount = 0) { // Decribe attribute of current node using var node = ComWrapper.Create(it.CurrentNode); using var a = ComWrapper.Create(node.It.Attribute); var indent = new string(' ', indentCount*4); Debug.Write(indent); Debug.Write("Attribute '" + a.It.Name + "' of type " + a.It.ValueType); switch (a.It.ValueType) { case TCustomAttributeValueType.avtString: Debug.Write(" with value '" + ((ICamApiStringCustomAttribute)a.It).Value + "'"); break; case TCustomAttributeValueType.avtInteger: Debug.Write(" with value '" + ((ICamApiIntegerCustomAttribute)a.It).Value + "'"); break; case TCustomAttributeValueType.avtFloat: Debug.Write(" with value '" + ((ICamApiFloatCustomAttribute)a.It).Value + "'"); break; case TCustomAttributeValueType.avtBoolean: Debug.Write(" with value '" + ((ICamApiBooleanCustomAttribute)a.It).Value + "'"); break; } Debug.WriteLine(""); // Enumerate children of current node using var chItW = ComWrapper.Create(it.GetCopy()); var chIt = chItW.It; if (chIt.MoveToChild()) { do { Describe(chIt, indentCount+1); } while (chIt.MoveToSibling()); chIt.MoveToParent(); } } }