hexagon logo

Program to Open PC-DMIS

I am currently attempting to write a program (VB.NET) that will have a PC-DMIS program's file name passed to it. This program should then start PC-DMIS if it isn't already running, and open the program that was passed to it. If PC-Dmis is already running, then it should open the program that was passed to it. Then, the program should close, leaving PC-DMIS running. I also want PCDMIS to be opened as Operator Mode.

I am attempting to do this by referncing PCDLRN within the program. Hwoever, I am having little luck with the .OperatorMode=true method.

The reason I am attempting to do this in VB.NET is I will then follow up with some additional programming (saving info to a DB and what not) that would be cumbersome as a .VBS etc.

This PCDMIS 2011 MR1 and VB.NET 2010 (.NET 4.0)

Imports System.IO


Public Class Form1

    Public PCDApp As PCDLRN.Application
    Public PCDPartPrograms As Object
    Public PCDPartProgram As Object

    Public fileName As String = "C:\Work\31580 - 1 - 12345.PRG"


    Private Sub Application_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        If File.GetAttributes(fileName) = FileAttributes.ReadOnly Then
            File.SetAttributes(fileName, FileAttributes.Normal)
        End If

        StartApplication(fileName)

    End Sub ' Application_Load



    Public Sub StartApplication(ByVal _fileName As String)

        PCDApp = CreateObject("PCDLRN.Application")
        PCDPartPrograms = PCDApp.PartPrograms

        PCDApp.Visible = True
        PCDPartPrograms.Open(_fileName, "CMM1")

    End Sub


End Class
Parents
  • We could do that, but the PLM system (Dassault Systemes' SmarTeam) we are looking to store the files in changes files to "Read Only", which PC-DMIS has a fit about. So, that flag needs to be cleared. Also, I am looking to introduce some logging that will compliment the execution which I want to tie into the application. For whatever reason, the application seems to be working fine in that regard now. But, now I am getting a strange behavior when I run the application with Operator Mode Turned off. When PC-DMIS exits, the PCDLRN is still running in Task Manager.

    Here is the entire code:

    Imports System.IO
    
    Public Class Form1
    
        Public PCDApp As PCDLRN.Application
        Public PCDPartPrograms As Object
        Public PCDPartProgram As Object
    
        Public fileName As String = "C:\SmarTeam\Work\3337 - 11100.087574.PRG"
        'Public fileName As String = "C:\SmarTeam\Work\31580 - 1 - 12345.PRG"
    
    
        Private Sub Application_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            File.SetAttributes(fileName, FileAttributes.Normal)
    
            StartApplication(fileName)
            EndForm()
        End Sub ' Application_Load
    
    
        Public Sub StartApplication(ByVal _fileName As String)
    
    
            On Error Resume Next
            PCDApp = System.Runtime.InteropServices.Marshal.GetActiveObject("PCDLRN.Application")
    
            If PCDApp Is Nothing Or Err.Number <> 0 Then
                PCDApp = CreateObject("PCDLRN.Application")
            End If
    
            PCDPartPrograms = PCDApp.PartPrograms
    
            PCDApp.Visible = True
            PCDApp.SetActive()
            PCDApp.Maximize()
    
            ''PCDApp.OperatorMode = True
            'CheckBox1.Checked = True
    
            PCDPartProgram = PCDPartPrograms.Open(_fileName, "CMM1")
    
        End Sub
    
    
        Private Sub EndForm()
            Me.Close()
        End Sub
    
    
        Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged
    
            PCDApp.OperatorMode = CheckBox1.Checked
    
        End Sub
    
    End Class
    
    
Reply
  • We could do that, but the PLM system (Dassault Systemes' SmarTeam) we are looking to store the files in changes files to "Read Only", which PC-DMIS has a fit about. So, that flag needs to be cleared. Also, I am looking to introduce some logging that will compliment the execution which I want to tie into the application. For whatever reason, the application seems to be working fine in that regard now. But, now I am getting a strange behavior when I run the application with Operator Mode Turned off. When PC-DMIS exits, the PCDLRN is still running in Task Manager.

    Here is the entire code:

    Imports System.IO
    
    Public Class Form1
    
        Public PCDApp As PCDLRN.Application
        Public PCDPartPrograms As Object
        Public PCDPartProgram As Object
    
        Public fileName As String = "C:\SmarTeam\Work\3337 - 11100.087574.PRG"
        'Public fileName As String = "C:\SmarTeam\Work\31580 - 1 - 12345.PRG"
    
    
        Private Sub Application_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            File.SetAttributes(fileName, FileAttributes.Normal)
    
            StartApplication(fileName)
            EndForm()
        End Sub ' Application_Load
    
    
        Public Sub StartApplication(ByVal _fileName As String)
    
    
            On Error Resume Next
            PCDApp = System.Runtime.InteropServices.Marshal.GetActiveObject("PCDLRN.Application")
    
            If PCDApp Is Nothing Or Err.Number <> 0 Then
                PCDApp = CreateObject("PCDLRN.Application")
            End If
    
            PCDPartPrograms = PCDApp.PartPrograms
    
            PCDApp.Visible = True
            PCDApp.SetActive()
            PCDApp.Maximize()
    
            ''PCDApp.OperatorMode = True
            'CheckBox1.Checked = True
    
            PCDPartProgram = PCDPartPrograms.Open(_fileName, "CMM1")
    
        End Sub
    
    
        Private Sub EndForm()
            Me.Close()
        End Sub
    
    
        Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged
    
            PCDApp.OperatorMode = CheckBox1.Checked
    
        End Sub
    
    End Class
    
    
Children
No Data