Exemplo n.º 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(NXObjectAooearancePoint.GetPointToFaceDis(this.selectionPt, this.selectionFace));
                }
            }
            return(new Point3d(0, 0, 0));
        }
Exemplo n.º 2
0
        //------------------------------------------------------------------------------
        //Callback Name: update_cb
        //------------------------------------------------------------------------------
        public int update_cb(NXOpen.BlockStyler.UIBlock block)
        {
            try
            {
                if (block == selePart)
                {
                    //---------Enter your code here-----------
                    TaggedObject[] obj = this.selePart.GetLastSelectedObjects();
                    if (obj.Length > 0)
                    {
                        this.seleCt = obj[0] as NXOpen.Assemblies.Component;

                        Part temp = (this.seleCt).Prototype as Part;
                        if (ParentAssmblieInfo.IsWork(temp))
                        {
                            WorkModel wk = new WorkModel(temp);
                            this.group.Show = true;
                            this.workNumber.SetEnumMembers(GetWorkpieceName(wk).ToArray());
                            selectPart = GetWorkPieceForWork(wk);
                        }
                        else
                        {
                            selectPart       = temp;
                            this.group.Show  = false;
                            this.group1.Show = true;
                            this.group2.Show = true;
                        }
                        List <Body> bodys = GetCompBodys(this.seleCt, selectPart);
                        if (bodys.Count > 0)
                        {
                            aoo         = new NXObjectAooearancePoint(bodys.ToArray());
                            this.points = aoo.CreatePoint();
                        }
                        this.selePoint.Enable = true;
                    }
                    else
                    {
                        this.selePoint.Enable = false;
                        selectPart            = null;
                        this.seleCt           = null;
                        DeleteObject.Delete(this.points.ToArray());
                        this.points.Clear();
                        this.selectPt   = null;
                        this.selectFace = null;
                        CsysUtils.SetWcsToAbs();
                    }
                }
                else if (block == addOrModify)
                {
                    //---------Enter your code here-----------
                    if (this.addOrModify.Value)
                    {
                        this.workNumber.Show = true;
                        if (this.points.Count > 0)
                        {
                            DeleteObject.Delete(this.points.ToArray());
                            this.points.Clear();
                        }

                        this.group2.Show = false;
                        this.group1.Show = false;
                    }
                    else
                    {
                        if (selectPart != null)
                        {
                            List <Body> bodys = GetCompBodys(this.seleCt, this.selectPart);
                            if (bodys.Count > 0)
                            {
                                aoo         = new NXObjectAooearancePoint(bodys.ToArray());
                                this.points = aoo.CreatePoint();
                            }
                        }
                        //  this.workNumber.Show = false;
                        this.group1.Show = true;
                        this.group2.Show = true;
                    }
                }
                else if (block == workNumber)
                {
                    //---------Enter your code here-----------
                }
                else if (block == selePoint)
                {
                    //---------Enter your code here-----------
                    if (selePoint.GetSelectedObjects().Length != 0)
                    {
                        TaggedObject obj = selePoint.GetSelectedObjects()[0];
                        //---------Enter your code here-----------
                        if (obj is Point)
                        {
                            this.selectPt = obj as Point;
                        }
                        if (obj is Face)
                        {
                            Face temp = obj as Face;
                            if (this.selectFace != null)
                            {
                                this.selectFace.Unhighlight();
                                if (this.selectFace.Equals(temp))
                                {
                                    this.selectFace = null;
                                }
                                else
                                {
                                    this.selectFace = temp;
                                }
                            }
                            else
                            {
                                this.selectFace = temp;
                            }
                            if (this.selectFace != null)
                            {
                                this.selectFace.Highlight();
                            }
                        }
                        if (selectPt != null)
                        {
                            Point3d temp;
                            if (selectFace != null)
                            {
                                temp = NXObjectAooearancePoint.GetPointToFaceDis(selectPt, selectFace);
                            }
                            else
                            {
                                temp = selectPt.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);
        }