大量更新

This commit is contained in:
GG Z
2025-12-23 21:35:54 +08:00
parent cd4733ee01
commit ceccab9abb
211 changed files with 9439 additions and 6578 deletions

View File

@@ -1,23 +1,24 @@
using Autodesk.Revit.Attributes;
using System.Text;
using System.Windows;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Nice3point.Revit.Toolkit.External;
namespace ShrlAlgoToolkit.RevitAddins.RvFamily;
/// <summary>
/// 炸开族中的dwg或嵌套族图元
/// </summary>
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class ExplodeDwgCmd : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
StringBuilder sb = new StringBuilder();
try
{
ExternalCommandData data = commandData;
Document Document = data.Application.ActiveUIDocument.Document;
UIDocument UiDocument = data.Application.ActiveUIDocument;
@@ -31,6 +32,7 @@ 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(
_ =>
{
@@ -40,42 +42,61 @@ public class ExplodeDwgCmd : IExternalCommand
{
foreach (var obj in instance.GetInstanceGeometry())
{
if (obj is Solid solid && solid.Faces.Size > 0 && solid.Volume > 0)
try
{
FreeFormElement.Create(Document, solid);//和分解的功能一样,仅保留几何信息
if (obj is Solid solid && solid.Faces.Size > 0 && solid.Volume > 10e-6)
{
//try
//{
// // 如果是项目文档只能使用DirectShape创建适用于导入的几何体不能进行二次编辑
FreeFormElement.Create(Document, solid);//和分解的功能一样,仅保留几何信息
// // 如果是族文档使用FreeFormElement创建可以有更多的几何体支持支持编辑手柄族文档也支持DirectShape
// var shape = DirectShape.CreateElement(Document, f.FamilyCategory.Id);
// shape.SetShape([solid]);
//}
//catch (Exception)
//{
// 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;
}
}
}
else if (geoObj is Solid topSolid && topSolid.Faces.Size > 0 && topSolid.Volume > 0)
try
{
FreeFormElement.Create(Document, topSolid);//和分解的功能一样,仅保留几何信息
if (geoObj is Solid topSolid && topSolid.Faces.Size > 0 && topSolid.Volume > 10e-6)
{
//try
//{
FreeFormElement.Create(Document, topSolid);//和分解的功能一样,仅保留几何信息
// var directShape = DirectShape.CreateElement(Document, f.FamilyCategory.Id);
// directShape.SetShape([topSolid]);
//}
//catch (Exception)
//{
// 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);
@@ -86,9 +107,9 @@ public class ExplodeDwgCmd : IExternalCommand
{
}
catch (Exception ex)
if (sb.Length > 0)
{
TaskDialog.Show("Error", ex.Message);
MessageBox.Show(sb.ToString(), "部分几何体创建失败");
}
return Result.Succeeded;
}