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.
  • It looks like you would need to Dimension the auto-circle and then use a variable to collect the information from the Dimension. You could generate 1 do loop to report your holes and build an array of your roundness values to prevent adding 30,000 dimensions directly into the program.
  • hi,

    you can try it out and see if it works.
    Unfortunately, I didn't have any measurement data to hand,
    so I don't know exactly if this works, but looks good so far.

    basically it's like @ ​ said
    Note that with this variant, the names of the circles should be countable​ like this: NAME_1 NAME_2 NAME_n​
    however the "name"-part can be changed, (only make sure you can count it up)

                ASSIGN/VCOUNT_MAX=4
                ASSIGN/VCOUNT_ACTUAL=0
                ASSIGN/VROUNDNESS=0
    
                WHILE/VCOUNT_ACTUAL < VCOUNT_MAX
    
                  ASSIGN/VCOUNT_ACTUAL=VCOUNT_ACTUAL+1
                  ASSIGN/VNAME="NAME_"+STR(VCOUNT_ACTUAL)
    
    RND          =GEOMETRIC_TOLERANCE/STANDARD=ISO 1101,SHOWEXPANDED=YES,
                  FEATURE_MATH=DEFAULT,
                  UNITS=MM,OUTPUT=BOTH,ARROWDENSITY=100,
                  SEGMENT_1,CIRCULARITY,0.01,TOL_ZONE_MATH=DEFAULT,
                  TEXT=OFF,CADGRAPH=OFF,REPORTGRAPH=OFF,MULT=10,
                    MEASURED:
                      NAME_4:0.000,
                  FEATURES/VNAME,,
    
      $$ YES,
                  VNAME
      $$ YES,
                  RND.SEGMENT[1].FEATURE[1].MEAS
    
                  ASSIGN/VROUNDNESS[VCOUNT_ACTUAL]=RND.SEGMENT[1].FEATURE[1].MEAS
    
                END_WHILE/​
    
  • hi,

    you can try it out and see if it works.
    Unfortunately, I didn't have any measurement data to hand,
    so I don't know exactly if this works, but looks good so far.

    basically it's like @ ​ said
    Note that with this variant, the names of the circles should be countable​ like this: NAME_1 NAME_2 NAME_n​
    however the "name"-part can be changed, (only make sure you can count it up)

    ASSIGN/VCOUNT_MAX=4
    ASSIGN/VCOUNT_ACTUAL=0
    ASSIGN/VROUNDNESS=0
    
    WHILE/VCOUNT_ACTUAL < VCOUNT_MAX
    
    ASSIGN/VCOUNT_ACTUAL=VCOUNT_ACTUAL+1
    ASSIGN/VNAME="NAME_"+STR(VCOUNT_ACTUAL)
    
    RND =GEOMETRIC_TOLERANCE/STANDARD=ISO 1101,SHOWEXPANDED=YES,
    FEATURE_MATH=DEFAULT,
    UNITS=MM,OUTPUT=BOTH,ARROWDENSITY=100,
    SEGMENT_1,CIRCULARITY,0.01,TOL_ZONE_MATH=DEFAULT,
    TEXT=OFF,CADGRAPH=OFF,REPORTGRAPH=OFF,MULT=10,
    MEASURED:
    NAME_4:0.000,
    FEATURES/VNAME,,
    
    $$ YES,
    VNAME
    $$ YES,
    RND.SEGMENT[1].FEATURE[1].MEAS
    
    ASSIGN/VROUNDNESS[VCOUNT_ACTUAL]=RND.SEGMENT[1].FEATURE[1].MEAS
    
    END_WHILE/​
    


    nice workSunglassesAlien
  • The loop doesn't spit the data out into csv.
    (FYI: this format is designed to work within Mitutoyo Measurlink importing syntax)

    add something like this before the while loop.
    -any of the +PART or +ROUTINE point to assigns that are either embedded into the routine code at the beginning, or are the result of an Input Comment... so alter at will.

    ASSIGN/C_PATH="C:\PRODUCTION\CUSTOMERNAME\PART\REPORTOUTPUT.CSV"
    ASSIGN/CHAR_1="Roundness for Circle # "
    C_FILE =FILE/OPEN,C_PATH,APPEND
    FILE/WRITELINE,C_FILE,"/PART NUMBER/" + "," + PART
    FILE/WRITELINE,C_FILE,"/ROUTINE NAME/" + "," + ROUTINE
    FILE/WRITELINE,C_FILE,"/LOT#/" + "," + RUN_ID
    FILE/WRITELINE,C_FILE,"/OPERATOR/" + "," + TRACE_FOLDER + "," + "Operator" + "," + OPERATOR
    FILE/WRITELINE,C_FILE,"/SCHEDULED TIME/" + "," + TRACE_FOLDER + "," + "Scheduled Time" + "," + TIME​

    then, within the loop:
    FILE/WRITELINE,C_FILE,"/DATA/" + "," + CHAR_1 + VCOUNT_ACTUAL + "," + RND.SEGMENT[1].FEATURE[1].MEAS

    outside of while loop, at end of routine:
    FILE/WRITELINE,C_FILE,"/END/"
    FILE/CLOSE,C_FILE,KEEP​​
  • you can parametrically and uniquely name each file within that ASSIGN/C_PATH line by adding a reference to an Input Comment/serial number or syntax for a unique timestamp if no part serialization, within the .csv file name.
  • If you measure the circle as a SEPMIN circle, the roundness is the difference between max and min radius, so you can export the dimension without creating it !!!!!!
    ASSIGN/V1=SQRT(DOT(CIR1.HIT[1..CIR1.NUMHITS].XYZ-CIR1.XYZ,CIR1.HIT[1..CIR1.NUMHITS].XYZ-CIR1.XYZ))
    ASSIGN/ROUNDNESS=MAX(V1)-MIN(V1)
  • Does that only work with a SEPMIN cir? It wouldn't work with Least_Sq?
  • : With LS, the formula would work, but wouldn't give the right roundness, it would give the result of "form" in the dimension window (the icon with a cross into a square).
    The main result to use sep_min is to use the right algo to calculate the roundness.
  • Hi all,

    Thanks for the help and support.

    I have the following script. Do you know how to change the mRound variable in the code to loop the CIR1 each time with one index?

    Sub Main
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    Dim tX, tY, tZ, tRound, mX, mY, mZ, tD, mD, mRound As String
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Dim iCnt As Integer
    
    Dim savePath
    Dim repFolder
    Dim repName
    
    repName = format(now(),"YYYYMMDDHHNNSS")
    savePath = "D:\PC-DMIS Data\Scripts\TEMP\"
    repFolder = left(PCDPartProgram.Name,len(PCDPartProgram.Name)-4)
    
    Open savePath & repFolder & repName & ".TXT" For Append As #1
    For iCnt = 1 To PCDCommands.Count
    Set PCDCommand = PCDCommands.Item(iCnt)
    
    If Left(PCDCommand.ID, 3) = "CIR" Then
    
      tX = PCDCommand.GetText(THEO_X, 0)
      tY = PCDCommand.GetText(THEO_Y, 0)
      tZ = PCDCommand.GetText(THEO_Z, 0)
      tD = PCDCommand.GetText(THEO_DIAM, 0)
      tRound = 0
    
      
      mX = PCDCommand.GetText(MEAS_X, 0)
      mY = PCDCommand.GetText(MEAS_Y, 0)
      mZ = PCDCommand.GetText(MEAS_Z, 0)
      mD = PCDCommand.GetText(MEAS_DIAM, 0)
      mRound = max(SQRT(DOT(CIR1.HIT[1..CIR1.NUMHITS].XYZ-CIR1.XYZ,CIR1.HIT[1..CIR1.NUMHITS].XYZ-CIR1.XYZ))) - MIN(SQRT(DOT(CIR1.HIT[1..CIR1.NUMHITS].XYZ-CIR1.XYZ,CIR1.HIT[1..CIR1.NUMHITS].XYZ-CIR1.XYZ)))
        
      Write #1, PCDCommand.ID & ", " & tX & ", " & tY & ", " & tZ & ", " & tD & ", " & tRound & ", " & mX & ", " & mY & ", " & mZ & ", " & mD & ", " & mRound 
    
    End If
    
    Next iCnt
    
    Close #1
    Set PCDCommands = Nothing
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub​


  • Sub Main
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    Dim tX, tY, tZ, tRound, mX, mY, mZ, tD, mD, mRound As String

    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands

    Dim iCnt As Integer

    Dim savePath
    Dim repFolder
    Dim repName

    repName = format(now(),"YYYYMMDDHHNNSS")
    savePath = "D:\PC-DMIS Data\Scripts\TEMP"
    repFolder = left(PCDPartProgram.Name,len(PCDPartProgram.Name)-4)

    Open savePath & repFolder & repName & ".TXT" For Append As Home
    For iCnt = 1 To PCDCommands.Count
    Set PCDCommand = PCDCommands.Item(iCnt)

    If Left(PCDCommand.ID, 3) = "CIR" Then

    tX = PCDCommand.GetText(THEO_X, 0)
    tY = PCDCommand.GetText(THEO_Y, 0)
    tZ = PCDCommand.GetText(THEO_Z, 0)
    tD = PCDCommand.GetText(THEO_DIAM, 0)
    tRound = 0


    mX = PCDCommand.GetText(MEAS_X, 0)
    mY = PCDCommand.GetText(MEAS_Y, 0)
    mZ = PCDCommand.GetText(MEAS_Z, 0)
    mD = PCDCommand.GetText(MEAS_DIAM, 0)

    featName = PCDCommand.ID

    mRound = max(SQRT(DOT(featName.HIT[1..featName.NUMHITS].XYZ-featName.XYZ,featName.HIT[1..featName.NUMHITS].XYZ-featName.XYZ))) - MIN(SQRT(DOT(featName.HIT[1..featName.NUMHITS].XYZ-featName.XYZ,featName.HIT[1..featName.NUMHITS].XYZ-featName.XYZ)))


    Write #1, PCDCommand.ID & ", " & tX & ", " & tY & ", " & tZ & ", " & tD & ", " & tRound & ", " & mX & ", " & mY & ", " & mZ & ", " & mD & ", " & mRound

    End If

    Next iCnt

    Close Home
    Set PCDCommands = Nothing
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub​

    Try my edits in red above. This should use the actuals for all "CIR" in your program and not just calculate CIR1 every time...