Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.13 KB | None | 0 0
  1. using System;
  2. using NXOpen;
  3. using NXOpen.BlockStyler;
  4.  
  5. namespace DesignUi
  6. {
  7. class DesignUi
  8. {
  9. private static Session theSession = null;
  10. private static UI theUI = null;
  11. private string theDlxFileName;
  12. private NXOpen.BlockStyler.BlockDialog theDialog;
  13. private NXOpen.BlockStyler.Label lblLogo;// Block type: Label
  14. private NXOpen.BlockStyler.Label EmptyLabel;// Block type: Label
  15. private NXOpen.BlockStyler.Group grpStatus;// Block type: Group
  16. private NXOpen.BlockStyler.Label lblRawMaterial;// Block type: Label
  17. private NXOpen.BlockStyler.Label lblShank;// Block type: Label
  18. private NXOpen.BlockStyler.Label lblInternalCoolant;// Block type: Label
  19. private NXOpen.BlockStyler.Label lblToolInformations;// Block type: Label
  20. private NXOpen.BlockStyler.Separator separator0;// Block type: Separator
  21. private NXOpen.BlockStyler.Label lblChecksCompleted;// Block type: Label
  22. private NXOpen.BlockStyler.Label lblEmpty01;// Block type: Label
  23. private NXOpen.BlockStyler.Button btnRunAutoCheck;// Block type: Button
  24. private NXOpen.BlockStyler.Group grpRawMaterial;// Block type: Group
  25. private NXOpen.BlockStyler.Enumeration enumMaterial;// Block type: Enumeration
  26. private NXOpen.BlockStyler.Enumeration enumHeatTreatment;// Block type: Enumeration
  27. private NXOpen.BlockStyler.Enumeration enumCoating;// Block type: Enumeration
  28. private NXOpen.BlockStyler.Label lblEmpty001;// Block type: Label
  29. private NXOpen.BlockStyler.Label lblDimensions;// Block type: Label
  30. private NXOpen.BlockStyler.DoubleBlock dblMaxDiameter;// Block type: Double
  31. private NXOpen.BlockStyler.DoubleBlock dblMaxLength;// Block type: Double
  32. private NXOpen.BlockStyler.Label SpaceItem;// Block type: Label
  33. private NXOpen.BlockStyler.Group grpShank;// Block type: Group
  34. private NXOpen.BlockStyler.Enumeration enumShank;// Block type: Enumeration
  35. private NXOpen.BlockStyler.Label lblNumberOfClampingDevices;// Block type: Label
  36. private NXOpen.BlockStyler.Group grpInternalCoolant;// Block type: Group
  37. private NXOpen.BlockStyler.Toggle chkInternalCoolant;// Block type: Toggle
  38. private NXOpen.BlockStyler.Label lblInternalCoolantDimensions;// Block type: Label
  39. private NXOpen.BlockStyler.DoubleBlock dblInternalCoolantDiameter;// Block type: Double
  40. private NXOpen.BlockStyler.DoubleBlock dblInternalCoolantLength;// Block type: Double
  41. private NXOpen.BlockStyler.Group grpToolInformation;// Block type: Group
  42. private NXOpen.BlockStyler.Enumeration enumToolCategory;// Block type: Enumeration
  43. private NXOpen.BlockStyler.Label EmptyLabel2;// Block type: Label
  44. private NXOpen.BlockStyler.IntegerBlock intNumberOfInsertSeats;// Block type: Integer
  45. private NXOpen.BlockStyler.Label EmptyLabel3;// Block type: Label
  46. private NXOpen.BlockStyler.IntegerBlock intNumberOfCartridgeSeats;// Block type: Integer
  47. private NXOpen.BlockStyler.Group grpInformation;// Block type: Group
  48. private NXOpen.BlockStyler.MultilineString strInformation;// Block type: Multiline String
  49. private NXOpen.BlockStyler.Label EmptyLabel4;// Block type: Label
  50. private NXOpen.BlockStyler.MultilineString strProblems;// Block type: Multiline String
  51. private NXOpen.BlockStyler.Button btnReportProblem;// Block type: Button
  52.  
  53. //------------------------------------------------------------------------------
  54. //Constructor for NX Styler class
  55. //------------------------------------------------------------------------------
  56. public DesignUi()
  57. {
  58. try
  59. {
  60. theSession = Session.GetSession();
  61. theUI = UI.GetUI();
  62. theDlxFileName = @"C:\Users\OneDrive\SmartModel\SmartModel\UI.Design.dlx";
  63. theDialog = theUI.CreateDialog(theDlxFileName);
  64. theDialog.AddOkHandler(new NXOpen.BlockStyler.BlockDialog.Ok(ok_cb));
  65. theDialog.AddUpdateHandler(new NXOpen.BlockStyler.BlockDialog.Update(update_cb));
  66. theDialog.AddInitializeHandler(new NXOpen.BlockStyler.BlockDialog.Initialize(initialize_cb));
  67. theDialog.AddDialogShownHandler(new NXOpen.BlockStyler.BlockDialog.DialogShown(dialogShown_cb));
  68. }
  69. catch (Exception ex)
  70. {
  71. throw ex;
  72. }
  73. }
  74.  
  75. public static void Main()
  76. {
  77. DesignUi theMainView = null;
  78. try
  79. {
  80. theMainView = new DesignUi();
  81. theMainView.Show();
  82. }
  83. catch (Exception ex)
  84. {
  85. theUI.NXMessageBox.Show("SmartModel - Error", NXMessageBox.DialogType.Error, ex.ToString());
  86. }
  87. finally
  88. {
  89. if (theMainView != null)
  90. theMainView.Dispose();
  91. theMainView = null;
  92. }
  93. }
  94.  
  95. public static int GetUnloadOption(string arg)
  96. {
  97. return Convert.ToInt32(Session.LibraryUnloadOption.Immediately);
  98. }
  99.  
  100. public static void UnloadLibrary(string arg)
  101. {
  102. try
  103. {
  104.  
  105. }
  106. catch (Exception ex)
  107. {
  108. theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
  109. }
  110. }
  111.  
  112. //------------------------------------------------------------------------------
  113. //This method shows the dialog on the screen
  114. //------------------------------------------------------------------------------
  115. public NXOpen.UIStyler.DialogResponse Show()
  116. {
  117. try
  118. {
  119. theDialog.Show();
  120. }
  121. catch (Exception ex)
  122. {
  123. theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
  124. }
  125. return 0;
  126. }
  127.  
  128. //------------------------------------------------------------------------------
  129. //Method Name: Dispose
  130. //------------------------------------------------------------------------------
  131. public void Dispose()
  132. {
  133. if (theDialog != null)
  134. {
  135. theDialog.Dispose();
  136. theDialog = null;
  137. }
  138. }
  139.  
  140. //------------------------------------------------------------------------------
  141. //Callback Name: initialize_cb
  142. //------------------------------------------------------------------------------
  143. public void initialize_cb()
  144. {
  145. try
  146. {
  147. lblLogo = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblLogo");
  148. EmptyLabel = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("EmptyLabel");
  149. grpStatus = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpStatus");
  150. lblRawMaterial = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblRawMaterial");
  151. lblShank = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblShank");
  152. lblInternalCoolant = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblInternalCoolant");
  153. lblToolInformations = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblToolType");
  154. separator0 = (NXOpen.BlockStyler.Separator)theDialog.TopBlock.FindBlock("separator0");
  155. lblChecksCompleted = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblChecksCompleted");
  156. lblEmpty01 = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblEmpty01");
  157. btnRunAutoCheck = (NXOpen.BlockStyler.Button)theDialog.TopBlock.FindBlock("btnRunAutoCheck");
  158. grpRawMaterial = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpRawMaterial");
  159. enumMaterial = (NXOpen.BlockStyler.Enumeration)theDialog.TopBlock.FindBlock("enumMaterial");
  160. enumHeatTreatment = (NXOpen.BlockStyler.Enumeration)theDialog.TopBlock.FindBlock("enumHeatTreatment");
  161. enumCoating = (NXOpen.BlockStyler.Enumeration)theDialog.TopBlock.FindBlock("enumCoating");
  162. lblEmpty001 = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblEmpty001");
  163. lblDimensions = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblDimensions");
  164. dblMaxDiameter = (NXOpen.BlockStyler.DoubleBlock)theDialog.TopBlock.FindBlock("dblMaxDiameter");
  165. dblMaxLength = (NXOpen.BlockStyler.DoubleBlock)theDialog.TopBlock.FindBlock("dblMaxLength");
  166. SpaceItem = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("SpaceItem");
  167. grpShank = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpShank");
  168. enumShank = (NXOpen.BlockStyler.Enumeration)theDialog.TopBlock.FindBlock("enumShank");
  169. lblNumberOfClampingDevices = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblNumberOfClampingDevices");
  170. grpInternalCoolant = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpInternalCoolant");
  171. chkInternalCoolant = (NXOpen.BlockStyler.Toggle)theDialog.TopBlock.FindBlock("chkInternalCoolant");
  172. lblInternalCoolantDimensions = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblInternalCoolantDimensions");
  173. dblInternalCoolantDiameter = (NXOpen.BlockStyler.DoubleBlock)theDialog.TopBlock.FindBlock("dblInternalCoolantDiameter");
  174. dblInternalCoolantLength = (NXOpen.BlockStyler.DoubleBlock)theDialog.TopBlock.FindBlock("dblInternalCoolantLength");
  175. grpToolInformation = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpToolInformation");
  176. enumToolCategory = (NXOpen.BlockStyler.Enumeration)theDialog.TopBlock.FindBlock("enumToolCategory");
  177. EmptyLabel2 = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("EmptyLabel2");
  178. intNumberOfInsertSeats = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("intNumberOfInsertSeats");
  179. EmptyLabel3 = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("EmptyLabel3");
  180. intNumberOfCartridgeSeats = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("intNumberOfCartridgeSeats2");
  181. grpInformation = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpInformation");
  182. strInformation = (NXOpen.BlockStyler.MultilineString)theDialog.TopBlock.FindBlock("strInformation");
  183. EmptyLabel4 = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("EmptyLabel4");
  184. strProblems = (NXOpen.BlockStyler.MultilineString)theDialog.TopBlock.FindBlock("strProblems");
  185. btnReportProblem = (NXOpen.BlockStyler.Button)theDialog.TopBlock.FindBlock("btnReportProblem");
  186. }
  187. catch (Exception ex)
  188. {
  189. theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
  190. }
  191. }
  192.  
  193. //------------------------------------------------------------------------------
  194. //Callback Name: dialogShown_cb
  195. //This callback is executed just before the dialog launch. Thus any value set
  196. //here will take precedence and dialog will be launched showing that value.
  197. //------------------------------------------------------------------------------
  198. public void dialogShown_cb()
  199. {
  200. try
  201. {
  202.  
  203. }
  204. catch (Exception ex)
  205. {
  206. theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
  207. }
  208. }
  209.  
  210. //------------------------------------------------------------------------------
  211. //Callback Name: update_cb
  212. //------------------------------------------------------------------------------
  213. public int update_cb(NXOpen.BlockStyler.UIBlock block)
  214. {
  215. try
  216. {
  217. if (block == btnRunAutoCheck)
  218. {
  219. }
  220. else if (block == enumMaterial)
  221. {
  222. }
  223. else if (block == enumHeatTreatment)
  224. {
  225. }
  226. else if (block == enumCoating)
  227. {
  228. }
  229. else if (block == dblMaxDiameter)
  230. {
  231. }
  232. else if (block == dblMaxLength)
  233. {
  234. }
  235. else if (block == enumShank)
  236. {
  237. }
  238. else if (block == chkInternalCoolant)
  239. {
  240. }
  241. else if (block == dblInternalCoolantDiameter)
  242. {
  243. }
  244. else if (block == dblInternalCoolantLength)
  245. {
  246. }
  247. else if (block == enumToolCategory)
  248. {
  249. }
  250. else if (block == intNumberOfInsertSeats)
  251. {
  252. }
  253. else if (block == intNumberOfCartridgeSeats)
  254. {
  255. }
  256. else if (block == strInformation)
  257. {
  258. }
  259. else if (block == strProblems)
  260. {
  261. }
  262. else if (block == btnReportProblem)
  263. {
  264. }
  265. }
  266. catch (Exception ex)
  267. {
  268. theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
  269. }
  270. return 0;
  271. }
  272.  
  273. //------------------------------------------------------------------------------
  274. //Callback Name: ok_cb
  275. //------------------------------------------------------------------------------
  276. public int ok_cb()
  277. {
  278. int errorCode = 0;
  279. try
  280. {
  281. //EndRoutine();
  282. }
  283. catch (Exception ex)
  284. {
  285. errorCode = 1;
  286. theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
  287. }
  288. return errorCode;
  289. }
  290.  
  291. //------------------------------------------------------------------------------
  292. //Function Name: GetBlockProperties
  293. //Returns the propertylist of the specified BlockID
  294. //------------------------------------------------------------------------------
  295. public PropertyList GetBlockProperties(string blockID)
  296. {
  297. PropertyList plist = null;
  298. try
  299. {
  300. plist = theDialog.GetBlockProperties(blockID);
  301. }
  302. catch (Exception ex)
  303. {
  304. theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
  305. }
  306. return plist;
  307. }
  308. }
  309. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement