public static void SetRowData(ISheet sheet, ICellStyle style, int row, ElectrodeInfo info) { ExcelUtils.SetValue(sheet, style, row, 0, info.EleName); ExcelUtils.SetValue(sheet, style, row, 1, info.EleSetValue[0]); ExcelUtils.SetValue(sheet, style, row, 2, info.EleSetValue[1]); ExcelUtils.SetValue(sheet, style, row, 3, info.EleSetValue[2]); ExcelUtils.SetValue(sheet, style, row, 4, info.PitchX); ExcelUtils.SetValue(sheet, style, row, 5, info.PitchXNum); ExcelUtils.SetValue(sheet, style, row, 6, info.PitchY); ExcelUtils.SetValue(sheet, style, row, 7, info.PitchYNum); ExcelUtils.SetValue(sheet, style, row, 8, info.CrudeInter); ExcelUtils.SetValue(sheet, style, row, 9, info.CrudeNum); ExcelUtils.SetValue(sheet, style, row, 10, info.DuringInter); ExcelUtils.SetValue(sheet, style, row, 11, info.DuringNum); ExcelUtils.SetValue(sheet, style, row, 12, info.FineInter); ExcelUtils.SetValue(sheet, style, row, 13, info.FineNum); ExcelUtils.SetValue(sheet, style, row, 14, info.EleType); ExcelUtils.SetValue(sheet, style, row, 15, info.Ch); ExcelUtils.SetValue(sheet, style, row, 16, info.Material); ExcelUtils.SetValue(sheet, style, row, 17, info.Condition); ExcelUtils.SetValue(sheet, style, row, 18, info.Positioning); string size = info.Preparation[0] + "*" + info.Preparation[1] + "*" + info.Preparation[2]; ExcelUtils.SetValue(sheet, style, row, 19, size); ExcelUtils.SetValue(sheet, style, row, 20, info.BorrowName); ExcelUtils.SetValue(sheet, style, row, 21, info.Remarks); ExcelUtils.SetValue(sheet, style, row, 22, info.Technology); }
public ElectrodeBomBuilder(ElectrodeInfo info, AssembleModel assemble) { this.info = info; foreach (ElectrodeModel model in assemble.Electrodes) { if (model.EleInfo.EleName == info.EleName) { Model.Add(model); } } foreach (WorkModel wk in assemble.Works) { if (wk.WorkNumber == Model[0].WorkNumber) { work = wk; } } EletrodePreparation pre; if (info.Material.Equals("紫铜")) { pre = new EletrodePreparation("CuLength", "CuWidth"); } else { pre = new EletrodePreparation("WuLength", "WuWidth"); } int[] temp = new int[2] { info.Preparation[0], info.Preparation[1] }; info.IsPreparation = pre.IsPreCriterion(temp); }
/// <summary> /// 开始事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { oldValue = this.dataGridView.CurrentCell.Value; DataRow dr = (dataGridView.Rows[e.RowIndex].DataBoundItem as DataRowView).Row; oldInfo = ElectrodeInfo.GetEleInfo(dr); }
//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here bool anyPartsModified1; NXOpen.PartSaveStatus partSaveStatus1; Session.GetSession().Parts.SaveAll(out anyPartsModified1, out partSaveStatus1); NXOpen.Assemblies.Component eleComp = this.SeleElePart.GetSelectedObjects()[0] as NXOpen.Assemblies.Component; string name = eleComp.Name + "-" + this.StrName.Value.ToUpper(); if (!this.EleDuplicationOfName(name)) { this.StrName.Value = ""; return(0); } ElectrodeModel eleModel = new ElectrodeModel(); eleModel.GetModelForPart(eleComp.Prototype as Part); name = work.WorkpieceDirectoryPath + name + ".prt"; Vector3d movePt = new Vector3d(double_x.Value, double_y.Value, double_z.Value); NXOpen.Assemblies.Component copyComp = AssmbliesUtils.MoveCompCopyPart(eleComp, movePt, work.WorkMatr); AssmbliesUtils.MakeUnique(copyComp, name); ElectrodeInfo newInfo = this.SetEleInfo(eleModel.EleInfo); newInfo.SetAttribute(copyComp.Prototype as Part); } catch (Exception ex) { //---- Enter your exception handling code here ----- errorCode = 1; theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(errorCode); }
private ElectrodeInfo SetEleInfo(ElectrodeInfo info) { info.Positioning = this.StrName.Value.ToUpper(); info.EleSetValue[0] = info.EleSetValue[0] + this.double_x.Value; info.EleSetValue[1] = info.EleSetValue[1] + this.double_y.Value; info.EleSetValue[2] = info.EleSetValue[2] + this.double_z.Value; info.Positioning = this.StrName.Value.ToUpper(); return(info); }
public ElectrodePart(ElectrodeInfo eleInfo, MoldInfoModel moldInfo, ElectrodeHeadInfo head, Matrix4 mat) { this.eleMatr = mat; this.eleInfo = eleInfo; this.moldInfo = moldInfo; this.head = head; elePart = new CreateElectrodePart(head.ConditionModel.Work.WorkpieceDirectoryPath, this.head.ConditionModel.Work.WorkNumber , eleInfo, moldInfo, mat); }
public ElectrodeCAMInfo(ElectrodeModel model) { this.Info = model.EleInfo; AnalyzeElectrode analyze = new AnalyzeElectrode(model); this.MinDim = analyze.GetMinDis(); builder = analyze.AnalyzeBody(); this.BaseFace = builder.AnalyzeFaces[1].FaceData; this.BaseSubfaceFace = builder.AnalyzeFaces[0].FaceData; this.MinDia = 2 * GetBaseMinDia(BaseFace.Face); this.BasePlanarPlanarBoundary = new PlanarBoundary(this.BaseFace.Face); }
public List <string> InterferenceBulider() { List <string> err = new List <string>(); Matrix4 inv = this.work.Info.Matr.GetInversMatrix(); CartesianCoordinateSystem csys = BoundingBoxUtils.CreateCoordinateSystem(this.work.Info.Matr, inv); foreach (Component eleCt in GetEleAllComp()) { ElectrodeInfo info = ElectrodeInfo.GetAttribute(eleCt); AskSetVaule(csys, info.AllInfo.SetValue, eleCt, ref err); Interference(eleCt, info.AllInfo.Name.EleName, info.AllInfo.SetValue.Positioning, "", ref err); if (MoveElePart(eleCt, info.AllInfo.Pitch, -1)) { Interference(eleCt, info.AllInfo.Name.EleName, info.AllInfo.SetValue.Positioning, "Pitch", ref err); MoveElePart(eleCt, info.AllInfo.Pitch, 1); } } return(err); }
/// <summary> /// 设置对话框显示 /// </summary> private void SetDisp(NXOpen.Assemblies.Component ct) { if (ParentAssmblieInfo.IsElectrode(ct)) { this.groupEle.Show = true; info = ElectrodeInfo.GetAttribute(ct); //this.strMoldNumber.Show = false; // this.strWorkpieceNumber.Show = false; // this.strEditionNumber.Show = false; this.groupWorkpiece.Show = false; this.groupWork.Show = false; ElectrodeInfo eleInfo = info as ElectrodeInfo; string temp = info.MoldInfo.MoldNumber + "-" + info.MoldInfo.WorkpieceNumber; this.strEleName.Value = temp; this.strEleName1.Value = eleInfo.AllInfo.Name.EleName.Substring(temp.Length, eleInfo.AllInfo.Name.EleName.Length - temp.Length); this.strEleEditionNumber.Value = eleInfo.AllInfo.Name.EleEditionNumber; } else if (ParentAssmblieInfo.IsWorkpiece(ct)) { info = WorkPieceInfo.GetAttribute(ct); this.groupWorkpiece.Show = true; this.groupEle.Show = false; this.groupWork.Show = false; this.strMoldNumber.Value = info.MoldInfo.MoldNumber; this.strWorkpieceNumber.Value = info.MoldInfo.WorkpieceNumber; this.strEditionNumber.Value = info.MoldInfo.EditionNumber; } else if (ParentAssmblieInfo.IsWork(ct)) { info = WorkInfo.GetAttribute(ct); this.groupWork.Show = true; this.groupEle.Show = false; this.groupWorkpiece.Show = false; this.intWorkNumber.Value = (info as WorkInfo).WorkNumber; } else if (!ParentAssmblieInfo.IsParent(ct)) { this.groupWorkpiece.Show = true; this.groupEle.Show = false; this.strWorkpieceNumber.Value = ct.Name; } }
/// <summary> /// 获取单齿设定的距离 /// </summary> /// <param name="newInfo"></param> /// <param name="oldInfo"></param> /// <returns></returns> private Point3d GetSingleToothDis(ElectrodeInfo newInfo, ElectrodeInfo oldInfo, Point3d oldPt) { Point3d newPt = new Point3d(newInfo.EleSetValue[0], newInfo.EleSetValue[1], newInfo.EleSetValue[2]); if (newInfo.PitchXNum > 0) { newPt.X = newPt.X - newInfo.PitchX * (newInfo.PitchXNum - 1) / 2; } if (newInfo.PitchYNum > 0) { newPt.Y = newPt.Y - newInfo.PitchY * (newInfo.PitchYNum - 1) / 2; } if (newInfo.PitchXNum > 0) { oldPt.X = oldPt.X - oldInfo.PitchX * (oldInfo.PitchXNum - 1) / 2; } if (newInfo.PitchYNum > 0) { oldPt.Y = oldPt.Y - oldInfo.PitchY * (oldInfo.PitchYNum - 1) / 2; } return(new Point3d(newPt.X - oldPt.X, newPt.Y - oldPt.Y, newPt.Z - oldPt.Z)); }
/// <summary> /// 结束事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (oldValue != this.dataGridView.CurrentCell.Value) { ElectrodeBomBuilder bom; if (dataGridView.CurrentCellAddress.X == 4 || dataGridView.CurrentCellAddress.X == 5 || dataGridView.CurrentCellAddress.X == 6 || dataGridView.CurrentCellAddress.X == 7) { double x = Convert.ToDouble(dataGridView.Rows[e.RowIndex].Cells[4].Value); int xNumber = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[5].Value); double y = Convert.ToDouble(dataGridView.Rows[e.RowIndex].Cells[6].Value); int yNumber = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[7].Value); string material = dataGridView.Rows[e.RowIndex].Cells[16].Value.ToString(); Point3d setPt = ElectrodeBomBuilder.GetSetValue(x, xNumber, y, yNumber, oldInfo); dataGridView.Rows[e.RowIndex].Cells[1].Value = setPt.X.ToString("f3"); dataGridView.Rows[e.RowIndex].Cells[2].Value = setPt.Y.ToString("f3"); int[] pre = ElectrodeBomBuilder.GetPreparation(x, xNumber, y, yNumber, material, oldInfo); dataGridView.Rows[e.RowIndex].Cells[18].Value = pre[0].ToString(); dataGridView.Rows[e.RowIndex].Cells[19].Value = pre[1].ToString(); } DataRow dr = (dataGridView.Rows[e.RowIndex].DataBoundItem as DataRowView).Row; //获取数据 ElectrodeInfo newInfo = ElectrodeInfo.GetEleInfo(dr); bom = new ElectrodeBomBuilder(newInfo, this.assemble); if (!builders.Exists(a => a.Model[0].EleInfo.EleName == newInfo.EleName)) { this.builders.Add(bom); } else { ElectrodeBomBuilder bu = builders.Find(a => a.Model[0].EleInfo.EleName == newInfo.EleName); this.builders.Remove(bu); this.builders.Add(bom); } } }
public void CreateEle(ElectrodeInfo eleInfo) { UserInfoSingleton user = UserInfoSingleton.GetInstance(); if (user.UserInfo == null) { return; } this.eleInfo = eleInfo; this.eleInfo.EleHeadDis[0] = Math.Round(this.head.DisPt.X, 3); this.eleInfo.EleHeadDis[1] = Math.Round(this.head.DisPt.Y, 3); this.eleInfo.EleMinDim = head.AskMinDim(); Matrix4 workMat = this.model.Work.WorkMatr; double zHeight = setValue.GetZHeight(eleInfo.Extrudewith); Matrix4 mat = setValue.GetEleMatr(eleInfo.Preparation, GetCenter()); this.model.Work.MoldInfo.CreatedDate = DateTime.Now.ToString("yyyy-MM-dd"); this.model.Work.MoldInfo.CreatorName = user.UserInfo.UserName; ElectrodePart elePart = new ElectrodePart(eleInfo, this.model.Work.MoldInfo, this.head, mat); elePart.CreateElectrode(eleInfo.ZDatum, zHeight, Expression); }
private void AlterElectrode(ElectrodeInfo newEleInfo, ElectrodeModel model) { // Part workPart = Session.GetSession().Parts.Work; PartUtils.SetPartDisplay(work.PartTag); double[] temp = new double[3]; for (int i = 0; i < 3; i++) { temp[i] = AttributeUtils.GetAttrForDouble(model.PartTag, "EleSetValue", i); } Point3d oldPt = new Point3d(temp[0], temp[1], temp[2]); Point3d newPt = new Point3d(newEleInfo.EleSetValue[0], newEleInfo.EleSetValue[1], newEleInfo.EleSetValue[2]); Point3d dis = GetSingleToothDis(newEleInfo, model.EleInfo, oldPt); // newEleInfo.Positioning = model.EleInfo.Positioning; string pos = model.EleInfo.Positioning; model.EleInfo = newEleInfo; newEleInfo.SetAttribute(model.PartTag); AttributeUtils.AttributeOperation("Positioning", pos, model.PartTag); if (!UMathUtils.IsEqual(oldPt, newPt)) { NXOpen.Assemblies.Component ct = AssmbliesUtils.GetPartComp(work.PartTag, model.PartTag); PartUtils.SetPartWork(ct); Vector3d move = new Vector3d(0, 0, 0); move.X = newPt.X - oldPt.X - dis.X; move.Y = newPt.Y - oldPt.Y - dis.Y; Body[] bodys = model.PartTag.Bodies.ToArray(); if (bodys.Length > 1) { AlterMove(model); DeleteObject.UpdateObject(); CreateUnite(bodys); } PartUtils.SetPartWork(null); AssmbliesUtils.MoveCompPart(ct, move, this.work.WorkMatr); } DeleteObject.UpdateObject(); }
public static int[] GetPreparation(double x, int xNumber, double y, int yNumber, string material, ElectrodeInfo eleInfo) { Point3d oldPt = new Point3d(eleInfo.Preparation[0], eleInfo.Preparation[1], eleInfo.Preparation[2]); if (eleInfo.PitchX != 0 && eleInfo.PitchXNum > 1) { oldPt.X = oldPt.X - eleInfo.PitchX * (eleInfo.PitchXNum - 1); } if (eleInfo.PitchY != 0 && eleInfo.PitchYNum > 1) { oldPt.Y = oldPt.Y - eleInfo.PitchY * (eleInfo.PitchYNum - 1); } Point3d newPt = new Point3d(oldPt.X, oldPt.Y, oldPt.Z); if (x != 0 && xNumber > 1) { newPt.X = oldPt.X + x * (xNumber - 1); } if (y != 0 && yNumber > 1) { newPt.Y = oldPt.Y + y * (yNumber - 1); } int[] temp = new int[3] { (int)newPt.X, (int)newPt.Y, (int)newPt.Z }; EletrodePreparation pre; if (material.Equals("紫铜")) { pre = new EletrodePreparation("CuLength", "CuWidth"); } else { pre = new EletrodePreparation("WuLength", "WuWidth"); } pre.GetPreparation(ref temp); return(temp); }
public CreateElectrodePart(string filePath, int workNum, ElectrodeInfo info, MoldInfoModel moldInfo, Matrix4 mat, Point3d center) { Model = new ElectrodeModel(filePath, workNum, info, moldInfo, mat, center); }
public List <string> Replace() { List <string> err = new List <string>(); Part part; bool anyPartsModified; PartSaveStatus saveStatus; Session theSession = Session.GetSession(); if (oldCt != null && newCt != null && oldCt.Equals(newCt)) { return(err); } // AllUpdeteDrawing(); if ((part = ReplacePart.Replace(assm.Edm, info)) != null) { info.SetAttribute(part); theSession.Parts.SaveAll(out anyPartsModified, out saveStatus); err.Add("修改" + assm.Edm.AssembleName + "成功!"); } foreach (ElectrodeModel em in assm.Electrodes) { if ((part = ReplacePart.Replace(em, info)) != null) { info.SetAttribute(part); ElectrodeInfo eleInfo = new ElectrodeInfo(); eleInfo.GetAttribute(part); string oldEleName = eleInfo.EleName; string olddrwPath = em.WorkpieceDirectoryPath + oldEleName + "_dwg.prt"; string newEleName = oldEleName.Replace(em.MoldInfo.MoldNumber + "-" + em.MoldInfo.WorkpieceNumber, info.MoldNumber + "-" + info.WorkpieceNumber); eleInfo.EleName = newEleName; if (isBorrow) { eleInfo.BorrowName = oldEleName; } eleInfo.SetAttribute(part); theSession.Parts.SaveAll(out anyPartsModified, out saveStatus); err.Add("修改" + em.AssembleName + "成功!"); } } foreach (WorkModel wm in assm.Works) { if ((part = ReplacePart.Replace(wm, info)) != null) { info.SetAttribute(part); theSession.Parts.SaveAll(out anyPartsModified, out saveStatus); err.Add("修改" + wm.AssembleName + "成功!"); } } foreach (ElectrodeModel em in assm.Electrodes) { Part workPart = Session.GetSession().Parts.Work; ElectrodeInfo eleInfo = em.EleInfo; string oldEleName = eleInfo.EleName; string olddrwPath = em.WorkpieceDirectoryPath + oldEleName + "_dwg.prt"; if (File.Exists(olddrwPath)) { string newEleName = oldEleName.Replace(em.MoldInfo.MoldNumber + "-" + em.MoldInfo.WorkpieceNumber, info.MoldNumber + "-" + info.WorkpieceNumber); eleInfo.EleName = newEleName; if (isBorrow) { eleInfo.BorrowName = oldEleName; } if (File.Exists(olddrwPath.Replace(oldEleName, newEleName))) { File.Delete(olddrwPath.Replace(oldEleName, newEleName)); } File.Move(olddrwPath, olddrwPath.Replace(oldEleName, newEleName)); NXOpen.PartLoadStatus partLoadStatus1; BasePart part1 = Session.GetSession().Parts.OpenBase(olddrwPath.Replace(oldEleName, newEleName), out partLoadStatus1); PartUtils.SetPartDisplay(part1 as Part); eleInfo.SetAttribute(part1 as Part); NXOpen.Assemblies.Component comp = part1.ComponentAssembly.RootComponent.GetChildren()[0]; string workName = comp.Name.Replace(em.MoldInfo.MoldNumber + "-" + em.MoldInfo.WorkpieceNumber, info.MoldNumber + "-" + info.WorkpieceNumber); Basic.AssmbliesUtils.ReplaceComp(comp, em.WorkpieceDirectoryPath + workName + ".prt", workName); theSession.Parts.SaveAll(out anyPartsModified, out saveStatus); PartUtils.SetPartDisplay(workPart); err.Add("修改" + em.AssembleName + "_dwg" + "成功!"); } } return(err); }
/// <summary> /// 初始化 /// </summary> private void Initialize() { this.textBox_MoldNumber.Text = assemble.Asm.MoldInfo.MoldNumber; this.textBox_PartNumber.Text = assemble.Asm.MoldInfo.WorkpieceNumber; this.textBox_EditionNumber.Text = assemble.Asm.MoldInfo.EditionNumber; EleType.Items.AddRange(GetContr("EleType").ToArray()); Material.Items.AddRange(GetContr("Material").ToArray()); Condition.Items.AddRange(GetContr("Condition").ToArray()); dataGridView.Columns["EleX"].Visible = false; //隐藏列 dataGridView.Columns["EleY"].Visible = false; dataGridView.Columns["EleZ"].Visible = false; dataGridView.Columns["EleName"].ReadOnly = true; //只读列 dataGridView.RowsDefaultCellStyle.BackColor = Color.Bisque; dataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; //交替行不同颜色 dataGridView.Columns[1].Frozen = true; //冻结首列 dataGridView.AutoGenerateColumns = false; assemble.Electrodes.Sort(); List <ElectrodeInfo> infos = new List <ElectrodeInfo>(); foreach (ElectrodeModel model in assemble.Electrodes) { if (model.EleInfo.Positioning == "") { infos.Add(model.EleInfo); } } DataTable table = ElectrodeInfo.GetDataTable(infos); dataGridView.DataSource = table; #region //foreach (ElectrodeModel ele in assemble.Electrodes) //{ // ElectrodeInfo info = ele.EleInfo; // if (info.Positioning == "") // { // int index = dataGridView.Rows.Add(); // dataGridView.Rows[index].Cells[0].Value = info.EleName; // dataGridView.Rows[index].Cells[1].Value = info.EleSetValue[0]; // dataGridView.Rows[index].Cells[2].Value = info.EleSetValue[1]; // dataGridView.Rows[index].Cells[3].Value = info.EleSetValue[2]; // dataGridView.Rows[index].Cells[4].Value = info.PitchX; // dataGridView.Rows[index].Cells[5].Value = info.PitchXNum; // dataGridView.Rows[index].Cells[6].Value = info.PitchY; // dataGridView.Rows[index].Cells[7].Value = info.PitchYNum; // dataGridView.Rows[index].Cells[8].Value = info.CrudeInter.ToString("f3"); // dataGridView.Rows[index].Cells[9].Value = info.CrudeNum; // dataGridView.Rows[index].Cells[10].Value = info.DuringInter.ToString("f3"); // dataGridView.Rows[index].Cells[11].Value = info.DuringNum; // dataGridView.Rows[index].Cells[12].Value = info.FineInter.ToString("f3"); // dataGridView.Rows[index].Cells[13].Value = info.FineNum; // dataGridView.Rows[index].Cells[14].Value = info.EleType; // dataGridView.Rows[index].Cells[15].Value = info.Ch; // dataGridView.Rows[index].Cells[16].Value = info.Material; // dataGridView.Rows[index].Cells[17].Value = info.Condition; // dataGridView.Rows[index].Cells[18].Value = info.Preparation[0]; // dataGridView.Rows[index].Cells[19].Value = info.Preparation[1]; // dataGridView.Rows[index].Cells[20].Value = info.Preparation[2]; // dataGridView.Rows[index].Cells[21].Value = info.BorrowName; // } //} #endregion }
/// <summary> /// 获取改变的设定值 /// </summary> /// <param name="x"></param> /// <param name="xNumber"></param> /// <param name="y"></param> /// <param name="yNumber"></param> /// <param name="eleInfo"></param> /// <returns></returns> public static Point3d GetSetValue(double x, int xNumber, double y, int yNumber, ElectrodeInfo eleInfo) { Point3d oldSet = new Point3d(eleInfo.EleSetValue[0], eleInfo.EleSetValue[1], eleInfo.EleSetValue[2]); if (eleInfo.PitchX != 0 && eleInfo.PitchXNum > 1) { oldSet.X = oldSet.X - eleInfo.PitchX * (eleInfo.PitchXNum - 1) / 2; } if (eleInfo.PitchY != 0 && eleInfo.PitchYNum > 1) { oldSet.Y = oldSet.Y - eleInfo.PitchY * (eleInfo.PitchYNum - 1) / 2; } Point3d newSet = new Point3d(eleInfo.EleSetValue[0], eleInfo.EleSetValue[1], eleInfo.EleSetValue[2]); if (x != 0 && xNumber > 1) { newSet.X = oldSet.X + x * (xNumber - 1) / 2; } if (y != 0 && yNumber > 1) { newSet.Y = oldSet.Y + y * (yNumber - 1) / 2; } return(newSet); }
public ElectrodePartBuilder(ElectrodeInfo eleInfo, string directoryPath) { this.info = eleInfo; this.EleModel = new ElectrodeModel(eleInfo); this.directoryPath = directoryPath; }