コード例 #1
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                CoordinateSystem wcs = theSession.Parts.Work.WCS.CoordinateSystem;
                Matrix4          mat = new Matrix4();
                mat.Identity();
                mat.TransformToCsys(wcs, ref mat);
                Component ct     = selectionBody.GetSelectedObjects()[0] as Component;
                Part      parent = ct.Parent.Prototype as Part;
                if (!parent.Equals(workPart))
                {
                    PartUtils.SetPartWork(ct.Parent);
                }
                AssmbliesUtils.MoveCompPartForCsys(mat, ct);
                PartUtils.SetPartWork(null);
                if (points.Count > 0)
                {
                    DeleteObject.Delete(points.ToArray());
                }
                CsysUtils.SetWcsToAbs();
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
コード例 #2
0
        public NXObject Move(params NXObject[] objs)
        {
            if (user.UserSucceed && user.Jurisd.GetComm())
            {
                List <NXOpen.Assemblies.Component> cts = new List <NXOpen.Assemblies.Component>();

                foreach (NXObject obj in objs)
                {
                    if (obj is NXOpen.Assemblies.Component)
                    {
                        cts.Add(obj as NXOpen.Assemblies.Component);
                    }
                }
                Matrix4 mat = new Matrix4();
                mat.Identity();
                mat.TransformToCsys(csys, ref mat);
                try
                {
                    AssmbliesUtils.MoveCompPartForCsys(mat, cts.ToArray());
                    return(null);
                }
                catch (NXException ex)
                {
                    UI.GetUI().NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "无法移动--" + ex.Message);
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }