hexagon logo

Help with OLE Automation

Now that I have information in a way that imports and exports the information correctly, I have been tasked with creating an OLE to automatically import the data into the SPC software. I have one that sort of works (as in opens the program, logs in, opens the right collection plan, etc) and I can get put in static information, but I am unsure how to call the information out of PC DMIS to have it be placed in the spots we need in the SPC software being used.

Has anyone else done this? Can anyone explain to me how find the variable and the measurement output in PC DMIS? I am using version 4.2 if that helps any.

Thanks so much.
  • OK, I thought I had a clue, but apparently not. So here is the code that works...and is not pulling in the dimensions since I can't seem to figure out how to do it, still.

    Begin VB.Form Form1
    caption = "Visual Basic OLE Client for WinSPC"
    ClientHeight = 4485
    ClientLeft = 60
    ClientTop = 630
    ClientWidth = 6150
    LinkTopic = "Form1"
    ScaleHeight = 4485
    ScaleWidth = 6150
    Begin VB.TextBox Text1
    Height = 4455
    Left = 0
    MultiLine = -1 'True
    ScrollBars = 2 'Vertical
    TabIndex = 0
    Top = 0
    Width = 6135
    End
    Begin VB.Menu RunMenu
    Caption = "&Run"
    End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredID = True
    Attribute VB_Expose = False

    'Declare variables
    sub Main
    Dim PartObj As Object
    Dim CPObj As Object
    Dim DCObj As Object
    Dim DBObj As Object
    Dim UserName As String
    Dim Password As String
    Dim sPart As String
    Dim sVar1 As String
    Dim sVar2 As String
    Dim sCollPlan As String
    Dim PartID As Long
    Dim Var1ID As Long
    Dim Var2ID As Long
    Dim CollPlanID As Long
    Dim Step1ID As Long
    Dim Step2ID As Long
    Dim CollectionPlanID As Object
    Dim dc As Object

    'Open WinSPC and Collection Plan
    Set dc = CreateObject("WinSPC.DataCollectionAuto")
    dc.Visible = True
    dc.RunHeadless = False
    While dc.ReadyForLogin = "F"
    Wend
    dc.UserName = "1675 CMM"
    dc.Password = "1675"

    dc.CollectionPlanID = 8544
    dc.TagIndex = 0
    dc.TagValue = "KKH"
    dc.CurrentStep = 0
    dc.Value = MyReading1
    dc.CurrentStep = 1
    dc.Value = 0.00011
    dc.CurrentStep = 2
    dc.Value = 3.643
    dc.CurrentStep = 3
    dc.Value = 1.565
    dc.CurrentStep = 4
    dc.Value = 1.345
    dc.CurrentStep = 5
    dc.Value = 7.89
    dc.CurrentStep = 6
    dc.Value = 3.726
    dc.CurrentStep = 7
    dc.Value = 0.00012
    dc.CurrentStep = 8
    dc.Value = .215
    dc.CurrentStep = 9
    dc.Value = .215
    dc.CurrentStep = 10
    dc.Value = .215
    dc.CurrentStep = 11
    dc.Value = .215
    dc.CurrentStep = 12
    dc.Value = .83
    dc.CurrentStep = 13
    dc.Value = 0.000015
    dc.CurrentStep = 14
    dc.Value = 0.000014
    dc.CurrentStep = 15
    dc.Value = .215

    dc.CollectionPlanID = 0
    dc.UserName = " "
    Set dc = Nothing
    End Sub

    And here is the code, that I thought I knew what to do with your hint in it.

    Begin VB.Form Form1
    caption = "Visual Basic OLE Client for WinSPC"
    ClientHeight = 4485
    ClientLeft = 60
    ClientTop = 630
    ClientWidth = 6150
    LinkTopic = "Form1"
    ScaleHeight = 4485
    ScaleWidth = 6150
    Begin VB.TextBox Text1
    Height = 4455
    Left = 0
    MultiLine = -1 'True
    ScrollBars = 2 'Vertical
    TabIndex = 0
    Top = 0
    Width = 6135
    End
    Begin VB.Menu RunMenu
    Caption = "&Run"
    End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredID = True
    Attribute VB_Expose = False

    'Declare variables
    sub Main
    Dim PartObj As Object
    Dim CPObj As Object
    Dim DCObj As Object
    Dim DBObj As Object
    Dim UserName As String
    Dim Password As String
    Dim sPart As String
    Dim sVar1 As String
    Dim sVar2 As String
    Dim sCollPlan As String
    Dim PartID As Long
    Dim Var1ID As Long
    Dim Var2ID As Long
    Dim CollPlanID As Long
    Dim Step1ID As Long
    Dim Step2ID As Long
    Dim CollectionPlanID As Object
    Dim dc As Object
    Dim ObjApp As Object
    Dim ObjPP As Object
    Dim ObjCmds As Object
    Dim ObjCmd As Object
    Dim ObjPart As Object
    Dim lngNumCmds As Long

    'Open PCDMIS and ready for output
    Set ObjApp = CreateObject ("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram
    Set ObjCmds = ObjPart.Commands
    Set lngNumCmds = ObjCmds.Count

    'Declare output variables
    Dim StrDimID As Object
    Dim StrDimFeature As String
    Dim StrDimType As Object
    Dim StrDimNominal As String
    Dim StrDimUTol As String
    Dim StrDimLTol As String
    Dim StrDimMeasure As String
    Dim i As Integer
    Dim MyReading1 as Double
    'build output
    For i = 1 To PCDCommands.Count
    Set StrDimID = PCDCommands(i)
    If StrDimID.IsDimension Then
    Set MyReading1 = StrDimID.StrDimMeasure

    'Open WinSPC and Collection Plan
    Set dc = CreateObject("WinSPC.DataCollectionAuto")
    dc.Visible = True
    dc.RunHeadless = False
    While dc.ReadyForLogin = "F"
    Wend
    dc.UserName = "1675 CMM"
    dc.Password = "1675"

    dc.CollectionPlanID = 8544
    dc.TagIndex = 0
    dc.TagValue = "KKH"
    dc.CurrentStep = 0
    dc.Value = MyDimensionCmd
    dc.CurrentStep = 1
    dc.Value = 0.00011
    dc.CurrentStep = 2
    dc.Value = 3.643
    dc.CurrentStep = 3
    dc.Value = 1.565
    dc.CurrentStep = 4
    dc.Value = 1.345
    dc.CurrentStep = 5
    dc.Value = 7.89
    dc.CurrentStep = 6
    dc.Value = 3.726
    dc.CurrentStep = 7
    dc.Value = 0.00012
    dc.CurrentStep = 8
    dc.Value = .215
    dc.CurrentStep = 9
    dc.Value = .215
    dc.CurrentStep = 10
    dc.Value = .215
    dc.CurrentStep = 11
    dc.Value = .215
    dc.CurrentStep = 12
    dc.Value = .83
    dc.CurrentStep = 13
    dc.Value = 0.000015
    dc.CurrentStep = 14
    dc.Value = 0.000014
    dc.CurrentStep = 15
    dc.Value = .215

    dc.CollectionPlanID = 0
    dc.UserName = " "
    Set dc = Nothing
    End Sub


    Please help me, because I am so lost and confused.
  • And just in case it helps, here is a portion of the file that I have to work with.

    DATE=6/4/2013 TIME=12:31:10 PM
    PART NAME : 566875-BAFFLE
    REV NUMBER :
    SER NUMBER :
    STATS COUNT : 37
    STARTUP =ALIGNMENT/START,RECALL:,LIST=YES
    ALIGNMENT/END
    MODE/DCC
    FORMAT/ ,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,TOL,MEAS,DEV,OUTTOL, ,
    LOADPROBE/PROBE6
    TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
    MOVESPEED/ 25
    TOUCHSPEED/ 0.75
    PREHIT/ 0.2
    RETRACT/ 0.2
    STATS/ON,DATAPAGE,$
    DIRECTORY=J:\1671\CMM DATA\1675 PCDMIS\DATAPAGE FOR PCDMIS,$
    DIRECTORY=,$
    READ=10,WRITE=20,MEMPAGES=64,DIMENSION NAME,CONTROLCALC OFF,$
    STATS/END
    C1 =COMMENT/INPUT,YES,'PLEASE ENTER MACHINIST CLOCK NUMBER'
    COMMENT/OPER,NO,DO NOT PUT BAFFLE ON FIXTURE UNTIL PROGRAM TELLS YOU!!!
    MOVE/POINT,NORMAL,<5.6878,15.8426,-7.8828>
    PLANE1 =FEAT/PLANE,CARTESIAN,TRIANGLE
    THEO/<6.9764,7.8351,-19.0982>,<0.0011614,0.0001585,0.9999993>
    ACTL/<6.9764,7.8351,-19.116>,<0.0011339,0.0001583,0.9999993>
    MEAS/PLANE,3
    HIT/BASIC,NORMAL,<5.2572,8.8095,-19.0964>,<0.0011614,0.0001585,0.9999993>,<5.2572,8.8096,-19.1142>,USE THEO = YES
    HIT/BASIC,NORMAL,<8.813,8.8488,-19.1005>,<0.0011614,0.0001585,0.9999993>,<8.8126,8.8485,-19.1182>,USE THEO = YES
    HIT/BASIC,NORMAL,<6.8592,5.847,-19.0978>,<0.0011614,0.0001585,0.9999993>,<6.8593,5.8472,-19.1155>,USE THEO = YES
    ENDMEAS/
    MOVE/POINT,NORMAL,<7.0299,6.3756,-18.9957>
    CIR1 =FEAT/CIRCLE,CARTESIAN,IN,LEAST_SQR
    THEO/<7.0294,7.8992,-19.3031>,<0,0,1>,3.5358
    ACTL/<7.0305,7.8686,-19.3028>,<0,0,1>,3.5335
    MEAS/CIRCLE,9,WORKPLANE
    HIT/BASIC,NORMAL,<6.7839,6.1532,-19.303>,<0.1440895,0.9895647,0>,<6.7799,6.1238,-19.3027>,USE THEO = YES
    HIT/BASIC,NORMAL,<7.0535,6.1327,-19.303>,<-0.0141001,0.9999006,0>,<7.0534,6.1028,-19.3027>,USE THEO = YES
    HIT/BASIC,NORMAL,<7.2578,6.1447,-19.3031>,<-0.1328797,0.9911322,0>,<7.2612,6.1145,-19.3028>,USE THEO = YES
    HIT/BASIC,NORMAL,<8.6647,8.4798,-19.3031>,<-0.9527832,-0.3036513,0>,<8.6909,8.4907,-19.3028>,USE THEO = YES
    HIT/BASIC,NORMAL,<8.5469,8.7962,-19.3031>,<-0.867853,-0.4968211,0>,<8.5363,8.7918,-19.3028>,USE THEO = YES
    HIT/BASIC,NORMAL,<8.3913,9.0175,-19.3031>,<-0.7749532,-0.6320186,0>,<8.3758,9.0059,-19.3028>,USE THEO = YES
    HIT/BASIC,NORMAL,<5.735,9.0623,-19.303>,<0.7610421,-0.6487025,0>,<5.735,9.065,-19.3028>,USE THEO = YES
    HIT/BASIC,NORMAL,<5.4337,8.6482,-19.303>,<0.8988226,-0.4383127,0>,<5.4435,8.643,-19.3028>,USE THEO = YES
    HIT/BASIC,NORMAL,<5.3063,8.3242,-19.303>,<0.9688725,-0.2475604,0>,<5.3166,8.3217,-19.3028>,USE THEO = YES
    ENDMEAS/
    PLANE2- BOTTOM OF BAFFLE=FEAT/PLANE,CARTESIAN,TRIANGLE
    THEO/<7.0037,7.868,-19.2547>,<0.0008384,0.0005591,0.9999995>
    ACTL/<7.0033,7.8586,-19.2724>,<0.0009688,0.0003399,0.9999995>
    MEAS/PLANE,3
    HIT/BASIC,NORMAL,<7.0051,6.1157,-19.2282>,<0.0008384,0.0005591,0.9999995>,<7.0047,6.1159,-19.2719>,USE THEO = YES
    HIT/BASIC,NORMAL,<8.5503,8.7784,-19.2565>,<0.0008384,0.0005591,0.9999995>,<8.5499,8.778,-19.2743>,USE THEO = YES
    HIT/BASIC,NORMAL,<5.4554,8.6818,-19.2538>,<0.0008384,0.0005591,0.9999995>,<5.4554,8.682,-19.2712>,USE THEO = YES
    ENDMEAS/
    MOVE/POINT,NORMAL,<5.7746,8.3003,-18.3843>
    MOVE/POINT,NORMAL,<4.9509,20.8308,-17.6851>
    L2D1 =FEAT/LINE,CARTESIAN,UNBOUNDED
    THEO/<4.9508,19.6258,-21.3031>,<1,-0.0000662,0>
    ACTL/<4.9507,19.5978,-21.3028>,<1,0.0002452,0>
    MEAS/LINE,2,WORKPLANE
    HIT/BASIC,NORMAL,<4.9508,19.6258,-21.3029>,<0.0000661,1,0>,<4.9507,19.5978,-21.3026>,USE THEO = YES
    HIT/BASIC,NORMAL,<12.4048,19.6253,-21.3032>,<0.0000661,1,0>,<12.4044,19.5996,-21.3029>,USE THEO = YES
    ENDMEAS/
    A1 =ALIGNMENT/START,RECALL:STARTUP,LIST=YES
    ALIGNMENT/LEVEL,ZPLUS,PLANE1
    ALIGNMENT/TRANS,ZAXIS,PLANE1
    ALIGNMENT/TRANS,XAXIS,CIR1
    ALIGNMENT/TRANS,YAXIS,CIR1
    ALIGNMENT/END
    MOVE/POINT,NORMAL,<5.6484,12.2572,1.577>
    COMMENT/OPER,NO,PLEASE PLACE BAFFLE ON FIXTURE AT THIS TIME
    ,VERIFY THAT THE BAFFLE IS RESTING AGAINST ALL 3 LOCATORS
    MOVE/POINT,NORMAL,<3.3206,0.383,2.2668>
    CIR2- OUTER CIRCLE ABOVE STEP=FEAT/CIRCLE,CARTESIAN,OUT,LEAST_SQR
    THEO/<0.0031,-0.0347,0.2653>,<0,0,1>,3.646,0
    ACTL/<0.0022,-0.0384,0.2651>,<0,0,1>,3.6435,0
    MEAS/CIRCLE,10,WORKPLANE
    HIT/BASIC,NORMAL,<1.8261,-0.0347,0.265>,<1,0,0>,<1.8243,-0.0347,0.265>,USE THEO = YES
    MOVE/CIRCULAR
    HIT/BASIC,NORMAL,<1.4779,1.0368,0.265>,<0.809017,0.5877852,0>,<1.4746,1.0343,0.265>,USE THEO = YES
    MOVE/CIRCULAR
    HIT/BASIC,NORMAL,<0.5664,1.699,0.265>,<0.309017,0.9510565,0>,<0.5649,1.6939,0.265>,USE THEO = YES
    MOVE/CIRCULAR
    HIT/BASIC,NORMAL,<-0.5603,1.699,0.265>,<-0.309017,0.9510565,0>,<-0.5591,1.6945,0.2651>,USE THEO = YES
    MOVE/CIRCULAR
    HIT/BASIC,NORMAL,<-1.4718,1.0368,0.265>,<-0.809017,0.5877853,0>,<-1.4703,1.0355,0.2651>,USE THEO = YES
    MOVE/CIRCULAR
    HIT/BASIC,NORMAL,<-1.8199,-0.0347,0.265>,<-1,0,0>,<-1.8195,-0.0348,0.2651>,USE THEO = YES
    MOVE/CIRCULAR
    HIT/BASIC,NORMAL,<-1.4718,-1.1063,0.265>,<-0.809017,-0.5877852,0>,<-1.4726,-1.1071,0.2651>,USE THEO = YES
    MOVE/CIRCULAR
    HIT/BASIC,NORMAL,<-0.5603,-1.7685,0.265>,<-0.309017,-0.9510565,0>,<-0.5613,-1.7709,0.2651>,USE THEO = YES
    MOVE/CIRCULAR
    HIT/BASIC,NORMAL,<0.5664,-1.7685,0.265>,<0.309017,-0.9510565,0>,<0.567,-1.7704,0.265>,USE THEO = YES
    MOVE/CIRCULAR
    HIT/BASIC,NORMAL,<1.4779,-1.1063,0.265>,<0.809017,-0.5877853,0>,<1.4777,-1.1065,0.265>,USE THEO = YES
    ENDMEAS/
    MOVE/POINT,NORMAL,<2.2735,-0.4024,0.3874>
    DIM CIRC2 DIA
    AX NOMINAL +TOL -TOL MEAS DEV OUTTOL
    D 3.6460 0.0020 0.0020 3.6435 -0.0025 0.0005 <-----
    END OF DIMENSION CIRC2 DIA
    DIM CIR2 ROUNDNESS
    AX NOMINAL +TOL -TOL MEAS DEV OUTTOL
    M 0.0000 0.0050 0.0000 0.0011 0.0011 0.0000 -#----

    It may help or may muddy the water.

    Thanks for any other guidance you can give me.
  • Try this, it should set some of your variables.
    Untested though.

    OK, I thought I had a clue, but apparently not. So here is the code that works...and is not pulling in the dimensions since I can't seem to figure out how to do it, still.

    Begin VB.Form Form1
    caption = "Visual Basic OLE Client for WinSPC"
    ClientHeight = 4485
    ClientLeft = 60
    ClientTop = 630
    ClientWidth = 6150
    LinkTopic = "Form1"
    ScaleHeight = 4485
    ScaleWidth = 6150
    Begin VB.TextBox Text1
    Height = 4455
    Left = 0
    MultiLine = -1 'True
    ScrollBars = 2 'Vertical
    TabIndex = 0
    Top = 0
    Width = 6135
    End
    Begin VB.Menu RunMenu
    Caption = "&Run"
    End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredID = True
    Attribute VB_Expose = False

    'Declare variables
    sub Main
    Dim PartObj As Object
    Dim CPObj As Object
    Dim DCObj As Object
    Dim DBObj As Object
    Dim UserName As String
    Dim Password As String
    Dim sPart As String
    Dim sVar1 As String
    Dim sVar2 As String
    Dim sCollPlan As String
    Dim PartID As Long
    Dim Var1ID As Long
    Dim Var2ID As Long
    Dim CollPlanID As Long
    Dim Step1ID As Long
    Dim Step2ID As Long
    Dim CollectionPlanID As Object
    Dim dc As Object

    'Open WinSPC and Collection Plan
    Set dc = CreateObject("WinSPC.DataCollectionAuto")
    dc.Visible = True
    dc.RunHeadless = False
    While dc.ReadyForLogin = "F"
    Wend
    dc.UserName = "1675 CMM"
    dc.Password = "1675"

    dc.CollectionPlanID = 8544
    dc.TagIndex = 0
    dc.TagValue = "KKH"
    dc.CurrentStep = 0
    dc.Value = MyReading1
    dc.CurrentStep = 1
    dc.Value = 0.00011
    dc.CurrentStep = 2
    dc.Value = 3.643
    dc.CurrentStep = 3
    dc.Value = 1.565
    dc.CurrentStep = 4
    dc.Value = 1.345
    dc.CurrentStep = 5
    dc.Value = 7.89
    dc.CurrentStep = 6
    dc.Value = 3.726
    dc.CurrentStep = 7
    dc.Value = 0.00012
    dc.CurrentStep = 8
    dc.Value = .215
    dc.CurrentStep = 9
    dc.Value = .215
    dc.CurrentStep = 10
    dc.Value = .215
    dc.CurrentStep = 11
    dc.Value = .215
    dc.CurrentStep = 12
    dc.Value = .83
    dc.CurrentStep = 13
    dc.Value = 0.000015
    dc.CurrentStep = 14
    dc.Value = 0.000014
    dc.CurrentStep = 15
    dc.Value = .215

    dc.CollectionPlanID = 0
    dc.UserName = " "
    Set dc = Nothing
    End Sub

    And here is the code, that I thought I knew what to do with your hint in it.

    Begin VB.Form Form1
    caption = "Visual Basic OLE Client for WinSPC"
    ClientHeight = 4485
    ClientLeft = 60
    ClientTop = 630
    ClientWidth = 6150
    LinkTopic = "Form1"
    ScaleHeight = 4485
    ScaleWidth = 6150
    Begin VB.TextBox Text1
    Height = 4455
    Left = 0
    MultiLine = -1 'True
    ScrollBars = 2 'Vertical
    TabIndex = 0
    Top = 0
    Width = 6135
    End
    Begin VB.Menu RunMenu
    Caption = "&Run"
    End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredID = True
    Attribute VB_Expose = False

    'Declare variables
    sub Main
    Dim PartObj As Object
    Dim CPObj As Object
    Dim DCObj As Object
    Dim DBObj As Object
    Dim UserName As String
    Dim Password As String
    Dim sPart As String
    Dim sVar1 As String
    Dim sVar2 As String
    Dim sCollPlan As String
    Dim PartID As Long
    Dim Var1ID As Long
    Dim Var2ID As Long
    Dim CollPlanID As Long
    Dim Step1ID As Long
    Dim Step2ID As Long
    Dim CollectionPlanID As Object
    Dim dc As Object
    Dim ObjApp As Object
    Dim ObjPP As Object
    Dim ObjCmds As Object
    Dim ObjCmd As Object
    Dim ObjPart As Object
    Dim lngNumCmds As Long

    'Open PCDMIS and ready for output
    Set ObjApp = CreateObject ("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram
    Set ObjCmds = ObjPart.Commands
    Set lngNumCmds = ObjCmds.Count

    'Declare output variables
    Dim StrDimID As Object
    Dim StrDimFeature As String
    Dim StrDimType As Object
    Dim StrDimNominal As String
    Dim StrDimUTol As String
    Dim StrDimLTol As String
    Dim StrDimMeasure As String
    Dim i As Integer
    Dim MyReading1 as Double
    Dim ObjDimCmd as Object
    'build output
    For i = 1 To PCDCommands.Count
    Set StrDimID = PCDCommands(i)
    If StrDimID.IsDimension Then
    Set ObjDimCmd = StrDimID.DimensionCommand
    Set StrDimFeature = StrDimID.ID
    Set StrDimNominal = ObjDimCmd.Nominal
    Set StrDimUTol = ObjDimCmd.Plus
    Set StrDimLTol = ObjDimCmd.Minus

    Set MyReading1 = StrDimID.StrDimMeasure

    'Open WinSPC and Collection Plan
    Set dc = CreateObject("WinSPC.DataCollectionAuto")
    dc.Visible = True
    dc.RunHeadless = False
    While dc.ReadyForLogin = "F"
    Wend
    dc.UserName = "1675 CMM"
    dc.Password = "1675"

    dc.CollectionPlanID = 8544
    dc.TagIndex = 0
    dc.TagValue = "KKH"
    dc.CurrentStep = 0
    dc.Value = MyDimensionCmd
    dc.CurrentStep = 1
    dc.Value = 0.00011
    dc.CurrentStep = 2
    dc.Value = 3.643
    dc.CurrentStep = 3
    dc.Value = 1.565
    dc.CurrentStep = 4
    dc.Value = 1.345
    dc.CurrentStep = 5
    dc.Value = 7.89
    dc.CurrentStep = 6
    dc.Value = 3.726
    dc.CurrentStep = 7
    dc.Value = 0.00012
    dc.CurrentStep = 8
    dc.Value = .215
    dc.CurrentStep = 9
    dc.Value = .215
    dc.CurrentStep = 10
    dc.Value = .215
    dc.CurrentStep = 11
    dc.Value = .215
    dc.CurrentStep = 12
    dc.Value = .83
    dc.CurrentStep = 13
    dc.Value = 0.000015
    dc.CurrentStep = 14
    dc.Value = 0.000014
    dc.CurrentStep = 15
    dc.Value = .215

    dc.CollectionPlanID = 0
    dc.UserName = " "
    Set dc = Nothing
    End Sub


    Please help me, because I am so lost and confused.
  • I can't get this to run, due to a syntax error in the last line. Why it is saying that ending the sub is a syntax error, I don't know becaue I declared it first toward the top. And I can't seem to find a dangling If statement either. Any thoughts?

    And then, I also found out that I can't simply do what we have been doing because we need the AX part of this added into how we are seperating out the variables. In some programs the StrDimID is the same and only seperated by the AX, or what I currently have labeled as the StrDimType (the D,M,Y,X,Z, etc). Would adding that in be Set StrDimType = StrDimID.Type? And then adding that at the MyReading1=StrDimID.StrDimType.StrDimMeasure?
  • I think this line can throw you off:

    Set MyReading1 = StrDimID.StrDimMeasure


    You set StrDimID as the current PC-DMIS command in your loop and then try to use StrDimMeasure which is a string.
    Comment that line out and try again.

    In my red marked code above, we check if the current command is a dimension command, if it is, we set ObjDimCmd to be the currentcommand.DimensionCommand.
    From that, we should be able to use ObjDimCmd.Minus to fetch the dimensioncommands minus tolerance (and so on).
  • So are you talking to change it like this:

    For i = 1 To PCDCommands.Count
    Set StrDimID = PCDCommands(i)
    If StrDimID.IsDimension Then
    Set ObjDimCmd = currentcommand.DimensionCommand
    Set StrDimFeature = StrDimID.ID
    Set StrDimNominal = ObjDimCmd.Nominal
    Set StrDimUTol = ObjDimCmd.Plus
    Set StrDimLTol = ObjDimCmd.Minus
    Set MyReading1 = StrDimID.StrDimMeasure

    And then, I wasn't meaning the tolerances, but the AX, which I only assume is axis and tells whether you are on the x axis, the y axis, z axis, or measuring a diameter (d). Which I have a variable of StrDimType on top for it, but it isn't called out in the code you laid out for me. And of course that has gotten me all confused again.

    Thank you so much for your patience and help.

    Kelly
  • No, you should change as following (untested):

    So are you talking to change it like this:

    For i = 1 To PCDCommands.Count
    Set StrDimID = PCDCommands(i)
    If StrDimID.IsDimension Then
    Set ObjDimCmd = StrDimID.DimensionCommand
    Set StrDimFeature = StrDimID.ID
    Set StrDimNominal = ObjDimCmd.Nominal
    Set StrDimUTol = ObjDimCmd.Plus
    Set StrDimLTol = ObjDimCmd.Minus
    'Set MyReading1 = StrDimID. Measure ' unsure about this data enumerator, could be 'Actual' instead of 'Measure'

    And then, I wasn't meaning the tolerances, but the AX, which I only assume is axis and tells whether you are on the x axis, the y axis, z axis, or measuring a diameter (d). Which I have a variable of StrDimType on top for it, but it isn't called out in the code you laid out for me. And of course that has gotten me all confused again.

    Thank you so much for your patience and help.

    Kelly


    You can add the variable to the code for 'AX' if you need to.
  • OK, thanks. I think I get where you are going with this. I will add it in and try it. And hope that this works. Fingers crossed.