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N/V49=LOC13.X.DEV
ASSIGN/V50=LOC13.Y.DEV
ASSIGN/V51=LOC14.X.DEV
ASSIGN/V52=LOC14.Y.DEV
ASSIGN/V53=LOC15.X.DEV
ASSIGN/V54=LOC15.Y.DEV
ASSIGN/V97="Date"+","+"Time"+","+"1.60 .190-32"+","+"1.60 5/16-24"+","+"1.00 Spot"+","+".8701 Spool"+","+".8701 5/16-24"
ASSIGN/V98=".8701 .452"+","+".8701 1/2-20"+","+"1.7902 Spool"+","+"1.7902 5/16-24"+","+"1.7902 .750"+","+"1.7902 7/8-14"
ASSIGN/V99=".6496 Spot"+","+"3.7780 Spot"+","+".2165 #1 x"+","+".2165 #1 y"+","+".2165 #2 x"+","+".2165 #2 y"
ASSIGN/V100=".2165 #3 x"+","+".2165 #3 y"+","+".2165 #4 x"+","+".2165 #4 y"+","+".156 #1 x"+","+".156 #1 y"
ASSIGN/V101=".156 #2 x"+","+".156 #2 y"+","+"Spot #6 x"+","+"Spot #6 y"+","+"Spot #5 x"+","+"Spot #5 y"
ASSIGN/V102="Spot #7 x"+","+"Spot #7 y"+","+".1256 x"+","+".1256 y"+","+".272 x"+","+".272 y"+","+"5/16-24 #1 x"
ASSIGN/V103="5/16-24 #1 y"+","+"TP tol (2x)"+","+".8701 7/16-20 #1"+","+".8701 7/16-20 #2"+","+"1.60 7/16-20 #1"+","+"1.60 7/16-20 #2"
ASSIGN/V104=".752 Spot Front"+","+".752 Spot Back"+","+"Spot #1 x"+","+"Spot #1 y"+","+"Spot #2 x"
ASSIGN/V105="Spot #2 y"+","+"Spot #3 x"+","+"Spot #3 y"+","+"Spot #4 x"+","+"Spot #4 y"
ASSIGN/V109=V3+","+V4+","+V5+","+V6+","+V7+","+V8+","+V9+","+V10+","+V11+","+V12+","+V13+","+V14+","+V15
ASSIGN/V110=V16+","+V17+","+V18+","+V19+","+V20+","+V21+","+V22+","+V23+","+V24+","+V25+","+V26+","+V27
ASSIGN/V111=V28+","+V29+","+V30+","+V31+","+V32+","+V33+","+V34+","+V35+","+V36+","+V37+","+V38+","+V39
ASSIGN/V112=V40+","+V41+","+V2+","+V42+","+V43+","+V44+","+V1+","+V45+","+V46+","+V47+","+V48+","+V49+","+V50+","+V51
ASSIGN/V113=V52+","+V53+","+V54

above is a portion of code.

Dim app As PCDLRN.Application
Dim cmds As Object
Dim cmd As PCDLRN.Command
Dim part As PCDLRN.PartProgram
Dim data As PCDLRN.ReportData
Dim rWin As PCDLRN.ReportWindow

Dim s As String = ""

app = GetObject("", "PCDLRN.Application.12.1")
app.Visible = True
part = app.ActivePartProgram
cmds = part.Commands

Dim nCommands As String = part.Commands.Count.ToString
Dim val As String = part.GetVariableValue("PLN1").StringValue.ToString

MessageBox.Show("Value is -- " & val & "--" & nCommands)

For Each cmd In cmds
'Dim assignName As Object = cmd.GetText(PCDLRN.ENUM_FIELD_TYPES.DEST_EXPR, 0)
'Console.WriteLine(assignName.ToString)
Console.WriteLine(cmd.TypeDescription.ToString & " " & cmd.Type & " " & cmd.GetFieldValue())
'Console.WriteLine(part.GetVariableValue(assignName).CommandValue.ToString)
Next

'rWin = part.ReportWindow
'data = rWin.Pages

'Dim dat As String = data.GetValue(PCDLRN.ENUM_FIELD_TYPES.AXIS_NOMINAL, 1107)
'MessageBox.Show(dat)

and above is the VB.NET code I am using to access CMM code. I want to get all the values inside ASSIGN/x=y commands eg: ASSIGN/V113=V52+","+V53+","+V54. Can anyone share code to get these values ? I am trying to use Command.GetFieldValue(PCDLRN ENUM FIELD TYPE, TYPE INDEX ) , I do not understand what are these two parameters inside the GetFieldValue method ? Any help will be appreciated.
  • I am new to using PCDMIS.
    
    ASSIGN/V3=SYSTEMDATE("MM'/'dd'/'yy")
    ASSIGN/V4=SYSTEMTIME("hh:mm:ss tt")
    ASSIGN/V5=DIST1.DEV
    ASSIGN/V6=DIST2.DEV
    ASSIGN/V7=DIST3.DEV
    ASSIGN/V8=DIST4.DEV
    ASSIGN/V9=DIST5.DEV
    ASSIGN/V10=DIST9.DEV
    ASSIGN/V11=DIST10.DEV
    ASSIGN/V12=DIST6.DEV
    ASSIGN/V13=DIST7.DEV
    ASSIGN/V14=DIST11.DEV
    ASSIGN/V15=DIST12.DEV
    ASSIGN/V16=DIST8.DEV
    ASSIGN/V17=DIST19.DEV
    ASSIGN/V18=LOC1.X.DEV
    ASSIGN/V19=LOC1.Y.DEV
    ASSIGN/V20=LOC2.X.DEV
    ASSIGN/V21=LOC2.Y.DEV
    ASSIGN/V22=LOC3.X.DEV
    ASSIGN/V23=LOC3.Y.DEV
    ASSIGN/V24=LOC4.X.DEV
    ASSIGN/V25=LOC4.Y.DEV
    ASSIGN/V26=LOC5.X.DEV
    ASSIGN/V27=LOC5.Y.DEV
    ASSIGN/V28=LOC6.X.DEV
    ASSIGN/V29=LOC6.Y.DEV
    ASSIGN/V30=LOC7.X.DEV
    ASSIGN/V31=LOC7.Y.DEV
    ASSIGN/V32=LOC8.X.DEV
    ASSIGN/V33=LOC8.Y.DEV
    ASSIGN/V34=LOC9.X.DEV
    ASSIGN/V35=LOC9.Y.DEV
    ASSIGN/V36=LOC10.X.DEV
    ASSIGN/V37=LOC10.Y.DEV
    ASSIGN/V38=LOC16.X.DEV
    ASSIGN/V39=LOC16.Y.DEV
    ASSIGN/V40=LOC11.X.DEV
    ASSIGN/V41=LOC11.Y.DEV
    ASSIGN/V42=DIST13.DEV
    ASSIGN/V43=DIST14.DEV
    ASSIGN/V44=DIST15.DEV
    ASSIGN/V1=DIST16.DEV
    ASSIGN/V45=DIST17.DEV
    ASSIGN/V46=DIST18.DEV
    ASSIGN/V47=LOC12.X.DEV
    ASSIGN/V48=LOC12.Y.DEV
    ASSIGN/V49=LOC13.X.DEV
    ASSIGN/V50=LOC13.Y.DEV
    ASSIGN/V51=LOC14.X.DEV
    ASSIGN/V52=LOC14.Y.DEV
    ASSIGN/V53=LOC15.X.DEV
    ASSIGN/V54=LOC15.Y.DEV
    ASSIGN/V97="Date"+","+"Time"+","+"1.60 .190-32"+","+"1.60 5/16-24"+","+"1.00 Spot"+","+".8701 Spool"+","+".8701 5/16-24"
    ASSIGN/V98=".8701 .452"+","+".8701 1/2-20"+","+"1.7902 Spool"+","+"1.7902 5/16-24"+","+"1.7902 .750"+","+"1.7902 7/8-14"
    ASSIGN/V99=".6496 Spot"+","+"3.7780 Spot"+","+".2165 #1 x"+","+".2165 #1 y"+","+".2165 #2 x"+","+".2165 #2 y"
    ASSIGN/V100=".2165 #3 x"+","+".2165 #3 y"+","+".2165 #4 x"+","+".2165 #4 y"+","+".156 #1 x"+","+".156 #1 y"
    ASSIGN/V101=".156 #2 x"+","+".156 #2 y"+","+"Spot #6 x"+","+"Spot #6 y"+","+"Spot #5 x"+","+"Spot #5 y"
    ASSIGN/V102="Spot #7 x"+","+"Spot #7 y"+","+".1256 x"+","+".1256 y"+","+".272 x"+","+".272 y"+","+"5/16-24 #1 x"
    ASSIGN/V103="5/16-24 #1 y"+","+"TP tol (2x)"+","+".8701 7/16-20 #1"+","+".8701 7/16-20 #2"+","+"1.60 7/16-20 #1"+","+"1.60 7/16-20 #2"
    ASSIGN/V104=".752 Spot Front"+","+".752 Spot Back"+","+"Spot #1 x"+","+"Spot #1 y"+","+"Spot #2 x"
    ASSIGN/V105="Spot #2 y"+","+"Spot #3 x"+","+"Spot #3 y"+","+"Spot #4 x"+","+"Spot #4 y"
    ASSIGN/V109=V3+","+V4+","+V5+","+V6+","+V7+","+V8+","+V9+","+V10+","+V11+","+V12+","+V13+","+V14+","+V15
    ASSIGN/V110=V16+","+V17+","+V18+","+V19+","+V20+","+V21+","+V22+","+V23+","+V24+","+V25+","+V26+","+V27
    ASSIGN/V111=V28+","+V29+","+V30+","+V31+","+V32+","+V33+","+V34+","+V35+","+V36+","+V37+","+V38+","+V39
    ASSIGN/V112=V40+","+V41+","+V2+","+V42+","+V43+","+V44+","+V1+","+V45+","+V46+","+V47+","+V48+","+V49+","+V50+","+V51
    ASSIGN/V113=V52+","+V53+","+V54


    above is a portion of code.
    Dim app As PCDLRN.Application
    Dim cmds As Object
    Dim cmd As PCDLRN.Command
    Dim part As PCDLRN.PartProgram
    Dim data As PCDLRN.ReportData
    Dim rWin As PCDLRN.ReportWindow
    
    Dim s As String = ""
    
    app = GetObject("", "PCDLRN.Application.12.1")
    app.Visible = True
    part = app.ActivePartProgram
    cmds = part.Commands
    
    Dim nCommands As String = part.Commands.Count.ToString
    Dim val As String = part.GetVariableValue("PLN1").StringValue.ToString
    
    MessageBox.Show("Value is -- " & val & "--" & nCommands)
    
    For Each cmd In cmds
    'Dim assignName As Object = cmd.GetText(PCDLRN.ENUM_FIELD_TYPES.DEST_EXPR, 0)
    'Console.WriteLine(assignName.ToString)
    Console.WriteLine(cmd.TypeDescription.ToString & " " & cmd.Type & " " & cmd.GetFieldValue())
    'Console.WriteLine(part.GetVariableValue(assignName).CommandValue.ToString)
    Next
    
    'rWin = part.ReportWindow
    'data = rWin.Pages
    
    'Dim dat As String = data.GetValue(PCDLRN.ENUM_FIELD_TYPES.AXIS_NOMINAL, 1107)
    'MessageBox.Show(dat)


    and above is the VB.NET code I am using to access CMM code. I want to get all the values inside ASSIGN/x=y commands eg: ASSIGN/V113=V52+","+V53+","+V54. Can anyone share code to get these values ? I am trying to use Command.GetFieldValue(PCDLRN ENUM FIELD TYPE, TYPE INDEX ) , I do not understand what are these two parameters inside the GetFieldValue method ? Any help will be appreciated.


    May help

  • Welcome to the forum . There is a few very smart script guys on this forum that should get back to you soon
  • Hi yes, I am familiar with VB.NET but not with pcdmis
  • Im not much help for this, just wanted to say hello.
  • Also I have PCDLRN Interop dll. I am trying to use dotpeek to read the implementation of classes and interfaces in this library. But all I see is virtual functions with no implementations so I am not able to understand how to use this dll correctly.
  • For Each cmd in cmds
      If cmd.TypeDescription = "Assignment" Then
          Dim assignName as Object = cmd.GetText(PCDLRN.ENUM_FIELD_TYPES.DEST_EXPR, 0)
          assVal = part.GetVariableValue(assignName).StringValue
          MsgBox(assVal)
      End If
    Next cmd
    


    From the pcdbasic.chm located in your pcdmis install directory:



    Public Function GetText( _ ByVal DataType As ENUM_FIELD_TYPES, _ ByVal TypeIndex As Long _ ) As String



    Found this too!

    "Use this command to get text that is displayed in the edit window for different object fields. The ENUM_FIELD_TYPES enumeration is a large enumeration. Documentation for which field types go with which objects is not given here. You can find this information by creating the desired object in PC-DMIS, inserting the desired expression in the desired field, and exporting (posting out) the containing measurement routine to BASIC."
    Looks like this is what you're trying to do.

  • I tried this from your thread that I found on this forum. When i ran this code I got null object returned on assignName. and when i used assignName in GetVariableValue(assignName) I got null reference exception thrown.

    What is TypeIndex parameter ? Should i used 0 all the time for TypeIndex ?
  • No kidding! no wonder the variable names rang 20 bells...
  • Here let's fix your code:

    Sub Test()
            Dim app As PCDLRN.Application
            Dim cmds As Object
            Dim cmd As PCDLRN.Command
            Dim part As PCDLRN.PartProgram
            Dim varValue As String
    
            Dim s As String = ""
    
            Try
                app = CreateObject("PCDLRN.Application.10.1") 'Using PCD version 2015.1
            Catch ex As Exception
                MsgBox("PcDmis cannot connect. " & vbNewLine & "(Error - " & ex.Message & ")" & vbNewLine & ex.ToString, MsgBoxStyle.Critical)
                Exit Sub
            End Try
    
            app.Visible = True
            part = app.ActivePartProgram
            cmds = part.Commands
    
            For Each cmd In cmds
                If cmd.TypeDescription = "Assignment" Then
                    Dim assignName As Object = cmd.GetText(PCDLRN.ENUM_FIELD_TYPES.DEST_EXPR, 0)
    
                    varValue = part.GetVariableValue(assignName).StringValue
                    MsgBox(varValue)
    
                End If
            Next cmd
        End Sub


    We're simply sending every assignment's value to a message box so you can view them. Later once you get the hang of it you can send that same data to wherever you'd like.

    Your code looks like the code from my post except it's slightly modified, look closely at it, and as far as explaining it... maybe someone else could cuz I am not sure how to explain it, all I know is that: that is the code and it WORKS.