hexagon logo

Learning coding

Where did you all learn coding?

I have one very basic code that was mainly copied from on here but I want to do more. So where did everyone learn this? Coworkers, books, Google, YouTube, classes, guy in a van down by the river??? What reading materials/websites/videos/classes/guys in vans by rivers would you recommend? I am going to take the free (until June) "VB.Net for PC-DMIS 301" class online probably this weekend. I see what you guys are having DMIS do with coding and I see how it can greatly help here at my job so I want to learn as much as I can. I'm the kind of person that is thirsty for knowledge and can't learn enough. My boss has had conversations with the owner and myself about sending me to classes at the local community college and they are all for it but that's on hold until this virus blows over.

Any recommendations you guys have are greatly appreciated.
  • Learning has to be fun. Coding is like learning to speak a new language or playing an instrument. Hearing someone play violin or reading a book on it isn't enough to pick up one up and play music. It takes doing and practice, practice, practice! Start small and work your way up to harder projects. For me the fastest thing was to familiarize myself with code syntactically, learning where to use it or where to apply or how a computer works took a bit longer.

    Learning code has been a lonely road for me, I never met anyone else that could mentor me. Google/YouTube played a major part in the beginning, they paved the way to learn enough to go to a book store and have the ability to recognize a 'good' book. Second, forums and the people therein, they're amazing, though don't ever attempt to force someone to hold your hand, do your homework (StackOverflow folks are ruthless! haha). Reading the developers manual/notes. Other people's code (it's everywhere). Make it a personal hobby and not just practice at work. Did I mention practice? Don't talk about it - it will cause your brain into thinking you're doing something productive but you're just chomping at the gums, instead refrain and unleash your desires (or whatever you want to call it) with more practice!

    EDIT: Oh and by the way "VB.Net for Pc-Dmis 301" I can't recommend enough! I took it shortly when it became available.
  • Hi,
    I think to have Coworkers who can teach coding is the best what could happen. In my case, the most helpful was this forum and PC DMIS help files (for functions). Now the important thing for me is to have a clear task of what I need to do and the second important thing was the recognition of useful possibilities of what I can do. The first idea of ​​coding was to write a script which should calculate general tolerances of dimensions depending on dimension size. By trying to get an idea how to write that script I searched info in this forum and in the same time I found other useful possibilities what I can do. First of those possibilities was a script for export data to excel, I found a script which working and have potency. Then I played and played and played on a script for export to excel, to get the best of what I could imagine, for info I always returned to this forum. To idea about script calculating general tolerances I returned maybe after 6 months and after few finished other scripts. I am sure, in this case learning for learning not the best thing to do.
  • At university I took one class which taught VB6. It was pretty basic (no pun intended) but just being able to drag and drop controls onto a form and then do simple stuff (add items to a list box, change the text of a label depending on which radio button was clicked etc) was an eye opener.

    I then did a work placement and worked closely with the IT guy who was great with Excel (among other things) and then I learnt I could combine the two with Macros (VBA).

    I also did a great class on databases (in which we didn't even touch a computer once!) - probably one of the most important classes I ever took.

    I continued with this (VB6/VBA and databases) through a range of temp jobs after Uni and in my first engineering job, then when I went to work for Hexagon I took over VB duties for PC-Dmis related stuff.

    Apart from one class it's all self taught, however I think working with automating a piece of software you already know (like automating PC-Dmis or Excel) is a great way of learning, as you're already familiar with the objects (part programs, commands, or workbooks or worksheets etc) so it makes getting your head round objects and methods and properties much easier.

  • Ok, I just finished the Automating PC-DMIS online course... Where should I go next to learn more about how to use this with DMIS?
  • Ok, I just finished the Automating PC-DMIS online course... Where should I go next to learn more about how to use this with DMIS?


    A fun one for me was to re-create a scripts that floating around here somewhere that takes all programs in a directory and reads all of the probes used and tips for each one. I adopted to use as much Object Oriented Programming as I could, what a blast!

    I would create small checker/helper programs to assist you in developing part routines... think of the one thing you always forget to do when writing Pc-Dmis part programs.... like forgetting to change that pesky default tolerance you forgot to correct.

    Another would be to figure out how to send arguments to console applications and/or how to fire console .exe from within Pc-Dmis.


  • A fun one for me was to re-create a scripts that floating around here somewhere that takes all programs in a directory and reads all of the probes used and tips for each one. I adopted to use as much Object Oriented Programming as I could, what a blast!

    I would create small checker/helper programs to assist you in developing part routines... think of the one thing you always forget to do when writing Pc-Dmis part programs.... like forgetting to change that pesky default tolerance you forgot to correct.

    Another would be to figure out how to send arguments to console applications and/or how to fire console .exe from within Pc-Dmis.


    Do you have some examples on here that you can point me to? We are incredibly slow so my boss is letting me spend as much training time as I want, just what I needed to start learning this.
  • One major improvement with automating PCDMIS I learned along the way was using a "BackgroundWorker" (there are other ways to accomplish this as well) to execute certain tasks. One thing you'll eventually notice is that when you hit a button and the buttons "freeze" until the code block(s) finish executing, running a part program for example.

    Below is an example of launching pcdmis with a BackgroundWorker. I just copied and pasted this so if you have a question about what something is let me know

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using PCDLRN;
    using Microsoft.VisualBasic;
    using System.Diagnostics;
    using System.IO.Compression;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.ComponentModel;
    using System.Windows.Interop;
    
    namespace PCD_Operator_App
    {
        /// <summary>
        /// Interaction logic for LoadScreen.xaml
        /// </summary>
        public partial class LoadScreen : Window
        {
            private const int GWL_STYLE = -16;
            private const int WS_SYSMENU = 0x80000;
    
            [DllImport("user32.dll", SetLastError = true)]
            private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
    
            [DllImport("user32.dll")]
            private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    
            public LoadScreen()
            {
                InitializeComponent();
    
                BackgroundWorker backgroundStartup = new BackgroundWorker();
                backgroundStartup.WorkerReportsProgress = true;
                backgroundStartup.DoWork += startup_DoWork;
                backgroundStartup.ProgressChanged += startup_ProgressChanged;
                backgroundStartup.RunWorkerCompleted += startup_RunWorkerCompleted;
                backgroundStartup.RunWorkerAsync();
            }
            void startup_DoWork(object sender, DoWorkEventArgs e)
            {
                bool startCondition = true;
    
                Process[] pcdStartupCheck = Process.GetProcessesByName("PCDLRN");
                if (pcdStartupCheck.Length > 0)
                {
                    startCondition = false;
                }
                else
                {
                    Type PCDRLN_Application = null;
                    object PCDObj = null;
    
                    PCDLRN.Application PCDApp = null;
    
                    try
                    {
                        PCDRLN_Application = Type.GetTypeFromProgID("PCDLRN.Application");
    
                        PCDObj = Activator.CreateInstance(PCDRLN_Application);
                    }
                    catch (System.Exception em)
                    {
                        MessageBox.Show(em.Message);
                    }
    
                    PCDApp = new PCDLRN.Application();
    
                    PCDApp.OperatorMode = true;
    
                    PCDApp.Visible = false;
    
                    PCDApp.ApplicationEvents.OnMachineConnected += new IApplicationEvents_OnMachineConnectedEventHandler(onMachineConnect);
    
                    void onMachineConnect(Machine machine)
                    {
                        //MessageBox.Show("machine connected");
                        //loadScreenStatus.Content = "PC-DMIS active, connecting to machine...";
    
                        startCondition = false;
                    }
    
                    if (startCondition)
                    {
                        WindowSearcher homeWindowSearch = new WindowSearcher();
                        homeWindowSearch.BeginWindowLook_Home();
                    }
                }
            }
    
            void startup_ProgressChanged(object sender, ProgressChangedEventArgs e)
            {
                
            }
    
            void startup_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
            {
                new MainWindow().Show();
    
                this.Close();
            }
    
            private void WindowLoaded(object sender, RoutedEventArgs e)
            {
                var hwnd = new WindowInteropHelper(this).Handle;
                SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
            }
        }
    }
    
    
  • One major improvement with automating PCDMIS I learned along the way was using a "BackgroundWorker" (there are other ways to accomplish this as well) to execute certain tasks. One thing you'll eventually notice is that when you hit a button and the buttons "freeze" until the code block(s) finish executing, running a part program for example.

    Below is an example of launching pcdmis with a BackgroundWorker. I just copied and pasted this so if you have a question about what something is let me know

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using PCDLRN;
    using Microsoft.VisualBasic;
    using System.Diagnostics;
    using System.IO.Compression;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.ComponentModel;
    using System.Windows.Interop;
    
    namespace PCD_Operator_App
    {
    /// <summary>
    /// Interaction logic for LoadScreen.xaml
    /// </summary>
    public partial class LoadScreen : Window
    {
    private const int GWL_STYLE = -16;
    private const int WS_SYSMENU = 0x80000;
    
    [DllImport("user32.dll", SetLastError = true)]
    private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
    
    [DllImport("user32.dll")]
    private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    
    public LoadScreen()
    {
    InitializeComponent();
    
    BackgroundWorker backgroundStartup = new BackgroundWorker();
    backgroundStartup.WorkerReportsProgress = true;
    backgroundStartup.DoWork += startup_DoWork;
    backgroundStartup.ProgressChanged += startup_ProgressChanged;
    backgroundStartup.RunWorkerCompleted += startup_RunWorkerCompleted;
    backgroundStartup.RunWorkerAsync();
    }
    void startup_DoWork(object sender, DoWorkEventArgs e)
    {
    bool startCondition = true;
    
    Process[] pcdStartupCheck = Process.GetProcessesByName("PCDLRN");
    if (pcdStartupCheck.Length > 0)
    {
    startCondition = false;
    }
    else
    {
    Type PCDRLN_Application = null;
    object PCDObj = null;
    
    PCDLRN.Application PCDApp = null;
    
    try
    {
    PCDRLN_Application = Type.GetTypeFromProgID("PCDLRN.Application");
    
    PCDObj = Activator.CreateInstance(PCDRLN_Application);
    }
    catch (System.Exception em)
    {
    MessageBox.Show(em.Message);
    }
    
    PCDApp = new PCDLRN.Application();
    
    PCDApp.OperatorMode = true;
    
    PCDApp.Visible = false;
    
    PCDApp.ApplicationEvents.OnMachineConnected += new IApplicationEvents_OnMachineConnectedEventHandler(onMachineConnect);
    
    void onMachineConnect(Machine machine)
    {
    //MessageBox.Show("machine connected");
    //loadScreenStatus.Content = "PC-DMIS active, connecting to machine...";
    
    startCondition = false;
    }
    
    if (startCondition)
    {
    WindowSearcher homeWindowSearch = new WindowSearcher();
    homeWindowSearch.BeginWindowLook_Home();
    }
    }
    }
    
    void startup_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
    
    }
    
    void startup_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
    new MainWindow().Show();
    
    this.Close();
    }
    
    private void WindowLoaded(object sender, RoutedEventArgs e)
    {
    var hwnd = new WindowInteropHelper(this).Handle;
    SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
    }
    }
    }
    
    


    Um... yeah... I question all of it. This is my first time getting into any kind of programming except programming part programs in DMIS. Maybe I should have them send me to the local community college for classes.


  • Um... yeah... I question all of it. This is my first time getting into any kind of programming except programming part programs in DMIS. Maybe I should have them send me to the local community college for classes.


    I bought a book here that got me started, I liked it a lot. Answered a lot of questions not regarding pc-dmis. Now that I've taken a few college level courses in coding, a lot of them follow these books very closely. Learning this will start to happen much quicker as you go along, like putting a puzzle together

    https://www.amazon.com/Microsoft-Visual-Step-Developer-Reference/dp/1509307761/ref=asc_df_1509307761/?tag=hyprod-20&linkCode=df0&hvadid=312125971120&hvpos=&hvnetw=g&hvrand=56322634205378343&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9016977&hvtargid=pla-527352025378&psc=1&tag=&ref=&adgrpid=61316180839&hvpone=&hvptwo=&hvadid=312125971120&hvpos=&hvnetw=g&hvrand=56322634205378343&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9016977&hvtargid=pla-527352025378


  • I have a few books downloaded that I am going through and I will give this book a look too. Is there anywhere I can find things specific to DMIS?