添加项目文件。
This commit is contained in:
84
GeologyToolkit/RemovePointCmd.cs
Normal file
84
GeologyToolkit/RemovePointCmd.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
using GeologyToolkit;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
|
||||
namespace GeologyToolkit
|
||||
{
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
internal class RemovePointCmd : ExternalCommand
|
||||
{
|
||||
public override void Execute()
|
||||
{
|
||||
var isContinue = true;
|
||||
try
|
||||
{
|
||||
while (isContinue)
|
||||
{
|
||||
var refer = UiDocument.Selection.PickObject(ObjectType.Element, new SelectTopographySurface(), "请选择要调整地层面");
|
||||
var surface = Document.GetElement(refer) as TopographySurface;
|
||||
var referPoint = SelectInstance(UiDocument);
|
||||
RemoveSurfacePoint(Document, surface, referPoint);
|
||||
}
|
||||
}
|
||||
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ReferencePoint SelectInstance(UIDocument uidoc)
|
||||
{
|
||||
var Document = uidoc.Document;
|
||||
var refer1 = uidoc.Selection.PickObject(ObjectType.Element, new SelectLayer(), "请选择要移除的土层");
|
||||
var familyinstance = Document.GetElement(refer1) as FamilyInstance;
|
||||
var placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(familyinstance);
|
||||
return Document.GetElement(placePointIds[1]) as ReferencePoint;
|
||||
}
|
||||
|
||||
public ReferencePoint SelectReferencePoint(UIDocument uidoc, TopographySurface surface)
|
||||
{
|
||||
var Document = uidoc.Document;
|
||||
|
||||
var refer1 = uidoc.Selection.PickObject(ObjectType.Element, new SelectReferPoint(), "请选择要移除的土层点");
|
||||
return Document.GetElement(refer1) as ReferencePoint;
|
||||
}
|
||||
|
||||
private void RemoveSurfacePoint(Document doc, TopographySurface surface, ReferencePoint referpoint)
|
||||
{
|
||||
var scope = new TopographyEditScope(doc, "移除地层点");
|
||||
if (scope.IsPermitted)
|
||||
{
|
||||
scope.Start(surface.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GeologyFailureProcessor processor = null;
|
||||
using (var ts = new Transaction(doc, "删除地层点"))
|
||||
{
|
||||
ts.Start();
|
||||
if (scope.IsActive)
|
||||
{
|
||||
var points = new List<XYZ>
|
||||
{
|
||||
referpoint.Position
|
||||
};
|
||||
surface.DeletePoints(points);
|
||||
processor = new GeologyFailureProcessor();
|
||||
}
|
||||
ts.Commit();
|
||||
}
|
||||
scope.Commit(processor);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user