Beispiel #1
0
        private Point3d GetPoint()
        {
            Point temp = this.selectionPt;

            if (get_point.GetSelectedObjects().Length != 0)
            {
                if (get_point.GetSelectedObjects()[0] is Point)
                {
                    this.selectionPt = get_point.GetSelectedObjects()[0] as Point;
                    this.selectionPt.Highlight();
                }
                if (get_point.GetSelectedObjects()[0] is Face)
                {
                    Face face = get_point.GetSelectedObjects()[0] as Face;
                    face.Highlight();
                    if (this.selectionFace == null)
                    {
                        this.selectionFace = face;
                    }
                    else
                    {
                        if (this.selectionFace.Tag != face.Tag)
                        {
                            this.selectionFace.Unhighlight();
                            this.selectionFace = face;
                        }
                        else
                        {
                            this.selectionFace = null;
                        }
                    }
                }
            }
            else
            {
                this.selectionPt = temp;
            }
            if (this.selectionPt != null)
            {
                if (this.selectionFace == null)
                {
                    return(this.selectionPt.Coordinates);
                }
                else
                {
                    return(moveObjectBasic.GetPointToFaceDis(this.selectionPt, this.selectionFace));
                }
            }
            return(new Point3d(0, 0, 0));
        }
Beispiel #2
0
        //------------------------------------------------------------------------------
        //Callback Name: update_cb
        //------------------------------------------------------------------------------
        public int update_cb(NXOpen.BlockStyler.UIBlock block)
        {
            try
            {
                if (block == addOrModify)
                {
                    //---------Enter your code here-----------
                    if (addOrModify.Value)
                    {
                        addOrModify.Label = "添加WORK";

                        string[] members = { "WORK" + (numbers[numbers.Count - 1] + 1).ToString() };
                        workNumber.Enable = false;
                        workNumber.SetEnumMembers(members);
                    }
                    else
                    {
                        addOrModify.Label = "修改WORK";
                        List <string> members = new List <string>();
                        foreach (int i in numbers)
                        {
                            members.Add("WORK" + i.ToString());
                        }
                        workNumber.Enable = true;
                        workNumber.SetEnumMembers(members.ToArray());
                    }
                }
                else if (block == workNumber)
                {
                    //---------Enter your code here-----------
                }
                else if (block == selePart)
                {
                    //---------Enter your code here-----------
                    Part            part     = (this.selePart.GetSelectedObjects()[0] as NXOpen.Assemblies.Component).Prototype as Part;
                    List <NXObject> partBody = new List <NXObject>();
                    foreach (Body body in part.Bodies)
                    {
                        partBody.Add(body);
                    }
                    this.moveObjectBasic = new MoveObjectBasic(partBody);
                    points = moveObjectBasic.CreatePoint();
                }
                else if (block == selePoint)
                {
                    if (selePoint.GetSelectedObjects().Length != 0)
                    {
                        TaggedObject obj = selePoint.GetSelectedObjects()[0];
                        //---------Enter your code here-----------
                        if (obj is Point)
                        {
                            this.selectionPt = obj as Point;
                        }
                        if (obj is Face)
                        {
                            this.selectionFace = obj as Face;
                        }
                        if (selectionPt != null)
                        {
                            Point3d temp;
                            if (selectionFace != null)
                            {
                                temp = moveObjectBasic.GetPointToFaceDis(selectionPt, selectionFace);
                            }
                            else
                            {
                                temp = selectionPt.Coordinates;
                            }
                            CsysUtils.SetWcsOfCentePoint(temp);
                        }
                    }
                }
                else if (block == button_X)
                {
                    //---------Enter your code here-----------
                    CsysUtils.RotateWcs(WCS.Axis.XAxis, 90);
                }
                else if (block == button_Y)
                {
                    //---------Enter your code here-----------
                    CsysUtils.RotateWcs(WCS.Axis.YAxis, 90);
                }
                else if (block == button_Z)
                {
                    //---------Enter your code here-----------
                    CsysUtils.RotateWcs(WCS.Axis.ZAxis, 90);
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(0);
        }