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
  • Tried this on a FCF Position and it seems to be working...
      [COLOR="#0000FF"]Dim bRet as Boolean[/COLOR]
      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
    [COLOR="#0000FF"]    If DmisCommand.IsFCFCommand Then
          bRet = DmisCommand.PutText("MM", UNIT_TYPE, 1)  ' "IN" for inch
        End If[/COLOR]
      Next DmisCommand
    End If

    ...haven't tried it on any other type of FCF though.
Reply
  • Tried this on a FCF Position and it seems to be working...
      [COLOR="#0000FF"]Dim bRet as Boolean[/COLOR]
      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
    [COLOR="#0000FF"]    If DmisCommand.IsFCFCommand Then
          bRet = DmisCommand.PutText("MM", UNIT_TYPE, 1)  ' "IN" for inch
        End If[/COLOR]
      Next DmisCommand
    End If

    ...haven't tried it on any other type of FCF though.
Children
No Data