public NxOperation(NXOpen.CAM.Operation operation, NxOperationGroup nxOperationGroup) { if (operation == null) { throw new Exception("Получение операций. Объект не является типом операция."); } Operation = operation; //String n = Operation.Name; System.Type t = Operation.GetType(); UF_TYPE_OPERATION_NAME = t.Name;// if SurfaceContour _operationGroup = nxOperationGroup; ufs = NxSession.Ufs; if (ufs == null) { throw new Exception("Не удалось получить сессию пользовательских функций NX."); } GetParams(); // GetCutterTool(); <--перенёс в метод GetParams() GetCutterInsertTypeStr(); GetChanellNumber(); }
/// <summary> /// 取得ToolSpeed /// </summary> /// <param name="singleOper"></param> /// <returns></returns> public static string AskOperToolSpeed(NXOpen.CAM.Operation singleOper) { string OperToolSpeed = ""; try { NXOpen.CAM.CAMObject[] params1 = new NXOpen.CAM.CAMObject[1]; params1[0] = singleOper; NXOpen.CAM.ObjectsFeedsBuilder objectsFeedsBuilder1; objectsFeedsBuilder1 = workPart.CAMSetup.CreateFeedsBuilder(params1); string OutPutMode = objectsFeedsBuilder1.FeedsBuilder.SpindleModeBuilder.Value.ToString(); //CaxLog.ShowListingWindow(objectsFeedsBuilder1.FeedsBuilder.SpindleModeBuilder.Value.ToString()); if (OutPutMode == "0") { OperToolSpeed = objectsFeedsBuilder1.FeedsBuilder.SpindleRpmBuilder.Value.ToString(); } else { OperToolSpeed = objectsFeedsBuilder1.FeedsBuilder.SurfaceSpeedBuilder.Value.ToString(); } //OperToolSpeed = objectsFeedsBuilder1.FeedsBuilder.SurfaceSpeedBuilder.Value.ToString(); CaxLog.ShowListingWindow(OperToolSpeed); //string aa = objectsFeedsBuilder1.FeedsBuilder.SpindleRpmBuilder.Value.ToString(); CaxLog.ShowListingWindow(aa); CaxLog.ShowListingWindow("--"); return(OperToolSpeed); } catch (System.Exception ex) { return(OperToolSpeed); } }
/// <summary> /// 取得Operation的預留量 /// </summary> /// <param name="singleOper"></param> /// <param name="StockStr"></param> /// <param name="FloorStockStr"></param> /// <returns></returns> public static bool AskOperStock(NXOpen.CAM.Operation singleOper, out string StockStr, out string FloorStockStr) { StockStr = "0"; FloorStockStr = "0"; try { //CaxLog.ShowListingWindow(singleOper.GetType().ToString()); if (singleOper.GetType().ToString() == "NXOpen.CAM.PlanarMilling") { NXOpen.CAM.PlanarMillingBuilder Builder1; Builder1 = workPart.CAMSetup.CAMOperationCollection.CreatePlanarMillingBuilder(singleOper); StockStr = Builder1.CutParameters.PartStock.Value.ToString(); FloorStockStr = Builder1.CutParameters.FloorStock.Value.ToString(); } else if (singleOper.GetType().ToString() == "NXOpen.CAM.PlungeMilling") { NXOpen.CAM.PlungeMillingBuilder Builder1; Builder1 = workPart.CAMSetup.CAMOperationCollection.CreatePlungeMillingBuilder(singleOper); StockStr = Builder1.CutParameters.PartStock.Value.ToString(); FloorStockStr = Builder1.CutParameters.FloorStock.Value.ToString(); } else if (singleOper.GetType().ToString() == "NXOpen.CAM.RoughTurning") { NXOpen.CAM.RoughTurningBuilder Builder1; Builder1 = workPart.CAMSetup.CAMOperationCollection.CreateRoughTurningBuilder(singleOper); StockStr = Builder1.CutParameters.PartStock.Value.ToString(); } else if (singleOper.GetType().ToString() == "NXOpen.CAM.FinishTurning") { NXOpen.CAM.FinishTurningBuilder Builder1; Builder1 = workPart.CAMSetup.CAMOperationCollection.CreateFinishTurningBuilder(singleOper); StockStr = Builder1.CutParameters.PartStock.Value.ToString(); } else if (singleOper.GetType().ToString() == "NXOpen.CavityMilling") { NXOpen.CAM.CavityMillingBuilder Builder1; Builder1 = workPart.CAMSetup.CAMOperationCollection.CreateCavityMillingBuilder(singleOper); StockStr = Builder1.CutParameters.PartStock.Value.ToString(); FloorStockStr = Builder1.CutParameters.FloorStock.Value.ToString(); } else if (singleOper.GetType().ToString() == "NXOpen.FaceMilling") { NXOpen.CAM.FaceMillingBuilder Builder1; Builder1 = workPart.CAMSetup.CAMOperationCollection.CreateFaceMillingBuilder(singleOper); StockStr = Builder1.CutParameters.PartStock.Value.ToString(); FloorStockStr = Builder1.CutParameters.FloorStock.Value.ToString(); } else if (singleOper.GetType().ToString() == "NXOpen.HoleMaking") { NXOpen.CAM.HoleMakingBuilder Builder1; Builder1 = workPart.CAMSetup.CAMOperationCollection.CreateHoleMakingBuilder(singleOper); StockStr = Builder1.CutParameters.PartStock.Value.ToString(); } } catch (System.Exception ex) { return(false); } return(true); }
/// <summary> /// 取得ToolSpeed /// </summary> /// <param name="singleOper"></param> /// <returns></returns> public static string AskOperToolSpeed(NXOpen.CAM.Operation singleOper) { string OperToolSpeed = ""; //double maxSpindleSpeed; try { NXOpen.CAM.CAMObject[] params1 = new NXOpen.CAM.CAMObject[1]; params1[0] = singleOper; NXOpen.CAM.ObjectsFeedsBuilder objectsFeedsBuilder1; objectsFeedsBuilder1 = workPart.CAMSetup.CreateFeedsBuilder(params1); string OutPutMode = objectsFeedsBuilder1.FeedsBuilder.SpindleModeBuilder.Value.ToString(); if (OutPutMode == "0") { OperToolSpeed = "S:" + objectsFeedsBuilder1.FeedsBuilder.SpindleRpmBuilder.Value.ToString(); } else if (OutPutMode == "1" || OutPutMode == "2") { OperToolSpeed = "V:" + objectsFeedsBuilder1.FeedsBuilder.SurfaceSpeedBuilder.Value.ToString(); //JOperation jOper = JOperationFactory.CreateJOperation(singleOper); //maxSpindleSpeed = jOper.GetMaximunSpindleSpeed(); } return(OperToolSpeed); } catch (System.Exception ex) { return(OperToolSpeed); } }
private static bool GetOperToolAttr(NXOpen.CAM.Operation item, ref OperData sOperData) { try { sOperData.OperName = item.Name; sOperData.ToolNumber = "T" + CaxOper.AskOperToolNumber(item); sOperData.ToolName = CaxOper.AskOperToolNameFromTag(item.Tag); sOperData.HolderDescription = CaxOper.AskOperHolderDescription(item); sOperData.TOOL_NO = "T" + CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.TOOL_NO); sOperData.ERP_NO = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.ERP_NO); sOperData.CUTTER_QTY = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.CUTTER_QTY); sOperData.CUTTER_LIFE = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.CUTTER_LIFE); sOperData.FLUTE_QTY = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.FLUTE_QTY); sOperData.TITLE = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.TITLE); if (CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.SPECIFICATION) != "") { sOperData.SPECIFICATION = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.SPECIFICATION); } else { sOperData.SPECIFICATION = CaxOper.AskOperToolNameFromTag(item.Tag); } sOperData.NOTE = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.NOTE); sOperData.ACCESSORY = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.ACCESSORY); } catch (System.Exception ex) { return(false); } return(true); }
/// <summary> /// 获取刀路 /// </summary> /// <param name="oper"></param> public AbstractOperationModel(NXOpen.CAM.Operation oper) { workPart = Session.GetSession().Parts.Work; if (oper == null) { throw new Exception("刀路信息为空!"); } this.Oper = oper; }
/// <summary> /// 取得Operation的加工時間 /// </summary> /// <param name="singleOper"></param> /// <returns></returns> public static string AskOperCuttingTime(NXOpen.CAM.Operation singleOper) { string CuttingTime = ""; try { return(CuttingTime = singleOper.GetToolpathCuttingTime().ToString()); } catch (System.Exception ex) { return(CuttingTime); } }
/// <summary> /// 取得Operation總加工長度 /// </summary> /// <param name="singleOper"></param> /// <returns></returns> public static string AskOperTotalCuttingLength(NXOpen.CAM.Operation singleOper) { string TotalCuttingLength = ""; try { return(TotalCuttingLength = singleOper.GetToolpathLength().ToString()); } catch (System.Exception ex) { return(TotalCuttingLength); } }
/// <summary> /// 取得Operation的刀具進給 /// </summary> /// <param name="singleOper"></param> /// <returns></returns> public static string AskOperToolFeed(NXOpen.CAM.Operation singleOper) { string OperToolFeed = ""; try { OperToolFeed = (Convert.ToDouble(AskOperCuttingLength(singleOper)) / Convert.ToDouble(AskOperCuttingTime(singleOper))).ToString(); return(OperToolFeed); } catch (System.Exception ex) { return(OperToolFeed); } }
/// <summary> /// 后处理 /// </summary> /// <param name="op"></param> /// <returns></returns>z private string PostOperation(NXOpen.CAM.Operation op) { Part workPart = Session.GetSession().Parts.Work; string filePath = System.IO.Path.GetDirectoryName(workPart.FullPath); NXOpen.CAM.Operation[] ops = { op }; string postPath = filePath + "\\" + op.Name + ".txt"; if (File.Exists(postPath)) { File.Delete(postPath); } workPart.CAMSetup.Postprocess(ops, "mill3ax", postPath, NXOpen.CAM.CAMSetup.OutputUnits.Metric); return(postPath); }
/// <summary> /// 取得ToolSpeed /// </summary> /// <param name="singleOper"></param> /// <returns></returns> public static string AskOperToolSpeed(NXOpen.CAM.Operation singleOper) { string OperToolSpeed = ""; try { NXOpen.CAM.CAMObject[] params1 = new NXOpen.CAM.CAMObject[1]; params1[0] = singleOper; NXOpen.CAM.ObjectsFeedsBuilder objectsFeedsBuilder1; objectsFeedsBuilder1 = workPart.CAMSetup.CreateFeedsBuilder(params1); return(OperToolSpeed = objectsFeedsBuilder1.FeedsBuilder.SpindleRpmBuilder.Value.ToString()); } catch (System.Exception ex) { return(OperToolSpeed); } }
public static OperationData GetOperationData(NXOpen.CAM.Operation oper) { int type, subtype; AbstractOperationModel model; OperationData data = null; UFSession theUFSession = UFSession.GetUFSession(); theUFSession.Obj.AskTypeAndSubtype(oper.Tag, out type, out subtype); switch (subtype) { case 260: model = new CavityMillingModel(oper); data = model.GetOperationData(); break; case 263: model = new ZLevelMillingModel(oper); data = model.GetOperationData(); break; case 210: model = new SurfaceContourModel(oper); data = model.GetOperationData(); break; case 110: model = new PlanarMillingModel(oper); data = model.GetOperationData(); break; case 261: model = new FaceMillingModel(oper); data = model.GetOperationData(); break; case 450: PointToPointModel point = new PointToPointModel(oper); data = point.GetOperationData(); break; default: break; } return(data); }
/// <summary> /// 取得Operation的刀具進給 /// </summary> /// <param name="singleOper"></param> /// <returns></returns> public static string AskOperToolFeed(NXOpen.CAM.Operation singleOper) { string OperToolFeed = ""; try { NXOpen.CAM.CAMObject[] params1 = new NXOpen.CAM.CAMObject[1]; params1[0] = singleOper; NXOpen.CAM.ObjectsFeedsBuilder objectsFeedsBuilder1; objectsFeedsBuilder1 = workPart.CAMSetup.CreateFeedsBuilder(params1); OperToolFeed = objectsFeedsBuilder1.FeedsBuilder.FeedCutBuilder.Value.ToString(); //CaxLog.ShowListingWindow(OperToolFeed); //OperToolFeed = (Convert.ToDouble(AskOperCuttingLength(singleOper)) / Convert.ToDouble(AskOperCuttingTime(singleOper))).ToString(); return(OperToolFeed); } catch (System.Exception ex) { return(OperToolFeed); } }
private IEnumerable <NxOperation> GetOperations(NXOpen.CAM.Operation op) { Tag cutterTag; if (op == null) { yield break; } if (NxSession.Ufs == null) { throw new Exception("Не удалось получить сессию пользовательских функций NX."); } NxSession.Ufs.Oper.AskCutterGroup(op.Tag, out cutterTag); if (cutterTag == Tag.Null || !(NXObjectManager.Get(cutterTag) is Tool)) { yield break; } yield return (new NxOperation(op, this)); }
private static void CheckRepeat(NXOpen.CAM.Operation item, ref OperData sOperData) { try { string toolNumber = "T" + CaxOper.AskOperToolNumber(item); //取得現有的刀號 string[] toolNumbers = sOperData.ToolNumber.Split(','); string toolName = CaxOper.AskOperToolNameFromTag(item.Tag); string holder = CaxOper.AskOperHolderDescription(item); //string toolERP = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, "ToolERP"); //string shankERP = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, "ShankERP"); //string extensionShankERP = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, "ExtensionShankERP"); //string holderERP = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, "HolderERP"); string specification = ""; if (CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.SPECIFICATION) != "") { specification = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.SPECIFICATION); } else { specification = CaxOper.AskOperToolNameFromTag(item.Tag); } string tool_NO = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.TOOL_NO); string erp_NO = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.ERP_NO); string cutter_qty = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.CUTTER_QTY); string cutter_life = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.CUTTER_LIFE); string flute_qty = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.FLUTE_QTY); string title = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.TITLE); string note = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.NOTE); //string specification = CaxOper.AskOperToolERPNumFromAttribute(item.Tag, ToolListMember.SPECIFICATION); #region toolNumber檢查 bool toolNumberChk = false; foreach (string i in toolNumbers) { if (toolNumber == i) { toolNumberChk = true; break; } } if (toolNumberChk) { sOperData.ToolNumber = sOperData.ToolNumber + "," + toolNumber; sOperData.ToolName = sOperData.ToolName + "," + ""; sOperData.HolderDescription = sOperData.HolderDescription + "," + ""; //sOperData.ToolERP = sOperData.ToolERP + "," + ""; //sOperData.ShankERP = sOperData.ShankERP + "," + ""; //sOperData.ExtensionShankERP = sOperData.ExtensionShankERP + "," + ""; //sOperData.HolderERP = sOperData.HolderERP + "," + ""; //attribute sOperData.TOOL_NO = sOperData.TOOL_NO + "," + ""; sOperData.ERP_NO = sOperData.ERP_NO + "," + ""; sOperData.CUTTER_QTY = sOperData.CUTTER_QTY + "," + ""; sOperData.CUTTER_LIFE = sOperData.CUTTER_LIFE + "," + ""; sOperData.FLUTE_QTY = sOperData.FLUTE_QTY + "," + ""; sOperData.TITLE = sOperData.TITLE + "," + ""; sOperData.SPECIFICATION = sOperData.SPECIFICATION + "," + ""; sOperData.NOTE = sOperData.NOTE + "," + ""; } else { sOperData.ToolNumber = sOperData.ToolNumber + "," + toolNumber; sOperData.ToolName = sOperData.ToolName + "," + toolName; sOperData.HolderDescription = sOperData.HolderDescription + "," + holder; //sOperData.ToolERP = sOperData.ToolERP + "," + toolERP; //sOperData.ShankERP = sOperData.ShankERP + "," + shankERP; //sOperData.ExtensionShankERP = sOperData.ExtensionShankERP + "," + extensionShankERP; //sOperData.HolderERP = sOperData.HolderERP + "," + holderERP; //attribute sOperData.TOOL_NO = sOperData.TOOL_NO + "," + tool_NO; sOperData.ERP_NO = sOperData.ERP_NO + "," + erp_NO; sOperData.CUTTER_QTY = sOperData.CUTTER_QTY + "," + cutter_qty; sOperData.CUTTER_LIFE = sOperData.CUTTER_LIFE + "," + cutter_life; sOperData.FLUTE_QTY = sOperData.FLUTE_QTY + "," + flute_qty; sOperData.TITLE = sOperData.TITLE + "," + title; sOperData.SPECIFICATION = sOperData.SPECIFICATION + "," + specification; sOperData.NOTE = sOperData.NOTE + "," + note; } #endregion //string toolName = CaxOper.AskOperToolNameFromTag(item.Tag); //string holder = CaxOper.AskOperHolderDescription(item); //string[] toolNames = sOperData.ToolName.Split(','); //string[] holders = sOperData.HolderDescription.Split(','); #region (註解)toolName檢查 /* * bool toolNameChk = false; * foreach (string i in toolNames) * { * if (toolName == i) * { * toolNameChk = true; * } * } * if (toolNameChk) * { * sOperData.ToolName = sOperData.ToolName + "," + ""; * } * else * { * sOperData.ToolName = sOperData.ToolName + "," + toolName; * } */ #endregion #region (註解)holder檢查 /* * bool holderChk = false; * foreach (string i in holders) * { * if (holder == i) * { * holderChk = true; * } * } * if (holderChk) * { * sOperData.HolderDescription = sOperData.HolderDescription + "," + ""; * } * else * { * sOperData.HolderDescription = sOperData.HolderDescription + "," + holder; * } */ #endregion } catch (System.Exception ex) { MessageBox.Show("判斷是否重複的刀具與刀柄失敗"); } }
public CavityMillingModel(NXOpen.CAM.Operation oper) : base(oper) { }
public FaceMillingModel(NXOpen.CAM.Operation oper) : base(oper) { }
public ZLevelMillingModel(NXOpen.CAM.Operation oper) : base(oper) { }
public AbstractOperationModel(NXOpen.CAM.Operation oper) { workPart = Session.GetSession().Parts.Work; this.Oper = oper; }
public SurfaceContourModel(NXOpen.CAM.Operation oper) : base(oper) { }
/// <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); }
/// <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); }
public PlanarMillingModel(NXOpen.CAM.Operation oper) : base(oper) { }
/// <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); }