hexagon logo

GetText and TypeIndex question

How does TypeIndex work for the GetText function? I am using C# and iterating through all of the data in the list of commands. After crawling through them I noticed that some commands have 8 instances and the last one is the one that directly relates to what I see in the command window. What are the other instances? Cany anyone explain how the typeindex works?

public static bool PrintAll(this Commands commands)
        {
            for (int i = 0; i <= commands.Count; i++)
            {
                var command = commands.Item(i);
                if (command != null)
                {
                    Console.WriteLine($"Command #: {i} Type: {command.Type}");

                    foreach (ENUM_FIELD_TYPES enumFieldType in Enum.GetValues(typeof(ENUM_FIELD_TYPES)))
                    {
                        try
                        {
                            var typeIndex = 0;
                            var cmdText = command.GetText(enumFieldType, typeIndex);
                            var prevCmdText = "";

                            // Loop while cmdText is not null or empty and different from the previous value
                            while (!string.IsNullOrEmpty(cmdText) && cmdText != prevCmdText)
                            {
                                if (typeIndex > 0)
                                {
                                    Console.WriteLine($"    index: {typeIndex}");
                                }

                                Console.WriteLine($"                {enumFieldType}: {cmdText}");

                                // Save the current cmdText as the previous value, increment typeIndex and get the next cmdText
                                prevCmdText = cmdText;
                                typeIndex++;
                                cmdText = command.GetText(enumFieldType, typeIndex);
                            }
                        }
                        catch
                        {
                            Console.WriteLine($"\n\n\n***GetText Failed*** Enum: {enumFieldType}\n\n\n");
                        }
                    }
                }
            }

            return false;
        }​
  • hi

    if the "type" has only one value then typeindex = 0, mostly:
        retval = DmisCommand.PutText ("0", THEO_Z, 0)
        retval = DmisCommand.PutText ("0", THEO_I, 0)
        retval = DmisCommand.PutText ("0", THEO_J, 0)
    



    if the "type" is a list then the "typeindex" appears to be like a count starting with 1
        retval = DmisCommand.PutText ("1.6", TRACE_VALUE_OPTION, 1)
        retval = DmisCommand.PutText ("1.55", TRACE_VALUE_OPTION, 2)
        retval = DmisCommand.PutText ("1.24", TRACE_VALUE_OPTION, 3)​
    



    I think I saw somewhere that the type index was 1, although it's not a list, but it seems to be extremely rare

    (PutText and GetText use the same "TypeIndex")
  • What I saw were 8 different values for the same enum i.e. THEO_X and the last index seemed to be the one that was visible in the UI.
  • maybe because of a loop? sorry I don't know that either.

    I stick to it: the typeindex refers (mostly) to a list.

    plz give me an example where you have 8 values for a THEO_X value, I try to see if it's the same for me
  • I created another class and place your method into the new class named: PrintProcess.

    
    Program.cs
    
    using PCDLRN;
    using RoutineTempTraceFieldCoreConsoleApp1;
    
    PcdlrnAppInteract pcdlrnAppInteract = new();
    
    PrintProcess printProcess = new(pcdlrnAppInteract.DmisCommands, pcdlrnAppInteract.DmisPart, pcdlrnAppInteract.CommandCount, pcdlrnAppInteract.DmisCommand);
    printProcess.PrintAll();​
    
    
    PrintProcess.cs
    
    using PCDLRN;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace RoutineTempTraceFieldCoreConsoleApp1
    {
        internal class PrintProcess
        {
            private readonly dynamic DmisCommands;
            public dynamic DmisPart;
            public dynamic CommandCount;
            public dynamic DmisCommand;
    
    
            public PrintProcess(dynamic dmisCommands, dynamic dmisPart, dynamic commandCount, dynamic dmisCommand)
            {
                DmisCommands = dmisCommands;
                DmisPart = dmisPart;
                CommandCount = commandCount;
                DmisCommand = dmisCommand;
            }
            public bool PrintAll()
            {
                for (int i = 0; i <= DmisCommands.Count; i++)
                {
                    var command = DmisCommands.Item(i);
                    if (command != null)
                    {
                        Console.WriteLine($"Command #: {i} Type: {command.Type}");
    
                        foreach (ENUM_FIELD_TYPES enumFieldType in Enum.GetValues(typeof(ENUM_FIELD_TYPES)))
                        {
                            try
                            {
                                var typeIndex = 0;
                                var cmdText = command.GetText(enumFieldType, typeIndex);
                                var prevCmdText = "";
    
                                // Loop while cmdText is not null or empty and different from the previous value
                                while (!string.IsNullOrEmpty(cmdText) && cmdText != prevCmdText)
                                {
                                    if (typeIndex > 0)
                                    {
                                        Console.WriteLine($"    index: {typeIndex}");
                                    }
    
                                    Console.WriteLine($"                {enumFieldType}: {cmdText}");
    
                                    // Save the current cmdText as the previous value, increment typeIndex and get the next cmdText
                                    prevCmdText = cmdText;
                                    typeIndex++;
                                    cmdText = command.GetText(enumFieldType, typeIndex);
                                }
                            }
                            catch
                            {
                                Console.WriteLine($"\n\n\n***GetText Failed*** Enum: {enumFieldType}\n\n\n");
                            }
                        }
                    }
                }
    
                return false;
            }
        }
    }​
    


    Using this example Console output for Command #: 27 that refers to Type: 191 for a TraceField.

    Console output:
    
    Command #: 27 Type: 191
                     PART_NAME: Create Automation Samples
                     DISPLAY_TRACE: YES
                     TRACE_NAME: PartID
                     TRACE_VALUE: 10000
                     UID: 8658067921673945405
                     DIM_RPT_TOLERANCECOLOR1: -1
                     DIM_RPT_TOLERANCECOLOR2: -1
                     RACE_DISPLAY_MESSAGE: Part ID
                     TRACE_DATA_SOURCE: 0
                     TRACE_DISPLAY_ONREPORT: NO​​
    


    The TypeIndex is one of the parameters for the GetText Method. TypeIndex is Long value used to indicate which instance of the supplied field type to use when an object has more than one instance of a field type. Reference from the



    PCDLRN ActiveX DLL > Command Object : GetText Method

    Visual Basic
    
    Public Function GetText( _
       ByVal DataType As ENUM_FIELD_TYPES, _
       ByVal TypeIndex As Long _
    ) As String​​
    


    Here is the link to the PC-DMIS 2023.1 Object Library
    Link: https://docs.hexagonmi.com/pcdmis/2023.1/en/helpcenter/mergedProjects/automationobjects/webframe.html#PCDLRN~Command~GetText.html
  • Using .NET 7.0 (Standard Term Support) for this example.
  • So for this one command I get 8 values. THEO_X Index 0 and index 7 are the same.

    PLN_C=FEAT/CONTACT/PLANE/DEFAULT,CARTESIAN,NONE,LEAST_SQR
    THEO/<29.527,15.037,-5.872>,<0,1,0>
    ACTL/<29.527,15.06,-5.872>,<-0.0000387,0.9999999,0.000533>
    TARG/<29.527,15.037,-5.872>,<0,1,0>
    ANGLE VEC=<-1,0,0>,SQUARE
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    NUMHITS=3,NUMROWS=2
    SPACER=0
    AVOIDANCE MOVE=NO,DISTANCE=10
    SHOW HITS=NO
    MOVE/POINT,NORMAL,<16.625,20.872,-13.369>

    Command #: 123 Type: CONTACT_PLANE_FEATURE
    index: 0
    ID: PLN_C
    index: 0
    THEO_X: 29.527
    index: 1
    THEO_X: 40.631
    index: 2
    THEO_X: 38.121
    index: 3
    THEO_X: 24.783
    index: 4
    THEO_X: 25.075
    index: 5
    THEO_X: 6.605
    index: 6
    THEO_X: 6.541
    index: 7
    THEO_X: 29.527
  • I did another test using your code method with a routine using the Plane Auto Feature. The indexs are for the HIT nominals.

    PC-DMIS Feature:
    
    PLN1 =FEAT/CONTACT/PLANE/DEFAULT,CARTESIAN,NONE,LEAST_SQR
    THEO/<0.866,0.225,-0.5>,<-0.8660191,0,0.500011>
    ACTL/<0.866,0.225,-0.5>,<-0.8660191,0,0.500011>
    TARG/<0.866,0.225,-0.5>,<-0.8660191,0,0.500011>
    ANGLE VEC=<1,0,0>,SQUARE
    SHOW FEATURE PARAMETERS=YES
    VOID DETECTION=NO
    SURFACE=THICKNESS_NONE,0
    MEASURE MODE=NOMINALS
    RMEAS=NONE,NONE,NONE
    AUTO WRIST=NO
    GRAPHICAL ANALYSIS=NO
    FEATURE LOCATOR=NO,NO,""
    SHOW CONTACT PARAMETERS=YES
    NUMHITS=3,NUMROWS=2
    SPACER=0
    AVOIDANCE MOVE=BOTH,DISTANCE BEFORE=0,DISTANCE AFTER=0.3937,DIRECTION=ALONG FEATURE VECTOR
    SHOW HITS=YES
    HIT/BASIC,<0.8463,0.2053,-0.5341>,<-0.8660191,0,0.500011>,<0.8463,0.2053,-0.5341>
    HIT/BASIC,<0.866,0.2053,-0.5>,<-0.8660191,0,0.500011>,<0.866,0.2053,-0.5>
    HIT/BASIC,<0.8857,0.2053,-0.4659>,<-0.8660191,0,0.500011>,<0.8857,0.2053,-0.4659>
    HIT/BASIC,<0.8857,0.2447,-0.4659>,<-0.8660191,0,0.500011>,<0.8857,0.2447,-0.4659>
    HIT/BASIC,<0.866,0.2447,-0.5>,<-0.8660191,0,0.500011>,<0.866,0.2447,-0.5>
    HIT/BASIC,<0.8463,0.2447,-0.5341>,<-0.8660191,0,0.500011>,<0.8463,0.2447,-0.5341>
    ENDMEAS/​
    
    
    C# Results:
    
    Command #: 9 Type: 617
    ID: PLN1
    THEO_X: 0.866 // X nominal
    index: 1
    THEO_X: 0.8463 // HIT1 nominal
    index: 2
    THEO_X: 0.866 // HIT2 nominal
    index: 3
    THEO_X: 0.8857 // HIT3 nominal
    THEO_Y: 0.225 // Y nominal
    index: 1
    THEO_Y: 0.2053
    THEO_Z: -0.5
    index: 1
    THEO_Z: -0.5341
    index: 2
    THEO_Z: -0.5
    index: 3
    THEO_Z: -0.4659
    THEO_I: -0.8660191
    THEO_J: 0
    THEO_K: 0.500011
    TARG_X: 0.866
    TARG_Y: 0.225
    TARG_Z: -0.5
    MEAS_X: 0.866
    index: 1
    MEAS_X: 0.8463
    index: 2
    MEAS_X: 0.866
    index: 3
    MEAS_X: 0.8857
    MEAS_Y: 0.225
    index: 1
    MEAS_Y: 0.2053
    MEAS_Z: -0.5
    index: 1
    MEAS_Z: -0.5341
    index: 2
    MEAS_Z: -0.5
    index: 3
    MEAS_Z: -0.4659
    MEAS_I: -0.8660191
    MEAS_J: 0
    MEAS_K: 0.500011
    TARG_I: -0.8660191
    TARG_J: 0
    TARG_K: 0.500011
    COORD_TYPE: CARTESIAN
    THICKNESS_TYPE: THICKNESS_NONE
    MOVE_TYPE: BOTH
    READPOS_TYPE: NO
    FINDHOLE_TYPE: DISABLED
    BF_MATH_TYPE: LEAST_SQR
    N_HITS: 3
    N_ROWS: 2
    F_SPACER: 0
    F_PITCH: 0
    F_THICKNESS: 0
    F_DEPTH: 0
    F_AUTOMOVE: 0
    ANGVEC_I: 1
    ANGVEC_J: 0
    ANGVEC_K: 0
    REPORTVEC_I: -0.8660191
    REPORTVEC_J: 0
    REPORTVEC_K: 0.500011
    SHOW_DETAILS: NO
    GRAPH_ANALYSIS: NO
    DISPLAY_TYPE: NONE
    PART_NAME: Test PrintProcess script
    FIND_NOMS_TYPE: NOMINALS
    DISPLAY_HITS: YES
    LOCATOR_BMP: NO
    LOCATOR_WAV: NO
    AUTO_ONERROR_TYPE: NO
    MINOR_WORD_TOGGLE: PLANE
    DISPLAY_ADVANCED_PARAMETERS: YES
    VOID_DETECT: NO
    PATTERN_TYPE: SQUARE
    RMEASFEATIDX: <Current Alignment>
    RMEASFEATIDY: <Current Alignment>
    RMEASFEATIDZ: <Current Alignment>
    AUTO_PH9: NO
    F_THICKNESS_EDGE: 0
    DISPLAY_PROBE_PARAMETERS: YES
    F_ENDING_DEPTH: 0
    F_ENDING_DEPTH: 0
    UID: 869
    NO_APPROACH_VECTOR_FLIP: NO
    
    
    
    ***GetText Failed*** Enum: SINGLE_POINT_DEVIATION
    
    
    
    DIM_RPT_TOLERANCECOLOR1: -1
    DIM_RPT_TOLERANCECOLOR2: -1
    MEASUREMENT_STRATEGY: DEFAULT
    MEASUREMENT_STRATEGY: DEFAULT
    SAMPLE_METHOD: SAMPLE_HITS
    BOUNDARY_OFFSET: 0.0394
    USE_BOUNDARY_OFFSET: NO
    N_POINTS: 6​​
    

  • plane:
    Index0; THEO_X from center of gravity of the plane
    Index1; THEO_X from of Plane.Hit[1]
    Index2; THEO_X from of Plane.Hit[2]
    Index3; THEO_X from of Plane.Hit[3]
    Index4; THEO_X from of Plane.Hit[4]
    Index5; THEO_X from of Plane.Hit[5]
    Index6; THEO_X from of Plane.Hit[6]
    Index7; out of bounds -> Result is from Index 0

    the people at pcDMIS set it up that way on purpose
  • Ahhh! That makes a lot of sense now. This is wonderful! Thank you so much.
  • No problem. Thank you for posting the C# method. This really speeds up the testing process.