예제 #1
0
        /// <summary>
        /// 获取面的数据
        /// </summary>
        /// <param name="face"></param>
        /// <returns></returns>
        public static FaceData AskFaceData(Face face)
        {
            NXOpen.UF.UFSession uf = NXOpen.UF.UFSession.GetUFSession();

            int type;

            double[] point = new double[3];
            double[] dir   = new double[3];
            double[] box   = new double[6];
            double   radius;
            double   rad_data;
            int      norm_dir;

            uf.Modl.AskFaceData(face.Tag, out type, point, dir, box, out radius, out rad_data, out norm_dir);


            FaceData fd = new FaceData();

            fd.FaceType = type;

            //UVector dit = new UVector(dir[0], dir[1], dir[2]);
            //dit.Norm();

            fd.Dir = new Vector3d(dir[0], dir[1], dir[2]);

            fd.BoxMinCorner = new Point3d(box[0], box[1], box[2]);
            fd.BoxMaxCorner = new Point3d(box[3], box[4], box[5]);
            fd.Radius       = radius;
            fd.RadData      = rad_data;
            fd.IntNorm      = norm_dir;
            fd.Point        = new Point3d(point[0], point[1], point[2]);
            fd.Face         = face;
            return(fd);
        }
예제 #2
0
        public int CompareTo(FaceComparable other)
        {
            Edge[] thisArray  = this.face.GetEdges();
            Edge[] otherArray = other.face.GetEdges();

            NXOpen.UF.UFSession  ufsession = NXOpen.UF.UFSession.GetUFSession();
            NXOpen.UF.UFEval.Arc arc;

            IntPtr eval;

            ufsession.Eval.Initialize(thisArray[0].Tag, out eval);
            ufsession.Eval.AskArc(eval, out arc);
            double[] thiscenter1 = arc.center;

            ufsession.Eval.Initialize(otherArray[0].Tag, out eval);
            ufsession.Eval.AskArc(eval, out arc);
            double[] othercenter1 = arc.center;

            if (thiscenter1[0] > othercenter1[0])
            {
                return(1);
            }
            else if (thiscenter1[0] < othercenter1[0])
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
예제 #3
0
    //--------------------------------------------------------------------------
    // The main interface by which NX will start and stop the application
    //--------------------------------------------------------------------------


    // The main entry point. Called when this library is loaded

    public static void Main()
    {
        theSession   = Session.GetSession();
        theUFSession = UFSession.GetUFSession();
        theViewer    = new AssemblyViewer();
        theViewer.Show();
    }
예제 #4
0
    //------------------------------------------------------------------------------
    //  NX Startup
    //      This entry point activates the application at NX startup
    //
    //  Will work when complete path of the dll is provided to Environment Variable
    //  USER_STARTUP or USER_DEFAULT
    //------------------------------------------------------------------------------
    public static int Startup()
    {
        theSession   = Session.GetSession();
        theUFSession = UFSession.GetUFSession();
        theUI        = UI.GetUI();
        lw           = theSession.ListingWindow;

        theUI.MenuBarManager.RegisterConfigureContextMenuCallback(
            "ConfigureContextMenu.cs",
            "An example of context menu customization demonstrating various functions.",
            new NXOpen.MenuBar.MenuBarManager.ConfigureContextMenu(CustomizeMenu));

        return(0);
    }
예제 #5
0
파일: Face.cs 프로젝트: suifengsigan/TEST_1
        /// <summary>
        /// 获取BOX
        /// </summary>
        /// <param name="face"></param>
        /// <returns></returns>
        public static Snap.Geom.Box3d BoxEx(this Snap.NX.Face face)
        {
            int    surfaceType;
            double radius1;
            double radius2;
            int    normalFlip;

            double[] point = new double[3];
            double[] dir   = new double[3];
            double[] box   = new double[6];
            try
            {
                NXOpen.UF.UFSession uFSession = NXOpen.UF.UFSession.GetUFSession();
                uFSession.Modl.AskFaceData(face.NXOpenTag, out surfaceType, point, dir, box, out radius1, out radius2, out normalFlip);
                var faceBox = new Snap.Geom.Box3d(box[0], box[1], box[2], box[3], box[4], box[5]);
                return(faceBox);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(face.Box);
            }
        }
예제 #6
0
        static void Main(string[] args)
        {
            nxSession = Session.GetSession();
            ufSession = UFSession.GetUFSession();

            PartLoadStatus partLoadStatus1;
            //ArrayList tcad_PartList = new ArrayList();
            string fileName = args[0];

            //"D:\\UG_MACRO\\TEST MODEL\\Amodels\\A1\\Pre\\A1.prt";
            NXOpen.Part assemblyFilePart = nxSession.Parts.OpenDisplay(fileName, out partLoadStatus1);

            ASSEMBLY assemManager = new ASSEMBLY();

            assemManager.InitializeTransCAD();
            assemManager.loadAssemblyInfo(assemblyFilePart);

            int numConstraints = assemManager.nxConstraints.Length;
            List <CONSTRAINT> preConstraints = new List <CONSTRAINT>();

            //for each constraint
            for (int i = 0; i < numConstraints; i++)
            {
                NXOpen.Positioning.Constraint nxConstraint = assemManager.nxConstraints[i];

                Constraint.Type constraintType = nxConstraint.ConstraintType;
                System.Console.WriteLine(constraintType.ToString());

                ConstraintReference[] nxConstraintRefGeoms = nxConstraint.GetReferences();

                if (constraintType == Constraint.Type.Touch)
                {
                    //validation
                    if (nxConstraintRefGeoms.Length != 2)
                    {
                        System.Console.WriteLine("Touch Align Constraint should have only 2 reference geometries!");
                        continue;
                    }

                    //Coaxial

                    /*
                     * if (nxConstraintRefGeoms[0].GetUsesGeometryAxis() && nxConstraintRefGeoms[1].GetUsesGeometryAxis())
                     * {
                     *  preConstraints.Add(new CONSTRAINTCoaxial(nxConstraint, assemManager));
                     * }
                     */
                    //Incidence??
                    else
                    {
                        preConstraints.Add(new CONSTRAINTIncidence(nxConstraint, assemManager));
                    }
                }
                //coaxial-edge-based-fit-Constraint in NX
                else if (constraintType == Constraint.Type.Fit)
                {
                    preConstraints.Add(new CONSTRAINTCoaxial(nxConstraint, assemManager));
                }

                else if (constraintType == Constraint.Type.Fix)
                {
                }

                else if (constraintType == Constraint.Type.Distance)
                {
                }

                else if (constraintType == Constraint.Type.Angle)
                {
                }
            }

            //for each constraint
            for (int i = 0; i < preConstraints.Count(); i++)
            {
                preConstraints[i].getNXInfo();
            }
            //for each constraint
            for (int i = 0; i < preConstraints.Count(); i++)
            {
                preConstraints[i].toTransCAD();
            }
            assemManager.UninitializeTransCAD();
        }
예제 #7
0
 /**
  *  Constructor
  */
 private CustomMenuCreator()
 {
     m_MenuHandler = null;
     m_ufSession   = NXOpen.UF.UFSession.GetUFSession();
     m_ugMgr       = m_ufSession.Ugmgr;
 }