增加保温层和整理管线的功能,修复自动保存功能等修复多个bug
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ACadSharp" Version="1.0.1" />
|
||||
<PackageReference Include="CommunityToolkit.Common" Version="8.3.2" />
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.3.2" />
|
||||
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.3.2" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="OpenAI" Version="2.0.0" />
|
||||
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,26 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ACadSharp.Entities;
|
||||
|
||||
using CommunityToolkit.Diagnostics;
|
||||
|
||||
using CSMath;
|
||||
|
||||
using OpenAI.Chat;
|
||||
|
||||
namespace ConsoleApp
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string str = "";
|
||||
double a = 10.0;
|
||||
//TEST();
|
||||
|
||||
ChatClient client = new ChatClient("gpt-4o", Environment.GetEnvironmentVariable("OPEN_API_KEY"));
|
||||
ChatCompletion completion = client.CompleteChat("say 'this is a test.'");
|
||||
Console.WriteLine($"[ASSISTANT]:{completion.Content[0].Text}");
|
||||
}
|
||||
|
||||
private static void TEST()
|
||||
{
|
||||
var str = "";
|
||||
var a = 10.0;
|
||||
double b = 100;
|
||||
|
||||
Debug.Assert(a == b);
|
||||
//确保str满足条件才能继续执行,不满足即抛出异常
|
||||
Guard.IsNotNullOrEmpty(str);//抛出异常
|
||||
Guard.IsLessThan(a,b);
|
||||
Guard.IsLessThan(a, b);
|
||||
}
|
||||
|
||||
public void ReadCAD()
|
||||
{
|
||||
var file = @"D:\Users\Zhanggg\Desktop\Drawing1.dwg";
|
||||
var cad = new ACadSharp.IO.DwgReader(file).Read();
|
||||
var polylines = cad.Entities.OfType<LwPolyline>().Where(l => l.Layer.Name == "RQ");
|
||||
var sizes = cad.Entities.OfType<TextEntity>().Where(t => t.Layer.Name == "RQ");
|
||||
var entities = cad.Entities.OfType<Insert>().Where(i => i.Layer.Name == "0" || i.Layer.Name == "RQ" || i.Layer.Name == "GAS" || i.Layer.Name == "燃具");
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("多段线");
|
||||
foreach (var line in polylines)
|
||||
{
|
||||
var first = line.Vertices.First();
|
||||
var last = line.Vertices.Last();
|
||||
sb.AppendLine($"起点:{first.Location};终点:{last.Location}");
|
||||
}
|
||||
foreach (var insert in entities)
|
||||
{
|
||||
if (insert.Block.Name == "立管0")
|
||||
{
|
||||
var temp = double.MaxValue;
|
||||
string t = default;
|
||||
foreach (var item in sizes)
|
||||
{
|
||||
var current = item.InsertPoint.DistanceFrom(insert.InsertPoint);
|
||||
if (current < temp)
|
||||
{
|
||||
temp = current;
|
||||
t = item.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
//盲板
|
||||
else if (insert.Block.Name == "盲板")
|
||||
{
|
||||
|
||||
}
|
||||
//旋塞阀
|
||||
else if (insert.Block.Name.Contains("旋塞"))
|
||||
{
|
||||
|
||||
}
|
||||
//商业预留,法兰球阀
|
||||
else if (insert.Block.Name.Contains("法兰球阀"))
|
||||
{
|
||||
|
||||
}
|
||||
//锁闭型螺纹铜球阀
|
||||
else if (insert.Block.Name.Contains("户内阀"))
|
||||
{
|
||||
|
||||
}
|
||||
//燃气表
|
||||
else if (insert.Block.Name == "计量表")
|
||||
{
|
||||
|
||||
}
|
||||
//自闭阀
|
||||
else if (insert.Block.Name == "自闭阀")
|
||||
{
|
||||
|
||||
}
|
||||
//热水器
|
||||
else if (insert.Block.Name == "RSQ")
|
||||
{
|
||||
|
||||
}
|
||||
//燃气灶
|
||||
else if (insert.Block.Name == "燃气灶")
|
||||
{
|
||||
|
||||
}
|
||||
//球阀+丝堵
|
||||
else if (insert.Block.Name.Contains("丝堵"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
sb.AppendLine($"图层名:{insert.Layer.Name};图块名:{insert.Block.Name};插入点:{insert.InsertPoint}");
|
||||
}
|
||||
File.WriteAllText(@"D:\Users\Zhanggg\Desktop\Drawing1.dwg" + ".txt", sb.ToString(), Encoding.UTF8);
|
||||
//foreach (var insert in entities)
|
||||
//{
|
||||
// var blocks = insert.Block.Entities.OfType<Dimension>().Where(d=>d.Text.Contains("52D"));
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user