调整代码
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitCore.Extensions;
|
||||
|
||||
internal static class FamilyInstanceExtensions
|
||||
{
|
||||
public static bool IsNested(this Autodesk.Revit.DB.FamilyInstance familyInstance)
|
||||
{
|
||||
return familyInstance.SuperComponent != null;
|
||||
}
|
||||
|
||||
public static bool CanBeMove(this Autodesk.Revit.DB.FamilyInstance familyInstance)
|
||||
{
|
||||
return !(familyInstance.Symbol.Family.FamilyPlacementType == FamilyPlacementType.WorkPlaneBased &&
|
||||
familyInstance.Host == null &&
|
||||
familyInstance.HostFace == null);
|
||||
}
|
||||
|
||||
public static void DeleteEmptyType(this Document famDocument)
|
||||
{
|
||||
if(famDocument == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(famDocument));
|
||||
}
|
||||
if(!famDocument.IsFamilyDocument)
|
||||
{
|
||||
throw new InvalidOperationException("该文档不是族文档");
|
||||
}
|
||||
var fm = famDocument.FamilyManager;
|
||||
foreach (FamilyType item in fm.Types)
|
||||
{
|
||||
var b = string.IsNullOrWhiteSpace(item.Name);
|
||||
//MessageBox.Show(item.Name);
|
||||
if (b)
|
||||
{
|
||||
fm.CurrentType = item;
|
||||
fm.DeleteCurrentType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Rotate(this Autodesk.Revit.DB.FamilyInstance familyInstance, double radian)
|
||||
{
|
||||
var axis = Line.CreateBound(familyInstance.GetTransform().Origin, familyInstance.GetTransform().Origin + XYZ.BasisZ);
|
||||
ElementTransformUtils.RotateElement(familyInstance.Document, familyInstance.Id, axis, radian);
|
||||
}
|
||||
|
||||
//extension (Autodesk.Revit.DB.FamilyInstance familyInstance)
|
||||
//{
|
||||
// public bool IsNested()
|
||||
// {
|
||||
// return familyInstance.SuperComponent != null;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user