/// <summary> /// Load the manufacturing features by their name to the study /// </summary> private void LoadMfgByName() { TxObjectList mfgsToLoad = new TxObjectList(); TxEmsCacheManager emsCacheManager = new TxEmsCacheManager(); QueryEmsCache(emsCacheManager, "wpMfgLibrary", "children", planningObject, null); TxObjectList mfgsInLibrary = planningObject.GetField("children") as TxObjectList; QueryEmsCache(emsCacheManager, "wpMfgLibrary", "name", null, mfgsInLibrary); foreach (ITxPlanningObject mfg in mfgsInLibrary) { string name = mfg.GetField("name") as string; if (MfgCollection.Contains(name)) { mfgsToLoad.Add(mfg); } } if (mfgsToLoad.Count > 0) { TxDocumentEx document = new TxDocumentEx(); document.LoadComplete(mfgsToLoad, true); TxMessageBox.Show($"{mfgsToLoad.Count} Mfgs loaded!", "Mfg import", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { TxMessageBox.Show("No wanted Mfgs found in library", "Mfg import", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
/// <summary> /// Load the manufacturing features by their name to the study /// </summary> private void LoadMfgByName() { /* * Thanks to Siemens API Team for the support * https://community.plm.automation.siemens.com/t5/Tecnomatix-Developer-Forum/Tx13-0-Import-Mfg/m-p/519783#M1240 */ TxObjectList mfgsToLoad = new TxObjectList(); TxEmsCacheManager emsCacheManager = new TxEmsCacheManager(); QueryEmsCache(emsCacheManager, "wpMfgLibrary", "children", planningObject, null); TxObjectList mfgsInLibrary = planningObject.GetField("children") as TxObjectList; QueryEmsCache(emsCacheManager, "wpMfgLibrary", "name", null, mfgsInLibrary); foreach (ITxPlanningObject mfg in mfgsInLibrary) { string name = mfg.GetField("name") as string; if (MfgCollection.Contains(name)) { mfgsToLoad.Add(mfg); } } if (mfgsToLoad.Count > 0) { TxDocumentEx document = new TxDocumentEx(); document.LoadComplete(mfgsToLoad, true); TxMessageBox.Show($"{mfgsToLoad.Count} Mfgs loaded!", "Mfg import", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { TxMessageBox.Show("No wanted Mfgs found in library", "Mfg import", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }