示例#1
0
        /// <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);
            }
        }
示例#2
0
 /// <summary>
 /// Query the eMServer fields
 /// </summary>
 /// <param name="emsCacheManager">Cache manager for emServer fields</param>
 /// <param name="index">The string indexer, normally "wpMfgLibrary"</param>
 /// <param name="attribute">The attribue for setting on eMServer cached field</param>
 /// <param name="planningObject">The planning object, here it is the MfgLibrary</param>
 /// <param name="collection">The collection with required objects, in this case the mfg names</param>
 private static void QueryEmsCache(TxEmsCacheManager emsCacheManager, string index, string attribute, ITxPlanningObject planningObject, TxObjectList collection)
 {
     emsCacheManager.Clear();
     emsCacheManager[index].SetAttributes(attribute);
     if (planningObject != null && collection == null)
     {
         emsCacheManager[index].SetRootObject(planningObject);
     }
     else if (planningObject == null && collection != null)
     {
         emsCacheManager[index].SetRootObjects(collection);
     }
     emsCacheManager.CacheData();
 }
示例#3
0
        /// <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);
            }
        }