Esempio n. 1
0
 public static Snap.NX.Block Wrap(Tag nxopenBlockTag)
 {
     if (nxopenBlockTag == Tag.Null)
     {
         throw new ArgumentException("Input tag is NXOpen.Tag.Null");
     }
     NXOpen.Features.Block objectFromTag = Snap.NX.NXObject.GetObjectFromTag(nxopenBlockTag) as NXOpen.Features.Block;
     if (objectFromTag == null)
     {
         throw new ArgumentException("Input tag doesn't belong to an NXOpen.Features.Block object");
     }
     return(objectFromTag);
 }
Esempio n. 2
0
        internal static Snap.NX.Block CreateBlock(Position origin, Orientation matrix, Snap.Number xLength, Snap.Number yLength, Snap.Number zLength)
        {
            Orientation wcsOrientation = Globals.WcsOrientation;

            Globals.WcsOrientation = matrix;
            BlockFeatureBuilder featureBuilder = Globals.WorkPart.NXOpenPart.Features.CreateBlockFeatureBuilder(null);

            featureBuilder.Type = BlockFeatureBuilder.Types.OriginAndEdgeLengths;
            featureBuilder.BooleanOption.Type = BooleanOperation.BooleanType.Create;
            featureBuilder.SetOriginAndLengths((Point3d)origin, xLength.ToString(), yLength.ToString(), zLength.ToString());
            NXOpen.Features.Block block = (NXOpen.Features.Block)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            Globals.WcsOrientation = wcsOrientation;
            return(new Snap.NX.Block(block));
        }
Esempio n. 3
0
        internal static Snap.NX.Block CreateBlock(Orientation matrix, Position originPoint, Position cornerPoint, Snap.Number height)
        {
            NXOpen.Part workPart       = (NXOpen.Part)Globals.WorkPart;
            Orientation wcsOrientation = Globals.WcsOrientation;

            Globals.WcsOrientation = matrix;
            BlockFeatureBuilder featureBuilder = workPart.Features.CreateBlockFeatureBuilder(null);

            featureBuilder.Type = BlockFeatureBuilder.Types.TwoPointsAndHeight;
            featureBuilder.BooleanOption.Type = BooleanOperation.BooleanType.Create;
            featureBuilder.SetTwoPointsAndHeight((Point3d)originPoint, (Point3d)cornerPoint, height.ToString());
            NXOpen.Features.Block block = (NXOpen.Features.Block)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            Globals.WcsOrientation = wcsOrientation;
            return(new Snap.NX.Block(block));
        }
    //------------------------------------------------------------------------------
    // Callback Name: apply_cb
    // Following callback is associated with the "changeDialog" Styler item.
    // Input: eventObject - object of UIStyler.StylerEvent class
    //------------------------------------------------------------------------------
    //Following is Apply Callback - This function is responsible for creating Edge Blend.
    public NXOpen.UIStyler.DialogState apply_cb(NXOpen.UIStyler.StylerEvent eventObject)
    {
        try
        {
            Part workPart    = theSession.Parts.Work;
            Part displayPart = theSession.Parts.Display;

            // ----------------------------------------------
            //   Menu: Insert->Detail Feature->Edge Blend...
            // ----------------------------------------------
            Session.UndoMarkId      markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start");
            NXOpen.Features.Feature nullFeatures_Feature = null;

            NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(nullFeatures_Feature);

            theSession.SetUndoMarkName(markId1, "Edge Blend");
            Boolean featureAlerts1 = theSession.Preferences.Modeling.FeatureAlerts;

            ScCollector scCollector1 = workPart.ScCollectors.CreateCollector();

            NXOpen.Features.Block block1 = (NXOpen.Features.Block)workPart.Features.FindObject("BLOCK(1)");

            Boolean featureAlerts2 = theSession.Preferences.Modeling.FeatureAlerts;
            Boolean featureAlerts3 = theSession.Preferences.Modeling.FeatureAlerts;

            Edge[] seedEdges1        = new Edge[htEdges.Count];
            IDictionaryEnumerator en = htEdges.GetEnumerator();
            int EdgeIndex            = 0;
            while (en.MoveNext())
            {
                Edge edgeVar = (Edge)en.Value;;
                seedEdges1[EdgeIndex] = edgeVar;
                EdgeIndex            += 1;
            }

            EdgeMultipleSeedTangentRule edgeMultipleSeedTangentRule2 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, true);

            SelectionIntentRule[] rules2 = new SelectionIntentRule[1];
            rules2[0] = edgeMultipleSeedTangentRule2;

            scCollector1.ReplaceRules(rules2, false);
            Boolean featureAlerts4 = theSession.Preferences.Modeling.FeatureAlerts;

            Boolean            featureAlerts5 = theSession.Preferences.Modeling.FeatureAlerts;
            Session.UndoMarkId markId2        = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Edge Blend");
            //Following can set the Tolerance for Edge Blend.
            edgeBlendBuilder1.Tolerance          = changeReal6.ItemValue;
            edgeBlendBuilder1.AllInstancesOption = false;
            //Following can set the Remove Self Intersection option for the Edge Blend.
            edgeBlendBuilder1.RemoveSelfIntersection = changeToggle6.ItemValue;
            edgeBlendBuilder1.ConvexConcaveY         = false;
            edgeBlendBuilder1.RollOverSmoothEdge     = true;
            edgeBlendBuilder1.RollOntoEdge           = true;
            edgeBlendBuilder1.MoveSharpEdge          = true;
            edgeBlendBuilder1.OverlapOption          = NXOpen.Features.EdgeBlendBuilder.Overlap.AnyConvexityRollOver;
            edgeBlendBuilder1.BlendOrder             = NXOpen.Features.EdgeBlendBuilder.OrderOfBlending.ConvexFirst;
            edgeBlendBuilder1.SetbackOption          = NXOpen.Features.EdgeBlendBuilder.Setback.SeparateFromCorner;

            //Following sets the value for Blend Radius.
            int csIndex1 = edgeBlendBuilder1.AddChainset(scCollector1, changeStr0.ItemValue);
            NXOpen.Features.Feature feature1 = edgeBlendBuilder1.CommitFeature();

            theSession.DeleteUndoMark(markId2, null);
            edgeBlendBuilder1.Destroy();
            htEdges.Clear();
            changeLabel1.SetLabel("Select Edges (0)");
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message);
        }
        // Callback acknowledged, do not terminate dialog
        // A return value of NXOpen.UIStyler.DialogState.ExitDialog will not be accepted
        // for this callback type. You must respond to your apply button.
        return(NXOpen.UIStyler.DialogState.ContinueDialog);
    }
Esempio n. 5
0
 internal Block(NXOpen.Features.Block block) : base(block)
 {
     this.NXOpenBlock = block;
 }