Cypress Enable Basic to Visual Basic .NET

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cypress Enable Basic to Visual Basic .NET

    Does anyone know the correct Visual Basic .NET syntax to replace the Cypress Enable Basic example below?
    Example:
    CommandCount = DmisCommands.Count
    Set DmisCommand = DmisCommands.Item(CommandCount)
    DmisCommands.InsertionPointAfter DmisCommand


    Cypress Enable Basic Example
    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object

    Sub Part1
    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    Set DmisCommands = DmisPart.Commands
    CommandCount = DmisCommands.Count
    Set DmisCommand = DmisCommands.Item(CommandCount)
    DmisCommands.InsertionPointAfter DmisCommand

    End Sub

    Sub Main

    Part1

    DmisPart.RefreshPart
    End Sub





    Visual Basic .NET Example
    Module Module1

    Sub Main()
    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object

    Try
    DmisApp = CreateObject("PCDLRN.Application")
    Catch ex As Exception
    MsgBox("PcDmis cannot connect. " & vbNewLine & "(Error - " & ex.Message & ")" & vbNewLine & ex.ToString, MsgBoxStyle.Critical)
    Exit Sub
    End Try

    DmisApp.Visible = True

    DmisApp = CreateObject("PCDLRN.Application")
    DmisPart = DmisApp.ActivePartProgram
    DmisCommands = DmisPart.Commands
    'CommandCount = DmisCommands.Count
    'DmisCommand = DmisCommands.Item(CommandCount)
    'DmisCommands.InsertionPointAfter DmisCommand

    End Sub

    End Module
    Working with the Best crashing software like no other.
    PC-DMIS BETA Software
    The CrashRpt Metrology Software company.

  • #2
    I've yet to figure out how in the world do you get the text to show just like an IDE with colors and such, I love it!

    Code:
    Dim DmisApp As PCDLRN.Application
    Dim DmisPart As PCDLRN.IPartProgram
    Dim DmisCommands As PCDLRN.Commands
    Dim DmisCommand As PCDLRN.Command
    
    Try
        DmisApp = CreateObject("PCDLRN.Application")
    Catch ex As Exception
        MsgBox("PcDmis cannot connect. " & vbNewLine & "(Error - " & ex.Message & ")" & vbNewLine & ex.ToString, MsgBoxStyle.Critical)
        Exit Sub
    End Try
    
    DmisApp.Visible = True
    
    'DmisApp = CreateObject("PCDLRN.Application")
    DmisPart = DmisApp.ActivePartProgram
    DmisCommands = DmisPart.Commands
    
    'CommandCount = DmisCommands.Count
    Dim CommandCount As Integer
    CommandCount = DmisCommands.Count
    
    'DmisCommand = DmisCommands.Item(CommandCount)
    DmisCommand = DmisCommands.Item(CommandCount) ' sets command to very last item
    
    'DmisCommands.InsertionPointAfter DmisCommand
    DmisCommands.InsertionPointAfter(DmisCommand)
    give this a try and please report back if works out for you.
    Last edited by Kp61dude!; 02-19-2020, 11:49 AM.
    PcDmis 2015.1 SP10 CAD++
    Global 7-10-7 DC800S

    Comment


    • #3
      Kp61dude!, thank you. I will give that a try.

      For the IDE colors, just copy the text from Visual Studio and paste the text to a word document. Then use the Paste from Word Pcdmis Forum Toolbar with Paste from Word.png
      Working with the Best crashing software like no other.
      PC-DMIS BETA Software
      The CrashRpt Metrology Software company.

      Comment


      • Kp61dude!
        Kp61dude! commented
        Editing a comment
        You helped me more than I helped you... thank you!

    • #4
      That Work Kp61dude!, thank you again.

      Here is a Test example using the information you provide me.

      Module Module1

      Sub Main()
      Dim DmisApp As Object
      Dim DmisPart As Object
      Dim DmisCommands As Object
      Dim DmisCommand As Object

      Try
      DmisApp = CreateObject("PCDLRN.Application") 'Using PCD version 2015.1 10.1 2019.1 15.1
      Catch ex As Exception
      MsgBox("PcDmis cannot connect. " & vbNewLine & "(Error - " & ex.Message & ")" & vbNewLine & ex.ToString, MsgBoxStyle.Critical)
      Exit Sub
      End Try

      DmisApp.Visible = True

      DmisApp = CreateObject("PCDLRN.Application")
      DmisPart = DmisApp.ActivePartProgram
      DmisCommands = DmisPart.Commands
      'CommandCount = DmisCommands.Count
      Dim CommandCount As Integer
      CommandCount = DmisCommands.Count
      'DmisCommand = DmisCommands.Item(CommandCount)
      DmisCommand = DmisCommands.Item(CommandCount) ' sets command to very last item
      'DmisCommands.InsertionPointAfter DmisCommand
      DmisCommands.InsertionPointAfter(DmisCommand)

      DmisCommand = DmisCommands.Add(195, True)
      DmisCommand.Marked = True
      ' Set Destination Expression = V1
      DmisCommand.PutText("V1", PCDLRN.ENUM_FIELD_TYPES.DEST_EXPR, 0)
      ' Set Source Expression = ""Hello""
      DmisCommand.PutText("""Hello""", PCDLRN.ENUM_FIELD_TYPES.SRC_EXPR, 0)

      DmisCommand = DmisCommands.Add(170, True)
      DmisCommand.Marked = True
      ' Set Id =
      DmisCommand.PutText("", PCDLRN.ENUM_FIELD_TYPES.ID, 0)
      ' Set Comment Type = $$
      DmisCommand.SetToggleString(4, PCDLRN.ENUM_FIELD_TYPES.COMMENT_TYPE, 0)
      ' Set Comment Item 1 = Add BOTTOM sided features, datum definitions and dimensions here:
      DmisCommand.PutText("Add BOTTOM sided features, datum definitions and dimensions here:", PCDLRN.ENUM_FIELD_TYPES.COMMENT_FIELD, 1)
      ' Set Report = NO
      DmisCommand.SetToggleString(1, PCDLRN.ENUM_FIELD_TYPES.OUTPUT_TYPE, 0)

      DmisPart.RefreshPart

      End Sub

      End Module



      Last edited by Dmisfatboy; 02-20-2020, 09:26 AM. Reason: Added: DmisPart.RefreshPart
      Working with the Best crashing software like no other.
      PC-DMIS BETA Software
      The CrashRpt Metrology Software company.

      Comment


      • #5
        Update: Added Automettech suggestion. Thank you.


        The best thing to do is add a reference to the PC-Dmis type library in your project. That way you get intelisence (or something like that).

        What this means is when you define an object, instead of declaring it as an object you declare it as a specific type of object

        Dim PCDAPP as PCDLRN.Application instead of Dim PCAPP as Object
        Dim PCPart as PCDLRN.PartProgram instead of Dim PCPart as Object

        Now when you type PCDAPP and hit the period "." you get a list of all properties and methods available for that object.

        CODE:

        Code using Visual Studio 2019.
        VB Console App (.NET Framework)

        Module Module1

        Sub Main()
        Dim DmisApp As PCDLRN.Application
        Dim DmisPart As PCDLRN.IPartProgram
        Dim DmisCommands As PCDLRN.Commands
        Dim DmisCommand As PCDLRN.Command

        Try
        DmisApp = CreateObject("PCDLRN.Application") 'Using PCD version 2015.1 10.1 2019.1 15.1
        Catch ex As Exception
        MsgBox("PcDmis cannot connect. " & vbNewLine & "(Error - " & ex.Message & ")" & vbNewLine & ex.ToString, MsgBoxStyle.Critical)
        Exit Sub
        End Try

        DmisApp.Visible = True

        DmisApp = CreateObject("PCDLRN.Application")
        DmisPart = DmisApp.ActivePartProgram
        DmisCommands = DmisPart.Commands
        'CommandCount = DmisCommands.Count
        Dim CommandCount As Integer
        CommandCount = DmisCommands.Count
        'DmisCommand = DmisCommands.Item(CommandCount)
        DmisCommand = DmisCommands.Item(CommandCount) ' sets command to very last item
        'DmisCommands.InsertionPointAfter DmisCommand
        DmisCommands.InsertionPointAfter(DmisCommand)

        DmisCommand = DmisCommands.Add(195, True)
        DmisCommand.Marked = True
        ' Set Destination Expression = V1
        DmisCommand.PutText("V1", PCDLRN.ENUM_FIELD_TYPES.DEST_EXPR, 0)
        ' Set Source Expression = "Hello"
        DmisCommand.PutText("""Hello""", PCDLRN.ENUM_FIELD_TYPES.SRC_EXPR, 0)

        DmisCommand = DmisCommands.Add(170, True)
        DmisCommand.Marked = True
        ' Set Id =
        DmisCommand.PutText("", PCDLRN.ENUM_FIELD_TYPES.ID, 0)
        ' Set Comment Type = $$
        DmisCommand.SetToggleString(4, PCDLRN.ENUM_FIELD_TYPES.COMMENT_TYPE, 0)
        ' Set Comment Item 1 = Add BOTTOM sided features, datum definitions and dimensions here:
        DmisCommand.PutText("Add BOTTOM sided features, datum definitions and dimensions here:", PCDLRN.ENUM_FIELD_TYPES.COMMENT_FIELD, 1)
        ' Set Report = NO
        DmisCommand.SetToggleString(1, PCDLRN.ENUM_FIELD_TYPES.OUTPUT_TYPE, 0)

        DmisPart.RefreshPart

        End Sub

        End Module




        Working with the Best crashing software like no other.
        PC-DMIS BETA Software
        The CrashRpt Metrology Software company.

        Comment


        • NinjaBadger
          NinjaBadger commented
          Editing a comment
          For those that inhabit this and the other forum NinjaBadger=Automettech

      • #6
        It is best to learn the .Net code for the long run, but in some cases you should be able to just add a couple of ines at the top of the project to make use of your existing (VB6 like) code -

        Imports Microsoft.VisualBasic.ControlChars

        Imports PCDLRN.OBTYPE
        Imports PCDLRN.ENUM_FIELD_TYPES


        Public Class Form1
        . . .
        . . .
        . . .

        Comment


        • #7
          Update: Added Don Ruggieri suggestion. Thank you.

          Originally posted by Don Ruggieri View Post
          It is best to learn the .Net code for the long run, but in some cases you should be able to just add a couple of ines at the top of the project to make use of your existing (VB6 like) code -

          Imports Microsoft.VisualBasic.ControlChars

          Imports PCDLRN.OBTYPE
          Imports PCDLRN.ENUM_FIELD_TYPES


          Public Class Form1
          . . .
          . . .
          . . .
          CODE:

          Code using Visual Studio 2019.
          VB Console App (.NET Framework)

          Imports Microsoft.VisualBasic.ControlChars

          Imports PCDLRN.OBTYPE
          Imports PCDLRN.ENUM_FIELD_TYPES
          Module Module1

          Sub Main()
          Dim DmisApp As Object
          Dim DmisPart As Object
          Dim DmisCommands As Object
          Dim DmisCommand As Object

          Try
          DmisApp = CreateObject("PCDLRN.Application") 'Using PCD version 2015.1 10.1 2019.1 15.1
          Catch ex As Exception
          MsgBox("PcDmis cannot connect. " & vbNewLine & "(Error - " & ex.Message & ")" & vbNewLine & ex.ToString, MsgBoxStyle.Critical)
          Exit Sub
          End Try

          DmisApp.Visible = True

          DmisApp = CreateObject("PCDLRN.Application")
          DmisPart = DmisApp.ActivePartProgram
          DmisCommands = DmisPart.Commands
          'CommandCount = DmisCommands.Count
          Dim CommandCount As Integer
          CommandCount = DmisCommands.Count
          'DmisCommand = DmisCommands.Item(CommandCount)
          DmisCommand = DmisCommands.Item(CommandCount) ' sets command to very last item
          'DmisCommands.InsertionPointAfter DmisCommand
          DmisCommands.InsertionPointAfter(DmisCommand)

          DmisCommand = DmisCommands.Add(ASSIGNMENT, True)
          DmisCommand.Marked = True
          ' Set Destination Expression = V1
          DmisCommand.PutText("V1", DEST_EXPR, 0)
          ' Set Source Expression = ""Hello""
          DmisCommand.PutText("""Hello""", SRC_EXPR, 0)

          DmisCommand = DmisCommands.Add(SET_COMMENT, True)
          DmisCommand.Marked = True
          ' Set Id =
          DmisCommand.PutText("", ID, 0)
          ' Set Comment Type = $$
          DmisCommand.SetToggleString(4, COMMENT_TYPE, 0)
          ' Set Comment Item 1 = Add BOTTOM sided features, datum definitions and dimensions here:
          DmisCommand.PutText("Add BOTTOM sided features, datum definitions and dimensions here:", COMMENT_FIELD, 1)
          ' Set Report = NO
          DmisCommand.SetToggleString(1, OUTPUT_TYPE, 0)

          DmisPart.RefreshPart


          End Sub

          End Module


          Working with the Best crashing software like no other.
          PC-DMIS BETA Software
          The CrashRpt Metrology Software company.

          Comment

          Related Topics

          Collapse

          • Radar
            Script using Basic
            by Radar
            Where I work we have several parts that only differ as far as the size and number of holes on the face plane of the part. Someone before me has taken...
            12-05-2018, 08:00 PM
          • MrBloondy
            Automated execution of several consecutive programs
            by MrBloondy
            Hi guys.
            I would like to know how i can automate the execution of several consecutive programs and which software i can do it easily.
            Maybe...
            05-15-2016, 05:04 PM
          • Chally72
            Writing/Reading a .txt file
            by Chally72
            This is very much a VB question not related to PC-DMIS. There is so much information out there for VB that I find it very hard to locate a good example...
            09-23-2009, 01:26 PM
          • Rploughe
            Operator Login
            by Rploughe
            here is a basic script for a simple operator login.

            Code:
            Sub[SIZE=2][COLOR=#000000] Main[/COLOR]
            [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Begin[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dialog[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] DIALOG_1 50,10, 300, 125, oOPERATORINPUT[/COLOR]
            GroupBox[/]
            ...
            01-21-2014, 01:52 PM
          • Paul Sarrach
            Your SMA not at work:
            by Paul Sarrach
            After I put the call into B&S and called me back the next day, they worked on it for 2 days. And this is thier reply by email no less:
            ...
            10-11-2007, 10:37 AM
          Working...
          X