PC-DMIS 2021.1 Object Library
CurrentFolder Property
See Also  Example  Send Topic Feedback | See Object Hierarchy Chart
PCDLRN ActiveX DLL > Application Object : CurrentFolder Property

Glossary Item Box

Description

This property gets or sets the current folder in PC-DMIS. The property only sets a folder if all part programs are closed.

Syntax

Visual Basic
Public Property CurrentFolder As String

Return Type

String value representing the directory path to the folder name.

Example

This example code connects to PC-DMIS, and lets you get or set the current folder.

 

Example (C#)Copy Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PCDLRN;

namespace Test_Automation_PCD_114161
{
  public partial class Form1 : Form
  {
    PCDLRN.Application application;
    PCDLRN.PartPrograms programs;
    PCDLRN.PartProgram program;

    public Form1()
    {
      InitializeComponent();
    }

    private void Connect_Click(object sender, EventArgs e)
    {
      application = new PCDLRN.Application();
      if (application != null)
      {
        Connect.Enabled = false;
        Disconnect.Enabled = true;
        GetCurrentFolder.Enabled = true;
        SetCurrentFolder.Enabled = true;
        SelectCurrentFolder.Enabled = true;
        LoadPartProgram.Enabled = true;
        ClosePartProgram.Enabled = true;
        getCurrentFolderText.Enabled = true;
        setCurrentFolderText.Enabled = true;
        loadedPartProgram.Enabled = true;
        checkBoxVisible.Enabled = true;
        checkBoxVisible.Checked = application.Visible;
        programs = application.PartPrograms;
      }
    }

    private void Disconnect_Click(object sender, EventArgs e)
    {
      if (application != null)
      {
        Connect.Enabled = true;
        Disconnect.Enabled = false;
        GetCurrentFolder.Enabled = false;
        SetCurrentFolder.Enabled = false;
        SelectCurrentFolder.Enabled = false;
        LoadPartProgram.Enabled = false;
        ClosePartProgram.Enabled = false;
        getCurrentFolderText.Enabled = false;
        setCurrentFolderText.Enabled = false;
        loadedPartProgram.Enabled = false;
        checkBoxVisible.Enabled = false;
        checkBoxVisible.Checked = false;
        program?.Quit();
        program = null;
        programs = null;
        GC.Collect();
      }

    }

    private void GetCurrentFolder_Click(object sender, EventArgs e)
    {
      if (application != null)
      {
        var curfolder = application.CurrentFolder;
        getCurrentFolderText.Text = curfolder;
      }
    }


    private void SelectCurrentFolder_Click(object sender, EventArgs e)
    {
      folderBrowserDialog.ShowDialog();
      setCurrentFolderText.Text = folderBrowserDialog.SelectedPath;
    }

    private void SetCurrentFolder_Click(object sender, EventArgs e)
    {
      if (application != null)
      {
        application.CurrentFolder = setCurrentFolderText.Text;
        getCurrentFolderText.Text = string.Empty;
      }
    }

    private void LoadPartProgram_Click(object sender, EventArgs e)
    {
      loadedPartProgram.Text = string.Empty;
      if (program != null)
      {
        program.Quit();
        program = null;
      }
      if (programs != null)
      {
        openFileDialog1.CheckFileExists = true;
        openFileDialog1.Multiselect = false;
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
          program = programs.Open(openFileDialog1.FileName, "OFFLINE");
          if (program != null)
          {
            loadedPartProgram.Text = program.FullName;
          }
          getCurrentFolderText.Text = string.Empty;
        }
      }
    }

    private void ClosePartProgram_Click(object sender, EventArgs e)
    {
      loadedPartProgram.Text = string.Empty;
      if (program != null)
      {
        program.Quit();
        program = null;
      }
    }

    private void checkBoxVisible_CheckedChanged(object sender, EventArgs e)
    {
      application.Visible = checkBoxVisible.Checked;
    }
  }
}

See Also

Copyright © 2020. Hexagon Manufacturing Intelligence – Metrology Software, Inc. All Rights Reserved.