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; ModelCurveArray modelCurveArray = null;
doc.InvokeGroup<Result>(tg => doc.InvokeGroup<Result>(tg =>
{ {
Room room = default;
try try
{ {
Room room = default;
var singleWallsToDim = new List<Wall>(); var singleWallsToDim = new List<Wall>();
Dictionary<BoundarySegment, Element> dics = new Dictionary<BoundarySegment, Element>(); Dictionary<BoundarySegment, Element> dics = new Dictionary<BoundarySegment, Element>();
IList<BoundarySegment> segments = new List<BoundarySegment>(); IList<BoundarySegment> segments = new List<BoundarySegment>();
@@ -103,7 +103,7 @@ namespace RookieStation.Drawing.ExecuteCmd
}, "创建梁和柱标注"); }, "创建梁和柱标注");
doc.Invoke(ts => 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() //CreateBuiltInInstance()
CreateLightAnnotations(doc); CreateLightAnnotations(doc);
CreateShelvesDimensions(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(); 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) 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(); doc.Regenerate();
foreach (ModelCurve curve in modelCurveArray) foreach (ModelCurve curve in modelCurveArray)
{ {
doc.Delete(curve.Id); if (curve.Id != ElementId.InvalidElementId)
{
doc.Delete(curve.Id);
}
} }
}, "删除临时房间,空标注"); }, "删除临时房间,空标注");
} }
catch (Exception ex) 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); Log.WriteLog(ex.Message);
//throw; //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); var wallCreated = Wall.Create(doc, curve, wallType.Id, baselevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false);
doc.Regenerate(); doc.Regenerate();
try
{ WallUtils.DisallowWallJoinAtEnd(wallCreated, 0);
if (wallCreated.WallType.Kind == WallKind.Stacked) WallUtils.DisallowWallJoinAtEnd(wallCreated, 1);
{ //try
foreach (var wallid in wallCreated.GetStackedWallMemberIds()) //{
{ // if (wallCreated.WallType.Kind == WallKind.Stacked)
Wall stackedwall = doc.GetElement(wallid) as Wall; // {
JoinGeometryUtils.JoinGeometry(doc, wall, stackedwall); // foreach (var wallid in wallCreated.GetStackedWallMemberIds())
} // {
} // Wall stackedwall = doc.GetElement(wallid) as Wall;
else // JoinGeometryUtils.JoinGeometry(doc, wall, stackedwall);
{ // }
JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated); // }
} // else
} // {
catch (Exception ex) // JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated);
{ // }
Log.WriteLog(ex.Message); //}
} //catch (Exception ex)
//{
// Log.WriteLog(ex.Message);
//}
}, "创建墙面饰面"); }, "创建墙面饰面");
} }
} }

View File

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

View File

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

View File

@@ -9,6 +9,7 @@ using System.Text;
using static System.Net.WebRequestMethods; using static System.Net.WebRequestMethods;
using Autodesk.Revit.UI; using Autodesk.Revit.UI;
using HandyControl.Controls; using HandyControl.Controls;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace RookieStation.Utils namespace RookieStation.Utils
{ {
@@ -871,7 +872,7 @@ namespace RookieStation.Utils
var x = baseTag.TagHeadPosition.X - tag.TagHeadPosition.X; var x = baseTag.TagHeadPosition.X - tag.TagHeadPosition.X;
var y = baseTag.TagHeadPosition.Y - tag.TagHeadPosition.Y; var y = baseTag.TagHeadPosition.Y - tag.TagHeadPosition.Y;
tag.TagHeadPosition += x * XYZ.BasisX + (y + distance * i) * XYZ.BasisY; 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.LeaderElbow = baseTag.LeaderElbow + (tag.TagHeadPosition.Y - baseTag.TagHeadPosition.Y) * XYZ.BasisY;
tag.LeaderEnd += (baseTag.LeaderEnd.X - tag.LeaderEnd.X) * XYZ.BasisX; tag.LeaderEnd += (baseTag.LeaderEnd.X - tag.LeaderEnd.X) * XYZ.BasisX;
@@ -883,7 +884,7 @@ namespace RookieStation.Utils
} }
tag.LeaderEndCondition = LeaderEndCondition.Attached; tag.LeaderEndCondition = LeaderEndCondition.Attached;
} }
if (baseTag.LeaderEndCondition == LeaderEndCondition.Free) if (baseTag.LeaderEndCondition == LeaderEndCondition.Free && baseTag.CanLeaderEndConditionBeAssigned(LeaderEndCondition.Attached))
{ {
baseTag.LeaderEndCondition = LeaderEndCondition.Attached; baseTag.LeaderEndCondition = LeaderEndCondition.Attached;
} }
@@ -973,7 +974,7 @@ namespace RookieStation.Utils
////端点之间的直线距离 ////端点之间的直线距离
//var v1 = baseTag.LeaderEnd - tag.LeaderEnd; //var v1 = baseTag.LeaderEnd - tag.LeaderEnd;
//var d1 = v1.DotProduct(moveUnitVector); //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; 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; baseTag.LeaderEndCondition = LeaderEndCondition.Attached;
} }

View File

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

View File

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