//------------------------------------------------------------------------------ //This method shows the dialog on the screen //------------------------------------------------------------------------------ public NXOpen.UIStyler.DialogResponse Show() { try { //CHECK WORKING OBJECT Logger.Write("--- WORKING OBJECT CHECK ---"); NXOpen.NXObject workObj = theSession.Parts.BaseWork; if (workObj.GetType().ToString() != "NXOpen.CAE.SimPart") { Logger.Write(workObj.GetType().ToString() + " --> EXPECTED A SIM OBJECT TO BE THE WORKING OBJECT: ABORT"); Logger.Show(); } else { // SHOW GUI theDialog.Show(); } } catch (Exception ex) { //---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(0); }
//------------------------------------------------------------------------------ //Callback Name: update_cb //------------------------------------------------------------------------------ public int update_cb(NXOpen.BlockStyler.UIBlock block) { try { if (block == LB_SelObjs) { //---------Enter your code here----------- button_Verify.Enable = LB_SelObjs.GetSelectedItems().Length > 0 ? true : false; button_Verify.Tooltip = button_Verify.Enable ? "" : "Select at least one object to verify"; } else if (block == button_Verify) { //---------Enter your code here----------- foreach (int objIndex in LB_SelObjs.GetSelectedItems()) { // Get selected object NXOpen.NXObject targObj = theSession.Parts.ToArray()[objIndex]; lw.WriteFullline(Environment.NewLine + targObj.Name.ToUpper()); // Check if CAD object if (targObj.GetType().ToString() != "NXOpen.Part") { lw.WriteFullline(" -> Skipped: not a CAD object, but of type = " + targObj.GetType().ToString()); continue; } NXOpen.Part targCAD = (NXOpen.Part)targObj; // Check if target CAD object is a Sheet Metal object if (DetectSheetMetal(targCAD)) { lw.WriteFullline(" -> SHEETMETAL"); } else { lw.WriteFullline(" -> normal CAD"); } } } } catch (Exception ex) { //---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(0); }