public double determinateDiameterOfTool(string toolName) { Part refPart = NxSession.Part; double diam; // поиск инструмента в магазине и создание параметров для создания операции NXOpen.CAM.Tool tempTool = (NXOpen.CAM.Tool)refPart.CAMSetup.CAMGroupCollection.FindObject(toolName); NXOpen.CAM.MillingToolBuilder millingToolBuilder; millingToolBuilder = NxSession.Part.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tempTool); diam = millingToolBuilder.TlDiameterBuilder.Value; millingToolBuilder.Destroy(); return(diam); }
/// <summary> /// 取得Operation刀具名稱 /// </summary> /// <param name="operTag"></param> /// <param name="operToolName"></param> /// <returns></returns> public static string AskOperToolNameFromTag(Tag operTag) { string operToolName = "0"; try { Tag bb; theUfSession.Oper.AskCutterGroup(operTag, out bb); NXOpen.CAM.Tool dd = (NXOpen.CAM.Tool)NXObjectManager.Get(bb); operToolName = dd.Name; return(operToolName); } catch (System.Exception ex) { operToolName = "0"; return(operToolName); } return(operToolName); }
/// <summary> /// 取得ToolNumber /// </summary> /// <param name="singleOper"></param> /// <param name="operHolderDescription"></param> /// <returns></returns> public static string AskOperToolNumber(NXOpen.CAM.Operation singleOper) { string operToolNumber = "0"; try { NCGroup singleOperParent = singleOper.GetParent(CAMSetup.View.MachineTool); //由Oper取得刀子 NXOpen.CAM.Tool tool = (NXOpen.CAM.Tool)NXObjectManager.Get(singleOperParent.Tag); //取得Oper的刀子名稱 return(operToolNumber = CaxOper.AskToolNumber(tool)); /*註解(如果AskToolNumber測試失敗,則回覆程式碼) * Tool.Types type; * Tool.Subtypes subtype; * tool.GetTypeAndSubtype(out type, out subtype); * * if (type == Tool.Types.Barrel) * { * NXOpen.CAM.BarrelToolBuilder ToolBuilder1; * ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateBarrelToolBuilder(tool); * operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); * return operToolNumber; * } * else if (type == Tool.Types.Drill) * { * NXOpen.CAM.DrillStdToolBuilder ToolBuilder1; * ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateDrillStdToolBuilder(tool); * operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); * return operToolNumber; * } * else if (type == Tool.Types.DrillSpcGroove) * { * NXOpen.CAM.MillingToolBuilder ToolBuilder1; * ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); * operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); * return operToolNumber; * } * else if (type == Tool.Types.Mill) * { * NXOpen.CAM.MillingToolBuilder ToolBuilder1; * ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); * operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); * return operToolNumber; * } * else if (type == Tool.Types.MillForm) * { * NXOpen.CAM.MillingToolBuilder ToolBuilder1; * ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); * operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); * return operToolNumber; * } * else if (type == Tool.Types.Solid) * { * * } * else if (type == Tool.Types.Tcutter) * { * NXOpen.CAM.MillingToolBuilder ToolBuilder1; * ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); * operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); * return operToolNumber; * } * else if (type == Tool.Types.Thread) * { * NXOpen.CAM.ThreadToolBuilder ToolBuilder1; * ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateThreadToolBuilder(tool); * operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); * return operToolNumber; * } * else if (type == Tool.Types.Turn) * { * NXOpen.CAM.TurningToolBuilder ToolBuilder1; * ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateTurnToolBuilder(tool); * operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); * return operToolNumber; * } * else if (type == Tool.Types.Wedm) * { * * } * else if (type == Tool.Types.Groove) * { * NXOpen.CAM.GrooveToolBuilder ToolBuilder1; * ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateGrooveToolBuilder(tool); * operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); * return operToolNumber; * } */ } catch (System.Exception ex) { operToolNumber = "尚未建立Builder存取資料"; return(operToolNumber); } return(operToolNumber); }
/// <summary> /// 取得ToolNumber /// </summary> /// <param name="singleOper"></param> /// <param name="operHolderDescription"></param> /// <returns></returns> public static string AskOperToolNumber(NXOpen.CAM.Operation singleOper) { string operToolNumber = "0"; try { NCGroup singleOperParent = singleOper.GetParent(CAMSetup.View.MachineTool); //由Oper取得刀子 NXOpen.CAM.Tool tool = (NXOpen.CAM.Tool)NXObjectManager.Get(singleOperParent.Tag); //取得Oper的刀子名稱 Tool.Types type; Tool.Subtypes subtype; tool.GetTypeAndSubtype(out type, out subtype); if (type == Tool.Types.Barrel) { NXOpen.CAM.BarrelToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateBarrelToolBuilder(tool); operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); return(operToolNumber); } else if (type == Tool.Types.Drill) { NXOpen.CAM.DrillStdToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateDrillStdToolBuilder(tool); operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); return(operToolNumber); } else if (type == Tool.Types.DrillSpcGroove) { NXOpen.CAM.MillingToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); return(operToolNumber); } else if (type == Tool.Types.Mill) { NXOpen.CAM.MillingToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); return(operToolNumber); } else if (type == Tool.Types.MillForm) { NXOpen.CAM.MillingToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); return(operToolNumber); } else if (type == Tool.Types.Solid) { } else if (type == Tool.Types.Tcutter) { NXOpen.CAM.MillingToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); operToolNumber = ToolBuilder1.TlNumberBuilder.Value.ToString(); return(operToolNumber); } else if (type == Tool.Types.Thread) { } else if (type == Tool.Types.Turn) { } else if (type == Tool.Types.Wedm) { } else if (type == Tool.Types.Groove) { } } catch (System.Exception ex) { operToolNumber = "尚未建立Builder存取資料"; return(operToolNumber); } return(operToolNumber); }
/// <summary> /// 取得Operation的HolderDescription名稱 /// </summary> /// <param name="singleOper"></param> /// <param name="operHolderDescription"></param> /// <returns></returns> public static string AskOperHolderDescription(NXOpen.CAM.Operation singleOper) { string operHolderDescription = ""; try { NCGroup singleOperParent = singleOper.GetParent(CAMSetup.View.MachineTool); //由Oper取得刀子 NXOpen.CAM.Tool tool = (NXOpen.CAM.Tool)NXObjectManager.Get(singleOperParent.Tag); //取得Oper的刀子名稱 Tool.Types type; Tool.Subtypes subtype; tool.GetTypeAndSubtype(out type, out subtype); //CaxLog.ShowListingWindow(type.ToString()); //CaxLog.ShowListingWindow(subtype.ToString()); //CaxLog.ShowListingWindow("---"); //CaxLog.ShowListingWindow(singleOper.Name.ToString()); if (type == Tool.Types.Barrel) { NXOpen.CAM.BarrelToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateBarrelToolBuilder(tool); operHolderDescription = ToolBuilder1.TlHolderDescription; return(operHolderDescription); } else if (type == Tool.Types.Drill) { NXOpen.CAM.DrillStdToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateDrillStdToolBuilder(tool); operHolderDescription = ToolBuilder1.TlHolderDescription; //CaxLog.ShowListingWindow(operHolderDescription); return(operHolderDescription); } else if (type == Tool.Types.DrillSpcGroove) { NXOpen.CAM.MillingToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); operHolderDescription = ToolBuilder1.TlHolderDescription; return(operHolderDescription); } else if (type == Tool.Types.Mill) { NXOpen.CAM.MillingToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); operHolderDescription = ToolBuilder1.TlHolderDescription; return(operHolderDescription); } else if (type == Tool.Types.MillForm) { NXOpen.CAM.MillingToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); operHolderDescription = ToolBuilder1.TlHolderDescription; return(operHolderDescription); } else if (type == Tool.Types.Solid) { } else if (type == Tool.Types.Tcutter) { NXOpen.CAM.MillingToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool); operHolderDescription = ToolBuilder1.TlHolderDescription; return(operHolderDescription); } else if (type == Tool.Types.Thread) { NXOpen.CAM.ThreadToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateThreadToolBuilder(tool); operHolderDescription = ToolBuilder1.TlDescription; //CaxLog.ShowListingWindow(operHolderDescription); //operHolderDescription = ToolBuilder1.HolderHand.ToString(); CaxLog.ShowListingWindow(operHolderDescription); //operHolderDescription = ToolBuilder1.HolderGrooveHand.ToString(); CaxLog.ShowListingWindow(operHolderDescription); //CaxLog.ShowListingWindow("---"); return(operHolderDescription); } else if (type == Tool.Types.Turn) { NXOpen.CAM.TurningToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateTurnToolBuilder(tool); operHolderDescription = ToolBuilder1.TlDescription; //CaxLog.ShowListingWindow(operHolderDescription); //operHolderDescription = ToolBuilder1.HolderHand.ToString(); CaxLog.ShowListingWindow(operHolderDescription); //operHolderDescription = ToolBuilder1.HolderGrooveHand.ToString(); CaxLog.ShowListingWindow(operHolderDescription); //CaxLog.ShowListingWindow("---"); return(operHolderDescription); } else if (type == Tool.Types.Wedm) { } else if (type == Tool.Types.Groove) { NXOpen.CAM.GrooveToolBuilder ToolBuilder1; ToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateGrooveToolBuilder(tool); operHolderDescription = ToolBuilder1.TlDescription; //CaxLog.ShowListingWindow(operHolderDescription); //operHolderDescription = ToolBuilder1.HolderHand.ToString(); CaxLog.ShowListingWindow(operHolderDescription); //operHolderDescription = ToolBuilder1.HolderGrooveHand.ToString(); CaxLog.ShowListingWindow(operHolderDescription); //CaxLog.ShowListingWindow("---"); return(operHolderDescription); } } catch (System.Exception ex) { operHolderDescription = "尚未建立Builder存取資料"; return(operHolderDescription); } return(operHolderDescription); }