hexagon logo

Have the roundness of an auto-circle in a variable

Hi there,

I am trying to have the roundness of an auto-element in a variable. I cannot use a dimension as I have 30,000 circles and try to export all of these roudnesses via a script to a txt file.

Does anyone knows how to call the roundness of an auto-circle into a variable?

Thanks in advance.
  • Found a way to get the value into a variable: CDbl(DmisCommand.GetTextEx(DIM_DEVIATION, 1, "SEG=1")).

    Still need to change that the script is not inserting the roundness dimension into the measurement routine...
  • Hello,

    it's not that easy. You can insert the roundness evaluation with a script, but I'm not sure if it then calculates this command correctly (within the runtime of the script).


    Excuse the question: but is it possible for you to evaluate the roundness with a pcDMIS loop and write the result straight into a CSV file? (i mean without the script altogether)​
    you just have to slightly adapt the above example from me


    anyway:
    this is how you can extract the measuring points from a "CONTACT_CIRCLE_FEATURE":
    (this does not work with "MEASURED_CIRCLE")

    MEAS_X, 0 -> center of the circle
    MEAS_X, 1 -> center of point 1
    MEAS_X, 2 -> center of point 2 (and so on)
    
    mX1 = PCDCommand.GetText(MEAS_X, 1)
    mY1 = PCDCommand.GetText(MEAS_Y, 1)
    mZ1 = PCDCommand.GetText(MEAS_Z, 1)​
    
    mX2 = PCDCommand.GetText(MEAS_X, 2)
    mY2 = PCDCommand.GetText(MEAS_Y, 2)
    mZ2 = PCDCommand.GetText(MEAS_Z, 2)​​
    


    With this points you can then calculate the roundness, the formula for this has already been posted by @ ​.
    (I do not know which exact calculation method pcDMIS uses, therefore the results could differ to pcDMIS)
  • Hi , thanks for the help! I've tried your suggestion with the DO/WHILE function within PC-DMIS, however, this will take a lot of time as PC-DMIS will need at least 1,5 hours to run 30,000 elements. Also, it will possibly freeze after a certain number as it gets slower in the loop.

    I'll try your suggestion. Do you know how to use the DOT function with BASIC script? If I place DOT, then the BASIC script will not recognize it.
  • Hello,

    I haven't tested it, forgive me if there's a typo somewhere​
    (works only with "CONTACT_CIRCLE_FEATURE")

    
    [...]
    
    ' Dim Something
    Dim iPointCount As Integer
    Dim iCount As Integer
    Dim dVectorX, dVectorY, dVectorZ As Double
    Dim dRadius As Double
    Dim dMax, dMin, dRound As Double
    
    ' Center from Cirle
    CirCenterX = PCDCommand.GetText(MEAS_X, 0)
    CirCenterY = PCDCommand.GetText(MEAS_Y, 0)
    CirCenterZ = PCDCommand.GetText(MEAS_Z, 0)
    
    iPointCount = PCDCommand.GetText(N_HITS, 0)
    ' each Point
    For iCount = 1 To iPointCount
    ' Vector "CIR1.HIT[1..CIR1.NUMHITS].XYZ-CIR1.XYZ"
    dVectorX = PCDCommand.GetText(MEAS_X, iCount) - CirCenterX
    dVectorY = PCDCommand.GetText(MEAS_Y, iCount) - CirCenterY
    dVectorZ = PCDCommand.GetText(MEAS_Z, iCount) - CirCenterZ
    
    ' Radius from each point "SQRT(DOT())"
    dRadius = Sqr((dVectorX * dVectorX) + (dVectorY * dVectorY) + (dVectorZ * dVectorZ))
    
    ' remember max min "MAX(V1)"
    If iCount = 1 Then
    dMax = dRadius
    dMin = dRadius
    End If
    
    If dMax < dRadius Then dMax = dRadius
    If dMin > dRadius Then dMin = dRadius
    Next iCount
    
    ' result "ROUNDNESS=MAX(V1)-MIN(V1)"
    dRound = dMax - dMin​
    
    [...]
    
    
  • I forgot
    Dim CirCenterX, CirCenterY, CirCenterZ As Double
  • Hi ,

    Thanks for the code. Real effort here! I tried it and needed to change the iPointCount to iPointCount = DmisCommand.FeatureCommand.NumHits

    However, I still don't get the roundness value. I've investigated it and saw that the underneath part of the code doesn't take the hits from the feature. I found out, like you said, that it works only for CONTACT_CIRCLE_FEATURE, but I'm using the Camera for the measurement. Do you know what to do in order to change for the camera?

    For iCount = 1 To iPointCount
    ' Vector "CIR1.HIT[1..CIR1.NUMHITS].XYZ-CIR1.XYZ"
    dVectorX = DmisCommand.GetText(MEAS_X, iCount) - CirCenterX
    dVectorY = DmisCommand.GetText(MEAS_Y, iCount) - CirCenterY
    dVectorZ = DmisCommand.GetText(MEAS_Z, iCount) - CirCenterZ
    
    MsgBox dVectorX & " " & dVectorY & " " & dVectorZ


    I checked with the Tactile probing, but the roundness was different bij 0.2 between PC-DMIS GeoTol calculation. ​
  • Differences were to be expected, pcDMIS uses a different calculation method.
    Still sounds like too much difference, Maybe I misinterpreted 's formula...?

    ...
    as long as it's a "CONTACT CIRCLE FEATURE" or "auto circle" it should work.
    for "mesured circles" it has to be written differently to get the points
    You can also use a "constructed circle", but it has to be written differently too, because the data objects are structured differently.​

    do you use a scanner?
    if so, can't you create a surface profile?​
  • Hi , I'm using a Zoom camera

    I found a different way perhaps. What do you think about this.

    In PC-DMIS I have the following.

    DIM LOC1= LOCATIE VAN CIRKEL CIR1  EENHEDEN=MM ,$
    GRAFIEK=UIT  TEKST=UIT  MULT=10.00  PIJLDICHTHEID=100  OUTPUT=BEIDE  HALVE HOEK=NEE
    AS        NOM       +TOL       -TOL       METG        AFW     BUITOL
    RN       0.000      0.050      0.000      0.009      0.009      0.000 -#-------
    EINDE VAN DIMENSIELOC1​


    Above you'll see that I have a Location Dimension called LOC1 and this calculates the roundness. Within the script I need to change the REF_ID and then extract the DIM_MEASURED. Put this in the loop, and it should give me the roundness values?!

    I tried doing with the following, but it didn't work.

    '' insert the REF_ID
    retval = LOC1.PutText ("iCnt", REF_ID, 0)
    '' Retrieve the value in the variable
    dRound = LOC1.GetText (DIM_MEASURED, 0)

    Do you know how I can have it to work?


  • Try this...

    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object
    Dim FCmd As Object
    
    Sub Main(OutputFileNameAndPath)
      Set DmisApp = CreateObject("PCDLRN.Application")
      Set DmisPart = DmisApp.ActivePartProgram
      Set DmisCommands = DmisPart.Commands
      CommandCount = DmisCommands.Count
      Set DmisCommand = DmisCommands.Item(CommandCount)
    
      Open OutputFileNameAndPath For Output As #1
    
      For Each DmisCommand In DmisCommands
        If DmisCommand.IsFeature Then
          If DmisCommand.Type = 612 Or DmisCommand =202 Then' (612 = auto circle, 202 = measured circle.  Using the numeric reference rather than text makes it language independent)
              Set FCmd = DmisCommand.FeatureCommand
                Print #1, DmisCommand.Id & chr(44) & FCmd.GetFormError()
          End If
        End If
      Next DmisCommand
    
      Close #1
    End Sub
    ​
    




    It reads the form error directly from the feature and writes it out to a file. Save as a .bas and then insert as a basic script command at the end of your routine. You need to specify the full path and file name for your output file as ARG1 like this...

    CS1        =SCRIPT/FILENAME= C:\USERS\PUBLIC\DOCUMENTS\SCRIPTS\GET_ROUNDNESS_FROM_FEATURE.BAS
                FUNCTION/Main,SHOW=YES,ARG1="C:\Users\Public\Documents\Scripts\Roundness_Output.txt",,
                STARTSCRIPT/
                ENDSCRIPT/​
    




    Note, this was for a routine using a touch trigger probe. I just noticed in a previous post that you said you were using vision so you will need to change the DmisCommand.Type. I believe 245 is a vision auto circle.
  • I didn't know that there were other data types for vision
    (VISION_CIRCLE_FEATURE = 245 according to the help file)