/// <summary>
 /// Execute the frame creation process
 /// </summary>
 /// <param name="obj">Not in use</param>
 private void FrameCreationExecuted(object obj)
 {
     if (ReferenceFrame != null && ReferenceFrame != originalFrame)
     {
         TxApplication.ActiveDocument.WorkingFrame = ReferenceFrame;
     }
     try
     {
         foreach (RwFrameCreationViewModel frameViewModel in FramesData)
         {
             TxTransformation    location          = RwMathUtilities.CreateRpyTransformation(frameViewModel.X, frameViewModel.Y, frameViewModel.Z, frameViewModel.Rx, frameViewModel.Ry, frameViewModel.Rz, true);
             TxFrameCreationData frameCreationData = new TxFrameCreationData(frameViewModel.Name, location);
             TxApplication.ActiveDocument.PhysicalRoot.CreateFrame(frameCreationData);
         }
         string message = $"Successsfully created {FramesData.Count} frames";
         TxMessageBox.Show(message, "Frame creation", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
     }
     catch
     {
         string message = "An error occured during frame creation";
         TxMessageBox.Show(message, "Frame creation", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
     finally
     {
         TxApplication.ActiveDocument.WorkingFrame = originalFrame;
     }
 }
示例#2
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);
            }
        }
 /// <summary>
 /// Execute the frame creation process
 /// </summary>
 /// <param name="obj">Not in use</param>
 private void FrameCreationExecuted(object obj)
 {
     if (ReferenceFrame != null && ReferenceFrame != originalFrame)
     {
         TxApplication.ActiveDocument.WorkingFrame = ReferenceFrame;
     }
     try
     {
         foreach (RwFrameCreationData frameData in FramesData)
         {
             //TxVector translation = new TxVector(frameData.X, frameData.Y, frameData.Z);
             //TxVector rotation = new TxVector(RwMath.Deg2Rad(frameData.Rx), RwMath.Deg2Rad(frameData.Ry), RwMath.Deg2Rad(frameData.Rz));
             //TxTransformation location = new TxTransformation(translation, rotation, TxTransformation.TxRotationType.RPY_XYZ);
             TxTransformation    location          = RwMath.CreateRpyTransformation(frameData.X, frameData.Y, frameData.Z, frameData.Rx, frameData.Ry, frameData.Rz, true);
             TxFrameCreationData frameCreationData = new TxFrameCreationData(frameData.Name, location);
             TxApplication.ActiveDocument.PhysicalRoot.CreateFrame(frameCreationData);
         }
         string message = $"Successsfully created {FramesData.Count} frames";
         TxMessageBox.Show(message, "Frame creation", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
     }
     catch
     {
         string message = "An error occured during frame creation";
         TxMessageBox.Show(message, "Frame creation", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
     finally
     {
         TxApplication.ActiveDocument.WorkingFrame = originalFrame;
     }
 }
示例#4
0
 /// <summary>
 /// Read the name of the manufacturing features of the import list
 /// </summary>
 private void ReadMfgData()
 {
     try
     {
         string[] mfgData = System.IO.File.ReadAllLines(SourceFilename);
         if (mfgData != null && mfgData.Length > 0)
         {
             foreach (string name in mfgData)
             {
                 MfgCollection.Add(name);
             }
         }
     }
     catch
     {
         TxMessageBox.Show("Error in reading import file", "Mfg import", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }
示例#5
0
 /// <summary>
 /// Write the mfg collection to the target file
 /// </summary>
 /// <param name="obj">Not in use</param>
 private void ExportMfgsExecuted(object obj)
 {
     try
     {
         using (StreamWriter file = new StreamWriter(TargetFilename))
         {
             foreach (TxMfgFeature mfg in Mfgs)
             {
                 file.WriteLine(mfg.Name);
             }
         }
         string message = $"Successsfully saved Manufacturing features to file {TargetFilename}";
         TxMessageBox.Show(message, "Mfg export", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
     }
     catch
     {
         string message = "An error occured during Mfg export";
         TxMessageBox.Show(message, "Mfg export", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }
示例#6
0
 /// <summary>
 /// Execute the pick event on a selected planning object
 /// </summary>
 /// <param name="obj">The control of the UI</param>
 private void MfgLibraryPickedExecuted(object obj)
 {
     try
     {
         isSelectedPlanningObjectValid = false;
         if (obj is TxObjEditBoxControl control)
         {
             planningObject = control.Object as ITxPlanningObject;
             if (planningObject != null)
             {
                 if (planningObject.PlanningType.Equals("PmMfgLibrary"))
                 {
                     isSelectedPlanningObjectValid = true;
                 }
             }
         }
     }
     catch (TxPlanningObjectNotLoadedException exception)
     {
         TxMessageBox.Show($"{exception.Message}", "Mfg import - Exception", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
     }
 }
示例#7
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);
            }
        }