Showing results for 
Search instead for 
Do you mean 
Solved! Go to solution

Warning for a different MCS


I don't have any experience with any kind of programming. Therefore I hope, that someone here on the forum can help me with the following problem.


When in Manufacturing application, MCS has to be defined in each operation. And each operation can have different MCS.
Operations can also be grouped. In most of the cases, grouped operations are using the same coordinated system, MCS.
Which MCS is used by the operation can be seen in the Operation Navigator-Program Order, if MCS column is turned on.
Which MCS is used for which operation can also be seen in Operation Navigator-Geometry.
If I click with RMB on any operation and select Information, I can also see the coordinates of MCS in use.


Now, one company is asking, if it is possible to create a macro, which will check those MCSs before post processing.

  1. the user would click on a group of operations. All the operations are selected
  2. then he would click on a new command, some macro 
  3. macro will give a report, that for example, most of the operations are defined with this MCS, and other operations are defined with different MCSs. For example, most of operations (1, 2 and 5) are created with MCS1. Operation 3 in defined with MCS2 and operation 4 is created with MCS3.

Is it possible to create a macro, that will give such report? Of course, if it is not to much work.


I will upload my Machinining example. Please don't check the correctness of the operations.Smiley Happy They are there just for the MCS purpose.
I will also upload the movie, that show, where MCS can be found/shown already.


I would appreciate any information. If it can not be done, it is OK. If it can be done and can be shared for free, also OK. And if has to be paid for such macro, it is also OK. Smiley Happy


Best Regards,



Re: Warning for a different MCS

I don't have a solution to post, but I can suggest some approaches.


If you do this in the post, there are mom variables available in start of program with the name of the MCS for each operation. The post could output these in the beginning.


Event 1: MOM_start_of_program
Var: mom_mcsname_attach_opr(FLOOR_WALL) = MCSAAA_MILL
Var: mom_mcsname_attach_opr(FLOOR_WALL_COPY) = MCSAAA_OTHER
Var: mom_operation_name_list = FLOOR_WALL FLOOR_WALL_COPY
Var: mom_invisible_mcs_array_size = 2
Var: mom_invisible_mcs_array[0] = MCSAAA_MILL
Var: mom_invisible_mcs_array[1] = MCSAAA_OTHER


To do this separately, you would need a vb journal that cycles through the selected operations or program group, and gets the MCS for each operation. Note that this is not always the imediate geometry parent.

Mark Rief
Retired Siemens

Re: Warning for a different MCS

Hello Mark,


Thanks for this suggestion. My colleague has tested this and it works quite nice.

There is only one problem.

Information about different MCS came onyl after the postprocessing. This can be a problem, if the postprocessing takes a lot of time. And only after that, you can see, that there is a different MCS. So, you have to change the MCS (if it is necessary) and go through the postprocessing again.


It would be nice, if this information can come before postprocessing starts. Maybe as a separate command (vb or similar). And after executing this command, the user decides, if he has to fix MCS problem or can go forward with postprocessing.


And about such macro. If it can be shared for free, OK. And if user has to buy it, it is also OK.



Accepted by topic author SvenBom
‎03-24-2016 06:42 AM

Re: Warning for a different MCS

Below is the code from solution center that reports MCS of the selected operations.  Copy paste the code in notepad and save as 'ReportMCS.cs'.  Select the operations in ONT and go to tools->journal->play journal and select the saved file.  It should report the MCS.


I cannot check this myself since I do not have a CAM license.



File description: Sample NX/Open Application
//     This Program Display Matrix and Origin Information for MCS of the Selected 
//     Operation.
//     NX Version : MP6

using System;
using NXOpen;
using NXOpen.UF;
using NXOpen.Utilities;
using NXOpen.Assemblies;
using NXOpen.CAM;

static class GetMCSFromOperation
    static Session theSession;
    static UFSession theUfSession;
    private static UI theUI;

    public static void Main()
        theSession = Session.GetSession();
        theUfSession = UFSession.GetUFSession();
        Part workPart = theSession.Parts.Work;
        theUI = UI.GetUI();

        if (workPart == null)
            UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, "A Part must be Opened.");


        if (!theSession.ListingWindow.IsOpen) theSession.ListingWindow.Open();

        SystemInfo(theUfSession.Part, workPart);

            int countObject = 0;

            Tag[] operTag;
            Tag setupTag = Tag.Null;

            theUfSession.Setup.AskSetup(out setupTag);

            if (setupTag == Tag.Null)
                UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, "No Cam Setup in this Part.");

            theUfSession.UiOnt.AskSelectedNodes(out countObject, out operTag);

            for (int i = 0; i < countObject; i++)
                int type, subType;

                theUfSession.Obj.AskTypeAndSubtype(operTag[i], out type, out subType);

                if (type == UFConstants.UF_machining_operation_type)
                    Operation operation = (Operation)(NXObjectManager.Get(operTag[i]));

                    if (GetMCSFromOper(operTag[i]) != Tag.Null)
                      CartesianCoordinateSystem cartesianCoordinateSystem = (CartesianCoordinateSystem)(NXObjectManager.Get(GetMCSFromOper(operTag[i])));
                      Point3d point3d = cartesianCoordinateSystem.Origin;
                      NXMatrix nXMatrix = cartesianCoordinateSystem.Orientation;
                      Matrix3x3 matrix3x3 = nXMatrix.Element;

                      theSession.ListingWindow.WriteLine("\nOperation : " + operation.Name);
                      theSession.ListingWindow.WriteLine("Origin    : X" + point3d.X.ToString() + " Y" + point3d.Y.ToString() + " Z" + point3d.Z.ToString());
                      theSession.ListingWindow.WriteLine("Matrix    :\n\tXx" + matrix3x3.Xx.ToString() + "\tXy" + matrix3x3.Xy.ToString() + "\tXz" + matrix3x3.Xz.ToString() +
                                                         "\n\tYx" + matrix3x3.Yx.ToString() + "\tXy" + matrix3x3.Yy.ToString() + "\tXz" + matrix3x3.Yz.ToString() +
                                                         "\n\tZx" + matrix3x3.Zx.ToString() + "\tZy" + matrix3x3.Zy.ToString() + "\tZz" + matrix3x3.Zz.ToString());
                    } /* if GetMCSFromOper */
                } /* if type */
            } /* for int i = 0 */
        } /* try */
        catch (NXOpen.NXException ex)
            UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);

    //             Method : GetMCSFromOper
    //  This Method Retrieve the MCS Tag of the Operation to Query
    //  Input Tag  : Input the Tag of the Operation to Query
    //  Return Tag : Return the Tag of the MCS where the Operation Inherit from
    public static Tag GetMCSFromOper(Tag operTag)
        int count = 0;
        int[] indices;

        Tag defTag = Tag.Null;
        Tag mcsTag = Tag.Null;

        UFParam.IndexAttribute attributes;

        theUfSession.Param.AskRequiredParams(operTag, out count, out indices);

        if (count > 0)
            for (int i = 0; i < count; i++)
                theUfSession.Param.AskParamAttributes(indices[i], out attributes);
                theUfSession.Param.AskParamDefiner(operTag, indices[i], out defTag);  /* If Parameters Tag are Needed */

                if (attributes.key == UFConstants.UF_PARAM_MCS)  /* uf_param_indices.h */
                    theUfSession.Param.AskTagValue(operTag, indices[i], out mcsTag);
                } /* if attributes */
            } /* for int i = 0 */
        } /* if count */

        return mcsTag;

    //             Method : SystemInfo
    //  Display System Information
    //  Input UFPart : The UF Part
    //  Input Part   : The Work Part
    //  Return       : None
    static void SystemInfo(UFPart uFPart, Part workPart)
        SystemInfo sysInfo;
        theUfSession.UF.AskSystemInfo(out sysInfo);

        string partName = string.Empty;
        uFPart.AskPartName(workPart.Tag, out partName);

        theSession.ListingWindow.WriteLine("Information Listing Created by : " + sysInfo.user_name.ToString());
        theSession.ListingWindow.WriteLine("Date                           : " + sysInfo.date_buf.ToString());
        theSession.ListingWindow.WriteLine("Current Work Part              : " + partName);
        theSession.ListingWindow.WriteLine("Node Name                      : " + sysInfo.node_name.ToString());

    //             Method : GetUnloadOption
    //  Unload the Current Image
    //  Input String : String Send by NX
    //  Return       : Integer
    public static int GetUnloadOption(string arg)
        return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately);

        //Unloads the image explicitly, via an unload dialog
        //return System.Convert.ToInt32(Session.LibraryUnloadOption.Explicitly);

        //Unloads the image when the NX session terminates
        //return System.Convert.ToInt32(Session.LibraryUnloadOption.AtTermination);

Re: Warning for a different MCS

Thanks for this journal. I have just tested and it works perfectly!


Thanks again to both of you for providing me with such a great solutions.