//------------------------------------------------------------------------------ // Callback Name: constructor_cb // Following callback is associated with the "changeDialog" Styler item. // Input: eventObject - object of UIStyler.StylerEvent class //------------------------------------------------------------------------------ public NXOpen.UIStyler.DialogState constructor_cb(NXOpen.UIStyler.StylerEvent eventObject) { try { // Get the selection handle SelectionHandle selectH; selectH = changeDialog.GetSelectionHandle(); NXOpen.Selection.MaskTriple[] selectionMask_array = new NXOpen.Selection.MaskTriple[1]; NXOpen.Selection.MaskTriple selectionMask_arrayElem; selectionMask_arrayElem.Type = NXOpen.UF.UFConstants.UF_solid_type; selectionMask_arrayElem.Subtype = NXOpen.UF.UFConstants.UF_solid_edge_subtype; selectionMask_arrayElem.SolidBodySubtype = NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE; selectionMask_array[0] = selectionMask_arrayElem; //Following sets the Selection mask for Edge theUI.SelectionManager.SetSelectionMask(selectH, NXOpen.Selection.SelectionAction.ClearAndEnableSpecific, selectionMask_array); //Following sets the Selection and Filter callbacks which are invoked during selection theUI.SelectionManager.SetSelectionCallbacks(selectH, filter_cb, sel_cb); changeToggle6.ItemValue = true; changeStr0.ItemValue = "5.0"; 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 continue dialog construction. return(NXOpen.UIStyler.DialogState.ContinueDialog); }
//------------------------------------------------------------------------------ // Callback Name: tolerance_cb // Following callback is associated with the "changeReal6" Styler item. // Input: eventObject - object of UIStyler.StylerEvent class //------------------------------------------------------------------------------ public NXOpen.UIStyler.DialogState tolerance_cb(NXOpen.UIStyler.StylerEvent eventObject) { try { // ---- Enter your callback code here ----- } 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 return(NXOpen.UIStyler.DialogState.ContinueDialog); // or Callback acknowledged, terminate dialog. // return NXOpen.UIStyler.DialogState.ExitDialog; }
//------------------------------------------------------------------------------ // Callback Name: ok_cb // Following callback is associated with the "changeDialog" Styler item. // Input: eventObject - object of UIStyler.StylerEvent class //------------------------------------------------------------------------------ public NXOpen.UIStyler.DialogState ok_cb(NXOpen.UIStyler.StylerEvent eventObject) { try { apply_cb(eventObject); } catch (NXOpen.NXException ex) { // ---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message); } // Callback acknowledged, terminate dialog // It is STRONGLY recommanded that you exit your // callback with NXOpen.UIStyler.DialogState.ExitDialog in a ok callback. return(NXOpen.UIStyler.DialogState.ExitDialog); }
//------------------------------------------------------------------------------ // 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); }