Your Products have been synced, click here to refresh
So I retired as of last July, but had all this stuff about PC-Dmis Automation which I've finally got around to uploading. Don't know it it is of any interest, but here it is.
The zip file has to Visual Studio project folders, both written in C#. One folder is a Class Library which has all the code for connecting with and dynamically interacting with PC-Dmis. The second folder is a C# application with uses the Class Library to connect and interact with PC-Dmis.
I also included two documents one explains how to setup the two Projects the other is about the application program.
Rather than trying to anticipate every possible question, the provided documents should be sufficient for someone familiar with visual studio and C#. Otherwise, I'll watch for questions to show up here. I can't promise to answer every question, given the complexity of what the answer might require. But I have taken phone calls and zoom opens up the possibility to demo live.
Good Luck
https://drive.google.com/drive/folders/1EDMe0GvN6TC_0Fcr_7Zt7_UqH-EV_8o2?usp=sharing
public Mainform() { InitializeComponent(); // Turn off the menu strip till PC-Dmis has started. DmisMenuStrip.Enabled = false; HomeDir = Application.StartupPath; xmlFile = HomeDir + @"\DmisMenuData.xml"; // Display the Main Form Title this.Text = "Project Action Mananger Version " + Settings.Default.Version; // Start Pcdmis InitializePcdmis(); // DataSet ReadData(); UpDateProgramList(); UpdateToolMenu(); }
1 string PcdmisVersion = Settings.Default.PcdmisVersion; 2 try 3 { 4 CMMsession = new PcdmisHelper(ExternalToInternalVersion(PcdmisVersion)); 5 } 6 catch (Exception e) 7 { 8 String message = e.Message; 9 MessageBox.Show("Incorrect Version of PCDMIS or PCDMIS not found.", 10 "PCDMIS not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 11 return; 12 }
1 try // to startup and connect with PC-Dmis 2 { 3 CMMsession.ConnectPCDLRN(); 4 } 5 catch (NoRegistryException e) 6 { 7 String message = e.Message; 8 MessageBox.Show(message, "Connection Error - Check Help->PCDLRN Info", 9 MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 10 return; 11 }
1 /// <summary> 2 /// This method starts the PCDMIS/PCDLRN CMM session in the background and 3 /// establishes a connection with the running PCDLRN session. The session is 4 /// running on a thread separate from the user DotNet application. 5 /// </summary> 6 public void ConnectPCDLRN() 7 { 8 if (!IsSessionActive) 9 { 10 Func<Boolean> method = Connect; 11 method.BeginInvoke(ConnectionDone, method); 12 } 13 else 14 { 15 . 16 . Code removed for brevity. 17 . 18 } 19 }
1 /* execute this method to make connection to the PCDLRN. */ 2 private Boolean Connect() 3 { 4 Type comType; 5 Object comObj; 6 try 7 { 8 pcdSession = null; 9 // Make sure the PCDLRN process is not already running. 10 Process[] PCDLRN_List = Process.GetProcessesByName("PCDLRN"); 11 foreach (Process exe in PCDLRN_List) 12 { 13 exe.Kill(); 14 } 15 //PCDMIS_CLSID = getCLSID_RegisterValue(); 16 comType = Type.GetTypeFromCLSID(Guid.Parse(PCDMIS_CLSID), true); 17 comObj = Activator.CreateInstance(comType); 18 pcdSession = comObj as PCDLRN.Application; 19 return IsSessionActive; 20 } 21 catch (Exception e) 22 { 23 ExceptionMessages = ExceptionMessages + "Problems starting PCDLRN CLSID " + 24 PCDMIS_CLSID + "\n" + e.Message; 25 } 26 return false; 27 }
1 /// <summary> 2 /// Make the Pcdmis session visable. 3 /// </summary> 4 public bool Visible 5 { 6 get { if (pcdSession != null) return pcdSession.Visible; return false; } 7 set { if (pcdSession != null) pcdSession.Visible = value; } 8 }
1 private void btnPcdmisWindow_Click(object sender, EventArgs e) 2 { 3 if (CMMsession.Visible == true) 4 { 5 CMMsession.Visible = false; 6 return; 7 } 9 CMMsession.Visible = true; }
/// <summary> Opens a new Pcdmis subprogram </summary> /// <remarks> /// The opened subprogram is ready to have assignments, tolerances and /// points written into it by the user DotNet application. /// </remarks> /// <param name="subName">Name of subprogram without path or extension.</param> /// <returns> /// Returns a PcdmisSubProgram object that has methods for writing to /// the Pcdmis subprogram. /// </returns> public PcdmisSubProgram CreateSubroutineProgram(string subName) { if (SessionIsAvailable) { try { this.CloseAll(); } catch (Exception ex) { ExceptionMessages = ExceptionMessages + ex.Message; } // Make sure the original is deleted before initializing a new subprogram. PurgeSubProgram(subName); pcdPartProgram = pcdPartPrograms.Add(AppProgSubrName(subName), PCDLRN.UNITTYPE.MM, pcdDefaultMachine, DefaultProbeName); return new PcdmisSubProgram(pcdPartProgram, subName); } return null; }
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |