yyf update

This commit is contained in:
Zhuangkh 2024-09-04 17:44:01 +08:00
parent ddc463824b
commit 57afe56c77
3 changed files with 90 additions and 28 deletions

View File

@ -86,9 +86,10 @@ namespace uBIMEarthTools.Commands
if (transGroup.Start() == TransactionStatus.Started) if (transGroup.Start() == TransactionStatus.Started)
{ {
Transaction transaction = new Transaction(doc, "uBIM"); Transaction transaction = new Transaction(doc, "uBIM");
transaction.Start();
int k = 0; int k = 0;
while (true) while (k<1000)
{ {
#region #region
XYZ origin_k = pointFirstTable_L + new XYZ(k * (pointSecTable.X - pointFirstTable_L.X), 0, 0);//当前图框左上角坐标 XYZ origin_k = pointFirstTable_L + new XYZ(k * (pointSecTable.X - pointFirstTable_L.X), 0, 0);//当前图框左上角坐标
@ -100,7 +101,7 @@ namespace uBIMEarthTools.Commands
#region textnote #region textnote
foreach (TextNote tntmp in textnoteList) foreach (TextNote tntmp in textnoteList)
{ {
if (tntmp.Coord.X > origin_k.X && tntmp.Coord.X < origin_k.X + (pointFirstTable_R.X - pointFirstTable_L.X) && if (tntmp.Coord.X > origin_k.X && tntmp.Coord.X < origin_k.X + (pointFirstTable_R.X - pointFirstTable_L.X) &&
tntmp.Coord.Y > origin_k.Y - (pointFirstTable_L.Y - pointFirstTable_R.Y) && tntmp.Coord.Y < origin_k.Y) tntmp.Coord.Y > origin_k.Y - (pointFirstTable_L.Y - pointFirstTable_R.Y) && tntmp.Coord.Y < origin_k.Y)
{ {
@ -120,15 +121,24 @@ namespace uBIMEarthTools.Commands
textnoteKList.Add(tntmp); textnoteKList.Add(tntmp);
} }
} }
foreach (TextNote tntmp in textnoteKList)
{
tntmp.Text = tntmp.Text.Replace("X=", "").Replace("Y=", "").Replace("m", "").Trim();
}
if (textnoteKList.Count == 0) //获取不到时,跳出 if (textnoteKList.Count == 0) //获取不到时,跳出
{
break; break;
}
#endregion #endregion
#region ,,X,Y #region ,,X,Y
TextNote zkbhTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointNum.X - pointFirstTable_L.X, pointNum.Y, pointNum.Z), textnoteKList, 4); //钻孔编号 TextNote zkbhTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointNum.X - pointFirstTable_L.X, pointNum.Y, pointNum.Z), textnoteKList, 100); //钻孔编号
TextNote kkbgTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointLevel.X - pointFirstTable_L.X, pointLevel.Y, pointLevel.Z), textnoteKList, 4); //孔口标高 TextNote kkbgTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointLevel.X - pointFirstTable_L.X, pointLevel.Y, pointLevel.Z), textnoteKList, 100); //孔口标高
TextNote xTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointX.X - pointFirstTable_L.X, pointX.Y, pointX.Z), textnoteKList, 4); //孔口X TextNote xTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointX.X - pointFirstTable_L.X, pointX.Y, pointX.Z), textnoteKList, 100); //孔口X
TextNote yTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointY.X - pointFirstTable_L.X, pointY.Y, pointY.Z), textnoteKList, 4); //孔口Y TextNote yTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointY.X - pointFirstTable_L.X, pointY.Y, pointY.Z), textnoteKList, 100); //孔口Y
//钻孔编号跟孔口标高不对应时,跳至下个图框 //钻孔编号跟孔口标高不对应时,跳至下个图框
if (zkbhTn == null || kkbgTn == null) if (zkbhTn == null || kkbgTn == null)
@ -142,6 +152,8 @@ namespace uBIMEarthTools.Commands
#region 3-1(:X公差:4mm;Y公差:2mm;:null) #region 3-1(:X公差:4mm;Y公差:2mm;:null)
foreach (TextNote tntmp1 in textnoteKList) foreach (TextNote tntmp1 in textnoteKList)
{ {
tntmp1.Text = Common.NameByRule(tntmp1.Text);
if (tntmp1.Coord.X > origin_k.X + pointLayer_R.X - pointFirstTable_L.X)//排除超出范围的 if (tntmp1.Coord.X > origin_k.X + pointLayer_R.X - pointFirstTable_L.X)//排除超出范围的
continue; continue;
if (delTextnoteList.Contains(tntmp1))//排除已剔除的 if (delTextnoteList.Contains(tntmp1))//排除已剔除的
@ -150,6 +162,8 @@ namespace uBIMEarthTools.Commands
continue; continue;
foreach (TextNote tntmp2 in textnoteKList) foreach (TextNote tntmp2 in textnoteKList)
{ {
tntmp2.Text = Common.NameByRule(tntmp2.Text);
if (delTextnoteList.Contains(tntmp2))//排除已剔除的 if (delTextnoteList.Contains(tntmp2))//排除已剔除的
continue; continue;
if (tntmp2.Coord.X > origin_k.X + pointLayer_R.X - pointFirstTable_L.X)//排除超出范围的 if (tntmp2.Coord.X > origin_k.X + pointLayer_R.X - pointFirstTable_L.X)//排除超出范围的
@ -163,18 +177,20 @@ namespace uBIMEarthTools.Commands
if (Math.Abs(tntmp1.Coord.X - tntmp2.Coord.X) < 4 / 304.8 && if (Math.Abs(tntmp1.Coord.X - tntmp2.Coord.X) < 4 / 304.8 &&
Math.Abs(tntmp1.Coord.Y - tntmp2.Coord.Y) < 2 / 304.8)// &&Math.Abs(tntmp1.Height - tntmp2.Height) > 0.00001 / 304.8) Math.Abs(tntmp1.Coord.Y - tntmp2.Coord.Y) < 2 / 304.8)// &&Math.Abs(tntmp1.Height - tntmp2.Height) > 0.00001 / 304.8)
{ {
transaction.Start(); //transaction.Start();
if (tntmp1.Coord.X < tntmp2.Coord.X) if (tntmp1.Coord.X < tntmp2.Coord.X)
{ {
tntmp1.Text = tntmp1.Text + "-" + tntmp2.Text; string s = tntmp1.Text.Trim() + "-" + tntmp2.Text.Trim();
tntmp1.Text = Common.NameByRule(s);
delTextnoteList.Add(tntmp2); delTextnoteList.Add(tntmp2);
} }
else else
{ {
tntmp2.Text = tntmp2.Text + "-" + tntmp1.Text; string s = tntmp2.Text.Trim() + "-" + tntmp1.Text.Trim();
tntmp2.Text = Common.NameByRule(s);
delTextnoteList.Add(tntmp1); delTextnoteList.Add(tntmp1);
} }
transaction.Commit(); //transaction.Commit();
} }
} }
} }
@ -199,7 +215,7 @@ namespace uBIMEarthTools.Commands
dcgcList = dcgcList.OrderByDescending(x => x.Coord.Y).ToList(); dcgcList = dcgcList.OrderByDescending(x => x.Coord.Y).ToList();
#endregion #endregion
#region , #region
Borehole bh; Borehole bh;
if (boreholes.Count != 0 && boreholes.Select(x => x.Name).ToList().Contains(zkbhTn.Text)) if (boreholes.Count != 0 && boreholes.Select(x => x.Name).ToList().Contains(zkbhTn.Text))
{ {
@ -208,6 +224,22 @@ namespace uBIMEarthTools.Commands
else else
{ {
bh = new Borehole { Name = zkbhTn.Text }; bh = new Borehole { Name = zkbhTn.Text };
double xxx = 0;
double yyy = 0;
double zzz = 0;
try
{
xxx = Convert.ToDouble(xTn.Text);
yyy = Convert.ToDouble(yTn.Text);
zzz = Convert.ToDouble(kkbgTn.Text);
}
catch
{
k++;
MessageBox.Show(k+ "\n" +xTn.Text + "\n" + yTn.Text + "\n" + kkbgTn.Text, "向日葵", MessageBoxButtons.OK);
continue;
}
bh.ValueList.Add(new GeologyLayer(dcbhList.First().Text, new XYZ(Convert.ToDouble(xTn.Text), Convert.ToDouble(yTn.Text), Convert.ToDouble(kkbgTn.Text)))); bh.ValueList.Add(new GeologyLayer(dcbhList.First().Text, new XYZ(Convert.ToDouble(xTn.Text), Convert.ToDouble(yTn.Text), Convert.ToDouble(kkbgTn.Text))));
boreholes.Add(bh); boreholes.Add(bh);
} }
@ -216,18 +248,31 @@ namespace uBIMEarthTools.Commands
#region #region
for (int i = 0; i < (dcbhList.Count < dcgcList.Count ? dcbhList.Count : dcgcList.Count); i++) for (int i = 0; i < (dcbhList.Count < dcgcList.Count ? dcbhList.Count : dcgcList.Count); i++)
{ {
string dcbh_i = dcbhList[i].Text.Replace("\r", "").Replace("\n", ""); string dcmc_i = "default";
string dcmc_i = dcgcList[i].Text.Replace("\r", "").Replace("\n", ""); string dcbh_i = "default";
double x = Convert.ToDouble(xTn.Text); //MessageBox.Show(xTn.Text + "\n" + yTn.Text + "\n" + dcbh_i + "\n" + dcmc_i, "向日葵", MessageBoxButtons.OK);
double y = Convert.ToDouble(yTn.Text);
double z = Convert.ToDouble(dcmc_i); try
GeologyLayer geologyLayer = new GeologyLayer(dcbh_i, new XYZ(x, y, z)); {
bh.ValueList.Add(geologyLayer); dcbh_i = dcbhList[i].Text.Trim();
dcmc_i = dcgcList[i].Text.Trim();
double x = Convert.ToDouble(xTn.Text);
double y = Convert.ToDouble(yTn.Text);
double z = Convert.ToDouble(dcmc_i);
GeologyLayer geologyLayer = new GeologyLayer(dcbh_i, new XYZ(x, y, z));
bh.ValueList.Add(geologyLayer);
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message, "向日葵", MessageBoxButtons.OK);
}
} }
#endregion #endregion
k++; k++;
} }
transaction.Commit();
} }
status = transGroup.RollBack(); status = transGroup.RollBack();
#endregion #endregion
@ -241,7 +286,7 @@ namespace uBIMEarthTools.Commands
ExcelPackage.LicenseContext = LicenseContext.NonCommercial; ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
FileInfo fileInfo = new FileInfo(localFilePath); FileInfo fileInfo = new FileInfo(localFilePath);
using (ExcelPackage excelPackage = new ExcelPackage(fileInfo)) using (ExcelPackage excelPackage = new ExcelPackage())
{ {
//using (FileStream fs = new FileStream(localFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) //using (FileStream fs = new FileStream(localFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
//{ //{
@ -281,7 +326,7 @@ namespace uBIMEarthTools.Commands
} }
} }
excelPackage.Save(); excelPackage.SaveAs(fileInfo);
//} //}
//File.WriteAllBytes(localFilePath, excelPackage.GetAsByteArray()); //File.WriteAllBytes(localFilePath, excelPackage.GetAsByteArray());
} }

View File

@ -2,7 +2,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.Reflection; using System.Reflection;
[assembly: MethodTimer.Time] //[assembly: MethodTimer.Time]
namespace uBIMEarthTools namespace uBIMEarthTools
{ {
public static class MethodTimeLogger public static class MethodTimeLogger

View File

@ -243,13 +243,23 @@ namespace uBIMEarthTools.Utils
{ {
TextNote tn = null; TextNote tn = null;
XYZ newXyz = new XYZ(p.X, p.Y, textnoteList[0].Coord.Z); XYZ newXyz = new XYZ(p.X, p.Y, textnoteList[0].Coord.Z);
foreach (TextNote tntmp in textnoteList) List<string> lines = new List<string>();
{
if (Math.Round(tntmp.Coord.DistanceTo(newXyz), 5) < (tolerance / 304.8)) textnoteList = textnoteList.FindAll(m => m.Text != "X =" && m.Text != "Y =").ToList();
{ TextNote tntmp = textnoteList.OrderBy(m => m.Coord.DistanceTo(newXyz)).First();
tn = tntmp; if (Math.Round(tntmp.Coord.DistanceTo(newXyz), 5) < (tolerance / 304.8))
} tn = tntmp;
}
//foreach (TextNote tntmp in textnoteList)
//{
// string text = tntmp.Text;
// if (text == "X=" || text == "Y=")
// continue;
// if (Math.Round(tntmp.Coord.DistanceTo(newXyz), 5) < (tolerance / 304.8))
// {
// tn = tntmp;
// }
//}
return tn; return tn;
} }
public static void Swap<T>(ref T x, ref T y) public static void Swap<T>(ref T x, ref T y)
@ -258,5 +268,12 @@ namespace uBIMEarthTools.Utils
x = y; x = y;
y = temp; y = temp;
} }
public static string NameByRule(string s)
{
//①②③④⑤⑥⑦⑧⑨
string ss = s.Replace("--", "-").Replace("①","1").Replace("②", "2").Replace("③", "3").Replace("④", "4").Replace("⑤", "5").Replace("⑥", "6").Replace("⑦", "7").Replace("⑧", "8").Replace("⑨", "9");
return ss;
}
} }
} }