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

How to identify face class type face while using the face select?

Hello! 

 

I am looking for a way to change the face type face while using the face select(Block UI).

I'm using  VS C#.

 

Is there any example code for me to look at?

 

Thanks a lot.

6 REPLIES

Re: How to identify face class type face while using the face select?

So you want to be able to filter by the type of face (planar, cylindrical, conical, spherical, bsurf,  etc.)?

 

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: How to identify face class type face while using the face select?

Hi

 

I want to use the AskFaceParm(Tag face_id,double[] ref_pnt,double[] parm,double[] face_pnt) function.

I use the BLOCK UI face select funtion to get the Tag  face_id (face_select.tag), but face_select.tag can't use for the Tag  face_id, so i want to know how to slove this problem.

 

Thanks.

Re: How to identify face class type face while using the face select?

The face selector returns tagged objects.  You need to pass the ".Tag" of that object to AskFaceParm function.

 

Re: How to identify face class type face while using the face select?

About the ".Tag" of that object to AskFaceParm function.

Could you show me an example? 

 

Thanks.

Solution
Solution
Accepted by topic author AaronPan
‎06-24-2016 02:01 AM

Re: How to identify face class type face while using the face select?

Below is the working code in C#.

 

using System;
using NXOpen;
using NXOpen.UF;

public class Program
{
    // class members
    private static Session theSession;
    private static UI theUI;
    private static UFSession theUfSession;
    public static Program theProgram;
    public static bool isDisposeCalled;

    //------------------------------------------------------------------------------
    // Constructor
    //------------------------------------------------------------------------------
    public Program()
    {
        try
        {
            theSession = Session.GetSession();
            theUI = UI.GetUI();
            theUfSession = UFSession.GetUFSession();
            isDisposeCalled = false;
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----
            // UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
        }
    }

    //------------------------------------------------------------------------------
    //  Explicit Activation
    //      This entry point is used to activate the application explicitly
    //------------------------------------------------------------------------------
    public static int Main(string[] args)
    {
        int retValue = 0;
        try
        {
            theProgram = new Program();

            //TODO: Add your application code here 
            
            Face theFace = null;

            while ((theFace = SelectFace("Select a Face")) != null)
            {
                int type;
                double[] center = new double[3];
                double[] dir = new double[3];
                double[] box = new double[6];
                double radius;
                double rad_data;
                int norm_dir;

                theUfSession.Modl.AskFaceData(theFace.Tag, out type, center, dir, box, 
                    out radius, out rad_data, out norm_dir);

                double[] parm = new double[2];
                double[] point1 = new double[3];

                theUfSession.Modl.AskFaceParm(theFace.Tag, center, parm, point1);

                theSession.ListingWindow.Open();
                theSession.ListingWindow.WriteLine("Face parameter at U=" + parm[0].ToString() +
                    "   Face parameter at V=" + parm[1].ToString());

            }

            


            theProgram.Dispose();
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----

        }
        return retValue;
    }

    public static Face SelectFace(string prompt)
    {
        NXObject selobj = null;
        Point3d cursor = default(Point3d);
        Selection.MaskTriple[] mask = { new Selection.MaskTriple(NXOpen.UF.UFConstants.UF_solid_type, 0, NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_ANY_FACE) };

        Selection.Response resp = UI.GetUI().SelectionManager.SelectObject(prompt, "Select a face",
            Selection.SelectionScope.WorkPart, Selection.SelectionAction.ClearAndEnableSpecific, false, false, mask, out selobj, out cursor);

        return (Face)selobj;
    }

    //------------------------------------------------------------------------------
    // Following method disposes all the class members
    //------------------------------------------------------------------------------
    public void Dispose()
    {
        try
        {
            if (isDisposeCalled == false)
            {
                //TODO: Add your application code here 
            }
            isDisposeCalled = true;
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----

        }
    }

    public static int GetUnloadOption(string arg)
    {
        //Unloads the image explicitly, via an unload dialog
        //return System.Convert.ToInt32(Session.LibraryUnloadOption.Explicitly);

        //Unloads the image immediately after execution within NX
        return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately);

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

}

 

Re: How to identify face class type face while using the face select?

Hi Technisites.
I am sorry for my late reply to you.

According to your example, I can solve this question.
Thanks for your information.