Пример #1
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----if (preview)
                if (preview)
                {
                    if (boolUnite.Value)
                    {
                        prtviewFeature.Add(CreateBooleanFeature());
                    }
                    if (boolPlane.Value)
                    {
                        prtviewFeature.AddRange(Trim(seleTags, superBox.ToolingBoxFeature.GetBodies()[0]));
                    }
                    if (boolHide.Value)
                    {
                        AskSelectParent().Unblank();
                    }
                }
                this.seleTags.Clear();
                this.prtviewFeature.Clear();
                superBox = null;
            }
            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
        //------------------------------------------------------------------------------
        //Callback Name: update_cb
        //------------------------------------------------------------------------------
        public int update_cb(NXOpen.BlockStyler.UIBlock block)
        {
            try
            {
                if (block == type)
                {
                    //---------Enter your code here-----------
                    if (superBox != null)
                    {
                        superBox.DeleToolingBoxFeatures();
                        superBox          = null;
                        bttPreview.Enable = false;
                    }
                    if (selectObject.GetSelectedObjects().Length != 0)
                    {
                        seleTags.Clear();
                        selectObject.SetSelectedObjects(seleTags.ToArray());
                    }
                    SetLinearDimensionShow(false);
                    negativeZ.Show = false;
                    positiveZ.Show = false;
                    radial.Show    = false;
                    SetUiInitialize();
                }
                else if (block == selectObject)
                {
                    //---------Enter your code here-----------
                    seleTags.Clear();
                    bttPreview.Enable = true;
                    foreach (TaggedObject to in selectObject.GetSelectedObjects())
                    {
                        seleTags.Add(to as NXObject);
                    }

                    if (superBox == null)
                    {
                        if (type.ValueAsString == "块")
                        {
                            superBox = new SuperBoxBlock(seleTags, blockOffset);
                            SetLinearDimensionShow(true);
                        }

                        else
                        {
                            superBox       = new SuperBoxCylinder(seleTags, cylinderOffset);
                            negativeZ.Show = true;
                            positiveZ.Show = true;
                            radial.Show    = true;
                        }

                        superBox.CreateSuperBox();
                    }
                    else
                    {
                        superBox.Update(seleTags);
                        if (this.superBox.ToolingBoxFeature == null)
                        {
                            SetLinearDimensionShow(false);
                        }
                    }
                    matr = superBox.Matr;
                    if (superBox.ToolingBoxFeature != null)
                    {
                        superBox.UpdateSpecify(manip);
                        bttPreview.Enable = true;
                        superBox.SetColor(intColor.GetValue()[0]);
                        SetDimForFace();
                        superBox.SetTranslucency(intTranslucency.Value);
                        superBox.SetLayer(intLayer.Value);
                    }
                }
                else if (block == manip)
                {
                    //---------Enter your code here-----------
                    if (superBox != null)
                    {
                        matr.Identity();
                        matr.TransformToZAxis(manip.Origin, manip.XAxis, manip.YAxis);
                        superBox.Update(matr, blockOffset);
                        SetDimForFace();
                    }
                }
                else if (block == vector)
                {
                    //---------Enter your code here-----------
                    if (superBox != null)
                    {
                        matr.Identity();
                        matr.TransformToZAxis(vector.Point, vector.Vector);
                        superBox.Update(matr, cylinderOffset);
                        SetDimForFace();
                    }
                }
                else if (block == boolOffset)
                {
                    //---------Enter your code here-----------
                    if (boolOffset.Value)
                    {
                        dimOffset.Enable = true;
                    }
                    else
                    {
                        dimOffset.Enable = false;
                    }
                }
                else if (block == dimOffset)
                {
                    //---------Enter your code here-----------
                    SetUiInitialize();
                    SetLinearDimensionDouble(0);
                    if (superBox != null)
                    {
                        if (type.ValueAsString == "块")
                        {
                            superBox.Update(this.matr, this.blockOffset);
                        }
                        else
                        {
                            superBox.Update(this.matr, this.cylinderOffset);
                        }
                    }
                }
                else if (block == positiveX)
                {
                    //---------Enter your code here-----------
                    SetDimFeatuer(positiveX, 0, ref blockOffset);
                }
                else if (block == negativeX)
                {
                    //---------Enter your code here-----------
                    SetDimFeatuer(negativeX, 1, ref blockOffset);
                }
                else if (block == positiveY)
                {
                    //---------Enter your code here-----------
                    SetDimFeatuer(positiveY, 2, ref blockOffset);
                }
                else if (block == negativeY)
                {
                    //---------Enter your code here-----------
                    SetDimFeatuer(negativeY, 3, ref blockOffset);
                }

                else if (block == positiveZ)
                {
                    //---------Enter your code here-----------
                    if (type.ValueAsString == "块")
                    {
                        SetDimFeatuer(positiveZ, 4, ref blockOffset);
                    }
                    else
                    {
                        SetDimFeatuer(positiveZ, 0, ref cylinderOffset);
                    }
                }
                else if (block == negativeZ)
                {
                    //---------Enter your code here-----------
                    if (type.ValueAsString == "块")
                    {
                        SetDimFeatuer(negativeZ, 5, ref blockOffset);
                    }
                    else
                    {
                        SetDimFeatuer(negativeZ, 1, ref cylinderOffset);
                    }
                }
                else if (block == radial)
                {
                    //---------Enter your code here-----------
                    SetDimFeatuer(radial, 2, ref cylinderOffset);
                }
                else if (block == boolHide)
                {
                    //---------Enter your code here-----------
                }
                else if (block == boolUnite)
                {
                    //---------Enter your code here-----------
                }
                else if (block == boolPlane)
                {
                    //---------Enter your code here-----------
                    if (boolPlane.Value)
                    {
                        boolSurface.Value = false;
                    }
                }
                else if (block == boolSurface)
                {
                    //---------Enter your code here-----------
                    if (boolSurface.Value)
                    {
                        boolPlane.Value = false;
                    }
                }
                else if (block == intTranslucency)
                {
                    //---------Enter your code here-----------
                    if (superBox != null)
                    {
                        superBox.SetTranslucency(intTranslucency.Value);
                    }
                }
                else if (block == intLayer)
                {
                    //---------Enter your code here-----------
                    if (superBox != null)
                    {
                        superBox.SetLayer(intLayer.Value);
                    }
                }
                else if (block == intColor)
                {
                    //---------Enter your code here-----------
                    if (superBox != null)
                    {
                        superBox.SetColor(intColor.GetValue()[0]);
                    }
                }
                else if (block == bttPreview)
                {
                    //---------Enter your code here-----------
                    if (superBox != null)
                    {
                        if (preview)
                        {
                            if (boolUnite.Value)
                            {
                                prtviewFeature.Add(CreateBooleanFeature());
                            }
                            if (boolPlane.Value)
                            {
                                prtviewFeature.AddRange(Trim(seleTags, superBox.ToolingBoxFeature.GetBodies()[0]));
                            }
                            if (boolHide.Value)
                            {
                                AskSelectParent().Unblank();
                            }
                            bttPreview.Bitmap = "undo";
                            strPreview.Label  = "Undo Result";
                            preview           = false;
                        }
                        else
                        {
                            if (prtviewFeature.Count != 0 || prtviewFeature != null)
                            {
                                DeleteObject.Delete(prtviewFeature.ToArray());
                            }
                            prtviewFeature.Clear();
                            bttPreview.Bitmap = "general_preview";
                            strPreview.Label  = "Show Result";
                            preview           = true;
                        }
                    }
                }
                else if (block == strPreview)
                {
                    //---------Enter your code here-----------
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(0);
        }