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.
  • Thanks

    Can anyone help me out with the script? I guess I cannot write the red highlighted part as I get a syntax error.

    Sub Main

    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    Dim tX, tY, tZ, tRound, mX, mY, mZ, tD, mD, mRoundMax, mRoundMin, mRound, featName As String
    Dim FMcd As Object
    Dim cmd As Object

    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

    mRoundMax = featName.HIT[1..featName.NumHits].XYZ
    mRoundMax = MAX(SQRT(DOT(featName.HIT[1..featName.NumHits].XYZ - featName.XYZ, featName.HIT[1..featName.NumHits].XYZ - featName.XYZ)))
    mRoundMin = MIN(SQRT(DOT(featName.HIT[1..featName.NumHits].XYZ-featName.XYZ,featName.HIT[1..featName.NumHits].XYZ-featName.XYZ)))
    mRound = mRoundMax - mRoundMin


    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​


  • {"data-align":"none","data-size":"full","title":"2022-12-27_15-56-27.jpg","data-attachmentid":524828}


    See the underscores after "HIT"? Check that those aren't there in your code.
  • they aren't there in my code. I believe it doesn't recognize the .HIT function? I wrote featName.HIT[1..featName].XYZ

    However I see in the error that it gives me underscores..
  • would a "space" input the underscore?
  • There are no spaces whatsoever.


    Attached Files
  • Ah, PC-DMIS syntax in a basic script, that might not work...
  • Thank you all for your help. If anyone has an idea how to get this calculation in the script, please let me know Slight smile
  • Oke found a possible new way. I insert the roundness in the script. Looks like this.

    Set DmisCommand = DmisCommands.Add(ISO_TOLERANCE_COMMAND, True)
        DmisCommand.Marked = True
      ' Set Id  = FCFCIRTY1
        retval = DmisCommand.PutText ("FCFCIRTY"&iCnt, ID, 0)
      ' Set Standard  = ISO 1101
        retval = DmisCommand.PutText ("ISO 1101", STANDARD, 0)
      ' Set Feature Math Type  = DEFAULT
        retval = DmisCommand.SetToggleStringEx (1, BF_MATH_TYPE, 0, "FEATMATHTYPE")
      ' Set Tol Zone Math Type Item 1 = DEFAULT
        retval = DmisCommand.SetToggleStringEx (1, BF_MATH_TYPE, 1, "TOLZONEMATHTYPE")
      ' Set Output Type  = BOTH
        retval = DmisCommand.SetToggleString (3, OUTPUT_TYPE, 0)
      ' Set Arrow Density  = 100
        retval = DmisCommand.PutText ("100", ARROW_DENSITY, 0)
      ' Set SHOWEXPANDED  = YES
        retval = DmisCommand.PutText ("YES", SHOW_OPTIONS, 0)
      ' Set Unit Type  = MM
        retval = DmisCommand.SetToggleString (2, UNIT_TYPE, 0)
      ' Set SHOWEXPANDED  = NO
        retval = DmisCommand.SetToggleStringEx (1, SHOW_OPTIONS, 0, "SIZE")
      ' Set SHOWEXPANDED  = NO
        retval = DmisCommand.SetToggleStringEx (1, SHOW_OPTIONS, 0, "DATUMSIZE")
      ' Set Add Segment Item 1 = CIRCULARITY
        retval = DmisCommand.SetToggleString (2, SEGMENT_TYPE_TOGGLE, 1)
      ' Set DISPLAY_COORDS  = CURRENT_ALIGNMENT
        retval = DmisCommand.SetToggleString (2, DISPLAY_TYPE, 0)
      ' Set ToleranceSpecificationMode  = NOMINAL_WITH_DEVIATIONS
        retval = DmisCommand.SetToggleStringEx (1, MODE_TYPE, 0, "SIZE")
      ' Set Reference Id Item 1 = CIR1
        retval = DmisCommand.PutText ("CIR" & iCnt, REF_ID, 1)
      ' Set Tolerance Type Item 1 = 1
        retval = DmisCommand.SetToggleString (2, SEGMENT_TYPE, 1)
      ' Set Tolerance Item 1 = 0.01
        retval = DmisCommand.PutText ("0.01", FORM_TOLERANCE, 1)
      ' Set TEXT Item 1 = OFF
        retval = DmisCommand.SetToggleString (1, TEXT_ANALYSIS, 1)
      ' Set CADGRAPH Item 1 = OFF
        retval = DmisCommand.SetToggleString (1, CAD_GRAPH_ANALYSIS, 1)
      ' Set REPORTGRAPH Item 1 = OFF
        retval = DmisCommand.SetToggleString (1, REPORT_GRAPH_ANALYSIS, 1)
      ' Set MULT Item 1 = 10
        retval = DmisCommand.PutText ("10", ARROW_MULTIPLIER, 1)
      ' Set Per Unit/Composite Item 1 = 0
        retval = DmisCommand.PutText ("0", COMPOSITE, 1)
      ' Set Unequally Disposed/Dynamic Profile Item 1 = 0
        retval = DmisCommand.PutText ("0", UNEQUAL_TOL_LINE2, 1)
      ' Set Unequal Tolerance Zone Item 1 = 0
        retval = DmisCommand.PutText ("0", UNEQUAL_TOL_ZONE_LINE2, 1)
      ' Set Per Unit Shape Item 1 = <UA>
        retval = DmisCommand.PutText ("<UA>", PERUNIT_AREA_FORM_LINE3, 1)
      ' Set Per Unit Length Item 1 = 0
        retval = DmisCommand.PutText ("0", PERUNIT_LENGTH , 1)
      ' Set Per Unit Width Item 1 = 0
        retval = DmisCommand.PutText ("0", PERUNIT_WIDTH , 1)
      ' Set Tolerance Zone Type Item 1 = PLANAR
        retval = DmisCommand.SetToggleStringEx (1, FCF_TOL_ZONE_TYPE, 1, "SEG=1")
      ' Set Angle Vector I Item 1 = 0
        retval = DmisCommand.PutTextEx ("0", ANGVEC_I, 1, "SEG=1")
      ' Set Angle Vector J Item 1 = 0
        retval = DmisCommand.PutTextEx ("0", ANGVEC_J, 1, "SEG=1")
      ' Set Angle Vector K Item 1 = 0
        retval = DmisCommand.PutTextEx ("0", ANGVEC_K, 1, "SEG=1")
      ' Set <MC> Item 1 = __
        retval = DmisCommand.SetToggleStringEx (1, TP_MODIFIER, 1, "SEG=1")
      ' Set <T> Item 1 = __
        retval = DmisCommand.SetToggleStringEx (1, TP_MODIFIER2, 1, "SEG=1")
      ' Set <PZ> Item 1 = 0
        retval = DmisCommand.PutTextEx ("0", USE_AXIS, 1, "SEG=1")
      ' Set <len> Item 1 = 0
        retval = DmisCommand.PutTextEx ("0", DIM_LENGTH, 1, "SEG=1")
      ' Set WORKPLANE Item 1 = ZPLUS
        retval = DmisCommand.SetToggleStringEx (1, WORK_PLANE, 1, "SEG=1")
      ' Set NOMINAL (SIZE)  = 4
        retval = DmisCommand.PutTextEx ("4", SIZE_NOMINAL, 0, "SIZE")
      ' Set NOMINAL (SIZE)  = 0.01
        retval = DmisCommand.PutTextEx ("0.01", UPPER_TOLERANCE, 0, "SIZE")
      ' Set LOWER TOLERANCE (SIZE)  = 0.01
        retval = DmisCommand.PutTextEx ("0.01", LOWER_TOLERANCE, 0, "SIZE")
      ' Set UPPER SIZE Item 1 = 4
        retval = DmisCommand.PutText ("4", UPPER_SIZE, 1)
      ' Set LOWER SIZE Item 1 = 4
        retval = DmisCommand.PutText ("4", LOWER_SIZE, 1)
      ' Set REPORT_SIZE Item 1 = 1
        retval = DmisCommand.PutText ("1", USE_SIZE, 1)
      ' Set Feature Item 1 = 0
        retval = DmisCommand.PutTextEx ("0", DIM_DEVIATION, 1, "SEG=1")
    ​


    Then, I would like to know the deviation.

    Can someone help how to get the roundness from this? I tried something like
    DmisCommand.GetText(DEVIATION_SEGMENT, 1), but that doesn't work.

    Also, is it possible not to insert the roundness command in the routine? Otherwise it'll take too much time if you run this 30,000 times.. Slight smile