Showing results for 
Search instead for 
Do you mean 
Reply

Reflecting the position and orientation of a component

I am attempting to reflect the position and orientation of a component across a plane. I'm using the GetPosition command to get the nessecary information from the component, and I am successfully mirroring the origin position of the component but am having issues with reflecting the orientation properly. Does anyone have any idea how to accomplish this? I've been looking at the UFTrns CreateReflectionMatrix command but I'm not sure how to implement it properly.

 

Dim cmpPosition As Point3d = Nothing
Dim cmpOrientation As Matrix3x3 = Nothing
cmpSelected.GetPosition(cmpPosition, cmpOrientation)

I feel like I am jumping through a lot of hoops to succesfully accomplish this, does anyone know of an easier command to accomplish this entire process?

DHuskic Nx 9
4 REPLIES

Re: Reflecting the position and orientation of a component

Are you trying to mirror a component or create a mirror body?  How would you do it interactively in NX?

 

Re: Reflecting the position and orientation of a component

When you record a journal of the manual process, you should be able to use this as a hint to success.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Reflecting the position and orientation of a component

I can mirror the body through the GeoCopyBuilder and a plane, but I'm trying to figure out how to use the UFTRNS to reflect the matrix. Since this is dealing with actual matrix3x3 objects, I'm not sure how I would attempt this interactively.

DHuskic Nx 9

Re: Reflecting the position and orientation of a component

See below example C# code that selects a line and mirrors it through another line.

 

using System;
using NXOpen;
using NXOpen.UF;

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

    //------------------------------------------------------------------------------
    // Constructor
    //------------------------------------------------------------------------------
    public Program()
    {
        try
        {
            theSession = Session.GetSession();
            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 

            NXObject objToMirror = null;
            NXObject mirrorLine = null;

            double[] matrix = new double[12] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            objToMirror = select_obj("Select Line to Mirror");
            if (objToMirror != null)
            {
                mirrorLine = select_obj("Select Line to Mirror Through");
                if (mirrorLine != null)
                {
                    int status;
                    Tag theMirrLine = mirrorLine.Tag;
                    Tag[] theObjs = new Tag[1];
                    theObjs[0] = objToMirror.Tag;
                    int nObjs = theObjs.Length;
                    Tag[] copiedObjs = new Tag[1];
                    Tag traceCurves = Tag.Null;
                    int move_or_copy = 2;
                    int dest_Layer = 0;
                    int trace_status = 2;

                    theUfSession.Trns.CreateReflectionMatrix(ref theMirrLine, matrix, out status);
                    theUfSession.Trns.TransformObjects(matrix, theObjs, ref nObjs, ref move_or_copy,  ref dest_Layer, ref trace_status, copiedObjs, out traceCurves, out status);

                }
            }

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

        }
        return retValue;
    }

    private static NXObject select_obj(string prompt)
    {
        UI theUI = UI.GetUI();
        NXObject selobj;
        Point3d cursor;
        Selection.MaskTriple[] mask = new Selection.MaskTriple[1];

        mask[0].Type = UFConstants.UF_line_type;
        mask[0].Subtype = 0;
        mask[0].SolidBodySubtype = 0;

        Selection.Response resp = theUI.SelectionManager.SelectObject("Select " + prompt, prompt,
            Selection.SelectionScope.WorkPart, Selection.SelectionAction.ClearAndEnableSpecific, false, false, mask, out selobj, out cursor);

        if (resp == Selection.Response.ObjectSelected ||
                resp == Selection.Response.ObjectSelectedByName)
        {
            return selobj;
        }
        else
            return null;

    }

    //------------------------------------------------------------------------------
    // 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)
    {
        return System.Convert.ToInt32(Session.LibraryUnloadOption.AtTermination);
    }

}