更新
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Visual;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
public static class DocumentAssist
|
||||
@@ -647,7 +647,7 @@ public static class DocumentAssist
|
||||
.FirstOrDefault(f => f.Name == Path.GetFileNameWithoutExtension(familyPath));
|
||||
if (family == null && File.Exists(familyPath))
|
||||
{
|
||||
doc.LoadFamily(familyPath, new LoadFamilyOptions(), out family);
|
||||
doc.LoadFamily(familyPath, new DefaultFamilyLoadOptions(), out family);
|
||||
}
|
||||
|
||||
return family;
|
||||
@@ -874,7 +874,48 @@ public static class DocumentAssist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有类型定义的DirectShape
|
||||
/// </summary>
|
||||
/// <param name="doc"></param>
|
||||
/// <param name="definitionId">定义名称,即是族名称、类型名称(强制一致),创建多个实例时,如果相同,则会合并在一个族中</param>
|
||||
/// <param name="category">族类别</param>
|
||||
/// <param name="geos">几何</param>
|
||||
/// <param name="transform">位置</param>
|
||||
/// <returns></returns>
|
||||
public static DirectShape CreateDirectShapeInstance(this Document doc, string definitionId, BuiltInCategory category, List<GeometryObject> geos)
|
||||
{
|
||||
DirectShapeLibrary directShapeLibrary = DirectShapeLibrary.GetDirectShapeLibrary(doc);
|
||||
ElementId directShapeTypeId = directShapeLibrary.FindDefinitionType(definitionId);
|
||||
if (doc.GetElement(directShapeTypeId) == null)
|
||||
{
|
||||
var directShapeType = DirectShapeType.Create(doc, definitionId, new ElementId(category));
|
||||
directShapeTypeId = directShapeType.Id;
|
||||
directShapeLibrary.AddDefinitionType(definitionId, directShapeTypeId);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// directShapeLibrary.AddDefinition(definitionId, geos);
|
||||
//}
|
||||
var shape = DirectShape.CreateElementInstance(doc, directShapeTypeId, new ElementId(category), definitionId, Transform.Identity);
|
||||
//shape.SetTypeId(directShapeTypeId);
|
||||
//shape.SetName();实例名称
|
||||
shape.SetShape(geos);
|
||||
return shape;
|
||||
}
|
||||
/// <summary>
|
||||
/// 无名称定义的DirectShape
|
||||
/// </summary>
|
||||
/// <param name="doc"></param>
|
||||
/// <param name="geos"></param>
|
||||
/// <param name="category"></param>
|
||||
/// <returns></returns>
|
||||
public static DirectShape CreateDirectShape(this Document doc, List<GeometryObject> geos, BuiltInCategory category)
|
||||
{
|
||||
var shape = DirectShape.CreateElement(doc, new ElementId(category));
|
||||
shape.SetShape(geos);
|
||||
return shape;
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除Revit链接
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user