功能更新

This commit is contained in:
GG Z
2026-02-12 21:29:00 +08:00
parent a9faf251be
commit 5f1adc5ad2
341 changed files with 4293 additions and 1874 deletions

View File

@@ -1,17 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!--<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ShrlAlgoToolkit.RevitAddins.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<!--<appSettings>
<add key="FamilyPath" value="C:\ProgramData\Autodesk\RVT 2018\Libraries\China" />
<add key="SavePath" value="" />
<add key="ImgFormat" value="JPEGMedium" />
<add key="ImgSize" value="1920" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>-->
</configSections>-->
<!--<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
</startup>

View File

@@ -23,7 +23,7 @@ public static class WinDialogAssist
/// <param name="filterName">过滤器的名称</param>
/// <param name="extensions">仅扩展名,*代表所有文件</param>
/// <returns></returns>
public static FileDialog SetFilter(this FileDialog dialog, string filterName, params string[] extensions)
public static Microsoft.Win32.FileDialog SetFilter(this Microsoft.Win32.FileDialog dialog, string filterName, params string[] extensions)
{
if (extensions[0] == "*")
{

View File

@@ -1,3 +1,5 @@
global using ShrlAlgoToolkit.Core.Extensions;
global using ShrlAlgoToolkit.Revit.Assists;
global using ShrlAlgoToolkit.Revit.Extensions;
global using JetBrains.Annotations;
global using Autodesk.Revit.UI;

View File

@@ -1,10 +1,12 @@
using Autodesk.Revit.Attributes;
using Nice3point.Revit.Toolkit.External;
using ShrlAlgoToolkit.Core.Assists;
namespace ShrlAlgoToolkit.RevitAddins.ModelManager;
[Transaction(TransactionMode.Manual)]
[UsedImplicitly]
public class ModelCheckCmd : ExternalCommand
{
public override void Execute() => SingletonChildWindowManager.ShowOrActivate<ModelCheckView, ModelCheckViewModel>(UiApplication);//ModelCheckView view = SingletonViewAssist<ModelCheckView>.GetInstance(out var isNewCreate);//if (isNewCreate)//{// view.DataContext = new ModelCheckViewModel(uiApplication);// view.ShowAhead();//}//view.Activate();

View File

@@ -8,6 +8,7 @@ using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using JetBrains.Annotations;
using Microsoft.Win32;
using Nice3point.Revit.Toolkit.External.Handlers;
using ShrlAlgoToolkit.Core.Assists;
@@ -15,10 +16,10 @@ using ShrlAlgoToolkit.Core.Assists;
using ShrlAlgoToolkit.RevitAddins.Assists;
using ShrlAlgoToolkit.RevitAddins.Windows;
// ReSharper disable PossibleMultipleEnumeration
namespace ShrlAlgoToolkit.RevitAddins.ModelManager;
[UsedImplicitly]
public partial class ModelCheckViewModel : ObservableObject
{
private readonly CorrectReferLevelExecutes correctReferLevelExecutes;
@@ -62,7 +63,7 @@ public partial class ModelCheckViewModel : ObservableObject
// view3d = doc.OfClass<View3D>().FirstOrDefault(e => FilteredElementCollector.IsViewValidForElementIteration(doc, e.Id)) as View3D;
//}
var elements = doc.OfParentModelElements();
var typeInstancesGroups = elements.GroupBy(e => e.GetTypeId());
var typeInstancesGroups = elements.GroupBy(e => e.GetTypeId()).ToList();
if (IsCheckLevel)
{
var levels = doc.OfClass<Level>().OfType<Level>().OrderBy(l => l.Elevation);

View File

@@ -32,37 +32,64 @@ public class ExplodeDwgCmd : IExternalCommand
var element = Document.GetElement(refer);
var geoElem = element.get_Geometry(new Options() { ComputeReferences = true, DetailLevel = ViewDetailLevel.Fine });
var f = Document.OwnerFamily;
Document.Invoke(
_ =>
Document.InvokeGroup(
tg =>
{
foreach (var geoObj in geoElem)
{
if (geoObj is GeometryInstance instance)
Document.Invoke(
_ =>
{
foreach (var obj in instance.GetInstanceGeometry())
foreach (var geoObj in geoElem)
{
if (geoObj is GeometryInstance instance)
{
foreach (var obj in instance.GetInstanceGeometry())
{
try
{
if (obj is Solid solid && solid.Faces.Size > 0 && solid.Volume > 10e-6)
{
FreeFormElement.Create(Document, solid);//和分解的功能一样,仅保留几何信息
//try
//{
// // 如果是项目文档只能使用DirectShape创建适用于导入的几何体不能进行二次编辑
// // 如果是族文档使用FreeFormElement创建可以有更多的几何体支持支持编辑手柄族文档也支持DirectShape
// var shape = DirectShape.CreateElement(Document, f.FamilyCategory.Id);
// shape.SetShape([solid]);
//}
//catch (Exception)
//{
// FreeFormElement.Create(Document, solid);//和分解的功能一样,仅保留几何信息
//}
}
}
catch (Exception ex)
{
sb.AppendLine(ex.Message);
continue;
}
}
}
try
{
if (obj is Solid solid && solid.Faces.Size > 0 && solid.Volume > 10e-6)
if (geoObj is Solid topSolid && topSolid.Faces.Size > 0 && topSolid.Volume > 10e-6)
{
FreeFormElement.Create(Document, solid);//和分解的功能一样,仅保留几何信息
FreeFormElement.Create(Document, topSolid);//和分解的功能一样,仅保留几何信息
//try
//{
// // 如果是项目文档只能使用DirectShape创建适用于导入的几何体不能进行二次编辑
// // 如果是族文档使用FreeFormElement创建可以有更多的几何体支持支持编辑手柄族文档也支持DirectShape
// var shape = DirectShape.CreateElement(Document, f.FamilyCategory.Id);
// shape.SetShape([solid]);
// var directShape = DirectShape.CreateElement(Document, f.FamilyCategory.Id);
// directShape.SetShape([topSolid]);
//}
//catch (Exception)
//{
// FreeFormElement.Create(Document, solid);//和分解的功能一样,仅保留几何信息
// FreeFormElement.Create(Document, topSolid);
//}
}
}
catch (Exception ex)
@@ -71,36 +98,29 @@ public class ExplodeDwgCmd : IExternalCommand
continue;
}
}
}
try
{
if (geoObj is Solid topSolid && topSolid.Faces.Size > 0 && topSolid.Volume > 10e-6)
Document.Delete(element.Id);
});
MessageBox.Show("几何体炸开完成,请等待材质赋值完成", "提示");
Document.Invoke(
_ =>
{
FreeFormElement.Create(Document, topSolid);//和分解的功能一样,仅保留几何信息
//try
//{
// var directShape = DirectShape.CreateElement(Document, f.FamilyCategory.Id);
// directShape.SetShape([topSolid]);
//}
//catch (Exception)
//{
// FreeFormElement.Create(Document, topSolid);
//}
}
}
catch (Exception ex)
{
sb.AppendLine(ex.Message);
continue;
}
}
Document.Delete(element.Id);
});
var freeFormElements = Document.OfClass<FreeFormElement>().Cast<FreeFormElement>().ToList();
foreach (var form in freeFormElements)
{
var geoElement = form.get_Geometry(new Options() { ComputeReferences = true, DetailLevel = ViewDetailLevel.Fine });
foreach (var obj in geoElement)
{
if (obj is Solid solid && solid.Faces.Size > 0 && solid.Volume > 10e-6)
{
Face face = solid.Faces.get_Item(0);
Material material = Document.GetElement(face.MaterialElementId) as Material;
if (material != null)
form.get_Parameter(BuiltInParameter.MATERIAL_ID_PARAM).Set(material.Id);
}
}
}
});
},"炸开dwg");
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)

View File

@@ -143,7 +143,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NeoUI\Melskin\Melskin.csproj" />
<ProjectReference Include="..\Melskin\Melskin.csproj" />
<ProjectReference Include="..\ShrlAlgoToolkit.Core\ShrlAlgoToolkit.Core.csproj" />
<ProjectReference Include="..\ShrlAlgoToolkit.Mvvm\ShrlAlgoToolkit.Mvvm.csproj" />
</ItemGroup>
@@ -178,12 +178,6 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Views\" />
<Folder Include="ViewModels\" />
<Folder Include="Models\" />
<Folder Include="Commands\" />
</ItemGroup>
<Import Project="..\ShrlAlgoToolkit.Revit\ShrlAlgoToolkit.Revit.projitems" Label="Shared" />
<!-- <PropertyGroup>

View File

@@ -24,7 +24,7 @@ namespace ShrlAlgoToolkit.RevitAddins.UIRibbon;
//[Obfuscation(Exclude = true, ApplyToMembers = true)]
public class RvApp : ExternalApplication
{
private static readonly string TabName = Settings.Default.TabName;
private static readonly string TabName = Properties.Settings.Default.TabName;
private AsyncEventHandler saveHandler;
readonly System.Timers.Timer saveTimer = Variables.AutoSaveTimer;
private void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
@@ -59,7 +59,7 @@ public class RvApp : ExternalApplication
public override void OnStartup()
{
saveHandler = new();
UiApplication.CreateRibbonTab(Settings.Default.TabName);
UiApplication.CreateRibbonTab(Properties.Settings.Default.TabName);
var versionNumber = UiApplication.Application.VersionNumber;
var subVersionNumber = UiApplication.Application.SubVersionNumber;
@@ -72,7 +72,7 @@ public class RvApp : ExternalApplication
var ribbon = Autodesk.Windows.ComponentManager.Ribbon;
var rt = ribbon.Tabs.FirstOrDefault(tab => tab.Name == Settings.Default.TabName);
var rt = ribbon.Tabs.FirstOrDefault(tab => tab.Name == Properties.Settings.Default.TabName);
ribbon.Tabs.Remove(rt);
//foreach (var tab in ribbon.Tabs)
//{