This commit is contained in:
GG Z
2022-01-28 08:53:37 +08:00
parent 05d16e23b5
commit 2f51521aa1
7 changed files with 105 additions and 63 deletions

View File

@@ -28,9 +28,9 @@ namespace RookieStation.Drawing.ExecuteCmd
ModelCurveArray modelCurveArray = null;
doc.InvokeGroup<Result>(tg =>
{
Room room = default;
try
{
Room room = default;
var singleWallsToDim = new List<Wall>();
Dictionary<BoundarySegment, Element> dics = new Dictionary<BoundarySegment, Element>();
IList<BoundarySegment> segments = new List<BoundarySegment>();
@@ -103,7 +103,7 @@ namespace RookieStation.Drawing.ExecuteCmd
}, "创建梁和柱标注");
doc.Invoke(ts =>
{
CreateInstanceTags(doc, segments, false, BuiltInCategory.OST_Doors, BuiltInCategory.OST_Windows, BuiltInCategory.OST_ElectricalFixtures, BuiltInCategory.OST_CommunicationDevices, BuiltInCategory.OST_FurnitureSystems, BuiltInCategory.OST_Furniture, BuiltInCategory.OST_LightingDevices, BuiltInCategory.OST_LightingFixtures);
CreateInstanceTags(doc, segments, false, BuiltInCategory.OST_Doors, BuiltInCategory.OST_Windows, BuiltInCategory.OST_ElectricalFixtures, BuiltInCategory.OST_CommunicationDevices, BuiltInCategory.OST_FurnitureSystems, BuiltInCategory.OST_Furniture, BuiltInCategory.OST_LightingDevices, BuiltInCategory.OST_LightingFixtures, BuiltInCategory.OST_SpecialityEquipment);
//CreateBuiltInInstance()
CreateLightAnnotations(doc);
CreateShelvesDimensions(doc);
@@ -145,18 +145,50 @@ namespace RookieStation.Drawing.ExecuteCmd
var independentTags = new FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(typeof(IndependentTag)).Cast<IndependentTag>().Where(tag => tag.TagText == "" || tag.TagText == null).ToList();
foreach (var item in independentTags)
{
doc.Delete(item.Id);
if (item.Id != ElementId.InvalidElementId)
{
doc.Delete(item.Id);
}
}
if (room.Id != ElementId.InvalidElementId)
{
doc.Delete(room.Id);
}
doc.Delete(room.Id);
doc.Regenerate();
foreach (ModelCurve curve in modelCurveArray)
{
doc.Delete(curve.Id);
if (curve.Id != ElementId.InvalidElementId)
{
doc.Delete(curve.Id);
}
}
}, "删除临时房间,空标注");
}
catch (Exception ex)
{
doc.Invoke(ts =>
{
var independentTags = new FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(typeof(IndependentTag)).Cast<IndependentTag>().Where(tag => tag.TagText == "" || tag.TagText == null).ToList();
foreach (var item in independentTags)
{
if (item.Id != ElementId.InvalidElementId)
{
doc.Delete(item.Id);
}
}
if (room.Id != ElementId.InvalidElementId)
{
doc.Delete(room.Id);
}
doc.Regenerate();
foreach (ModelCurve curve in modelCurveArray)
{
if (curve.Id != ElementId.InvalidElementId)
{
doc.Delete(curve.Id);
}
}
}, "删除临时房间,空标注");
Log.WriteLog(ex.Message);
//throw;
}

View File

@@ -276,25 +276,28 @@ namespace RookieStation.Finishes.ExecuteCmd
var wallCreated = Wall.Create(doc, curve, wallType.Id, baselevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false);
doc.Regenerate();
try
{
if (wallCreated.WallType.Kind == WallKind.Stacked)
{
foreach (var wallid in wallCreated.GetStackedWallMemberIds())
{
Wall stackedwall = doc.GetElement(wallid) as Wall;
JoinGeometryUtils.JoinGeometry(doc, wall, stackedwall);
}
}
else
{
JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated);
}
}
catch (Exception ex)
{
Log.WriteLog(ex.Message);
}
WallUtils.DisallowWallJoinAtEnd(wallCreated, 0);
WallUtils.DisallowWallJoinAtEnd(wallCreated, 1);
//try
//{
// if (wallCreated.WallType.Kind == WallKind.Stacked)
// {
// foreach (var wallid in wallCreated.GetStackedWallMemberIds())
// {
// Wall stackedwall = doc.GetElement(wallid) as Wall;
// JoinGeometryUtils.JoinGeometry(doc, wall, stackedwall);
// }
// }
// else
// {
// JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated);
// }
//}
//catch (Exception ex)
//{
// Log.WriteLog(ex.Message);
//}
}, "创建墙面饰面");
}
}

View File

@@ -48,10 +48,9 @@ namespace RookieStation.ParcelAreaModule.ExecuteCmd
return doc.InvokeGroup(tg =>
{
List<ElementId> modelCurveIds = new List<ElementId>();
try
{
List<ElementId> modelCurveIds = new List<ElementId>();
//var v = new FilteredElementCollector(doc).OfClass(typeof(View))
// .Cast<View>()
// .FirstOrDefault(x => x.ViewType == ViewType.FloorPlan && x.GenLevel.Elevation == 0);
@@ -228,6 +227,11 @@ namespace RookieStation.ParcelAreaModule.ExecuteCmd
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
doc.Invoke(ts =>
{
//删除模型线
doc.Delete(modelCurveIds);
}, "删除模型线");
//if (tg.GetStatus() == TransactionStatus.Started)
//{
// tg.RollBack();

View File

@@ -33,6 +33,6 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: NeutralResourcesLanguage("zh")]

View File

@@ -9,6 +9,7 @@ using System.Text;
using static System.Net.WebRequestMethods;
using Autodesk.Revit.UI;
using HandyControl.Controls;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace RookieStation.Utils
{
@@ -871,7 +872,7 @@ namespace RookieStation.Utils
var x = baseTag.TagHeadPosition.X - tag.TagHeadPosition.X;
var y = baseTag.TagHeadPosition.Y - tag.TagHeadPosition.Y;
tag.TagHeadPosition += x * XYZ.BasisX + (y + distance * i) * XYZ.BasisY;
if (Math.Abs(tag.LeaderEnd.X - baseTag.LeaderEnd.X) < 20 / 304.8)//引线端线水平距离小于20
if (Math.Abs(tag.LeaderEnd.X - baseTag.LeaderEnd.X) < 50 / 304.8)//引线端线水平距离小于50
{
tag.LeaderElbow = baseTag.LeaderElbow + (tag.TagHeadPosition.Y - baseTag.TagHeadPosition.Y) * XYZ.BasisY;
tag.LeaderEnd += (baseTag.LeaderEnd.X - tag.LeaderEnd.X) * XYZ.BasisX;
@@ -883,7 +884,7 @@ namespace RookieStation.Utils
}
tag.LeaderEndCondition = LeaderEndCondition.Attached;
}
if (baseTag.LeaderEndCondition == LeaderEndCondition.Free)
if (baseTag.LeaderEndCondition == LeaderEndCondition.Free && baseTag.CanLeaderEndConditionBeAssigned(LeaderEndCondition.Attached))
{
baseTag.LeaderEndCondition = LeaderEndCondition.Attached;
}
@@ -973,7 +974,7 @@ namespace RookieStation.Utils
////端点之间的直线距离
//var v1 = baseTag.LeaderEnd - tag.LeaderEnd;
//var d1 = v1.DotProduct(moveUnitVector);
if (Math.Abs(dd) < 20 / 304.8)
if (Math.Abs(dd) < 50 / 304.8)
{
tag.LeaderElbow = baseTag.LeaderElbow + (tag.TagHeadPosition.Z - baseTag.TagHeadPosition.Z) * XYZ.BasisZ;
@@ -990,7 +991,7 @@ namespace RookieStation.Utils
}
}
if (baseTag.LeaderEndCondition == LeaderEndCondition.Free)
if (baseTag.LeaderEndCondition == LeaderEndCondition.Free && baseTag.CanLeaderEndConditionBeAssigned(LeaderEndCondition.Attached))
{
baseTag.LeaderEndCondition = LeaderEndCondition.Attached;
}

View File

@@ -2402,15 +2402,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:菜鸟驿站工具集"
"ProductCode" = "8:{34472669-5555-4677-BDCA-76AE92FB33A0}"
"PackageCode" = "8:{68A99B7F-1AC0-4D64-932E-9E4C9549813D}"
"ProductCode" = "8:{97514960-6B8E-4C20-BAEA-4A56F44828EF}"
"PackageCode" = "8:{4FB3F3D3-C7F1-4150-AA6A-82B35C26DE20}"
"UpgradeCode" = "8:{127EC3EC-7539-468B-84EA-E1ECDD6204E6}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:1.0.1"
"ProductVersion" = "8:1.0.2"
"Manufacturer" = "8:YTX Engineering"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"

View File

@@ -1,4 +1,5 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
@@ -21,37 +22,38 @@ namespace TestTools
Document doc = uidoc.Document;
DocumentSet docset = uiapp.Application.Documents;
Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "请选择XXX");
Element e = uidoc.Document.GetElement(refer);
Options options = new Options()
{
ComputeReferences = true,
DetailLevel = ViewDetailLevel.Fine,
};
var eleIds = e.GetGeneratingElementIds(e.get_Geometry(options));
uidoc.Selection.SetElementIds(eleIds);
//Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "请选择XXX");
//Element e = uidoc.Document.GetElement(refer);
//Options options = new Options()
//{
// ComputeReferences = true,
// DetailLevel = ViewDetailLevel.Fine,
//};
//var eleIds = e.GetGeneratingElementIds(e.get_Geometry(options));
//uidoc.Selection.SetElementIds(eleIds);
#region FilterExecute
//var walls = new FilteredElementCollector(doc).OfClass(typeof(Wall)).ToElements();
//using (Transaction trans = new Transaction(doc, "default"))
//{
// try
// {
// trans.Start();
// //Do Something.
// trans.Commit();
// }
// catch (Exception ex)
// {
// message = ex.Message;
// if (trans.GetStatus() == TransactionStatus.Started)
// {
// trans.RollBack();
// }
// return Result.Failed;
// }
//}
var walls = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements();
using (Transaction trans = new Transaction(doc, "default"))
{
try
{
trans.Start();
var rooms = walls.Where(wall => wall.Name.Contains("房间")).Select(wall => wall.Id).ToList();
doc.Delete(rooms);
trans.Commit();
}
catch (Exception ex)
{
message = ex.Message;
if (trans.GetStatus() == TransactionStatus.Started)
{
trans.RollBack();
}
return Result.Failed;
}
}
#endregion FilterExecute