hexagon logo

Switching all dimensions from MM to INCH (or the other way around)

This is a little script that can be used to change all legacy dimensions (not XactMeasure) in a program from MM to INCH, or vice versa.

If anyone finds out how to make it work for XactMeasure too, I'd be grateful Slight smile

Save as mm2inch.bas and connect to a toolbar button (in a toolbar of your own).
Sub main()
TestIt
End Sub
'=================================

Sub TestIt()
Dim DmisApp As Object
Dim DmisPart As Object
Dim DmisCommands As Object
Dim DmisCommand As Object
Dim cmd As Object

Set DmisApp = CreateObject("PCDLRN.Application")
Set DmisPart = DmisApp.ActivePartProgram
Set DmisCommands = DmisPart.Commands

Begin Dialog dlgCHOOSE 31,32, 100, 96, "Change all Dimensions MM/INCH"
  OKButton 28,68,40,14
  GroupBox 12,8,72,52,"Choose unit",.GroupBox1
  OptionGroup .OptGroup1
  OptionButton 16, 24, 54, 8, "INCH", .OptINCH
  OptionButton 16, 40, 54, 8, "MM", .OptMM
End Dialog
Dim Dlg2 As dlgCHOOSE
Button = Dialog(Dlg2)

If Button = -1 Then
  ProbeCount = 0
  For Each DmisCommand In DmisCommands
    If DmisCommand.isDimension Then
      Set cmd = DmisCommand.DimensionCommand
      cmd.Units = Dlg2.OptGroup1 ' INCH=0, MM=1
    End If
  Next DmisCommand
End If

Set DmisApp = Nothing
Set DmisPart = Nothing
Set DmisCommands = Nothing
Set DmisCommand = Nothing
End Sub 
Parents
  • I tested the following, and it seems to work on every FCF (note swedish word for inch!):

        If DmisCommand.IsFCFCommand Then
          If Dlg2.OptGroup1 = 0 Then
            bRet = DmisCommand.PutText("TUM", UNIT_TYPE, 1)  ' Swedish For INCH
          Else
            bRet = DmisCommand.PutText("MM", UNIT_TYPE, 1) 
          End If
        End If
    


    NOTE: PC-DMIS 2015 itself (not this script) has a bug in connection with "per unit" and displaying with a unit different from what the program is made in - the numbers in the "per unit" specification are altered each time the part program is run, and soon reaches the value 0 (zero). (PCD-30282)

    So don't run this in 2015.0 on a program with "per unit" dimensions!
Reply
  • I tested the following, and it seems to work on every FCF (note swedish word for inch!):

        If DmisCommand.IsFCFCommand Then
          If Dlg2.OptGroup1 = 0 Then
            bRet = DmisCommand.PutText("TUM", UNIT_TYPE, 1)  ' Swedish For INCH
          Else
            bRet = DmisCommand.PutText("MM", UNIT_TYPE, 1) 
          End If
        End If
    


    NOTE: PC-DMIS 2015 itself (not this script) has a bug in connection with "per unit" and displaying with a unit different from what the program is made in - the numbers in the "per unit" specification are altered each time the part program is run, and soon reaches the value 0 (zero). (PCD-30282)

    So don't run this in 2015.0 on a program with "per unit" dimensions!
Children
No Data