添加项目文件。
This commit is contained in:
65
GeologyToolkit/MovePointCmd.cs
Normal file
65
GeologyToolkit/MovePointCmd.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System.Linq;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
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)]
|
||||
public class MovePointCmd : 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 refer1 = UiDocument.Selection.PickObject(ObjectType.Element, new SelectLayer(), "请选择要移动的土层");
|
||||
var familyinstance = Document.GetElement(refer1) as FamilyInstance;
|
||||
var placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(familyinstance);
|
||||
var referpoint = Document.GetElement(placePointIds[1]) as ReferencePoint;
|
||||
|
||||
var scope = new TopographyEditScope(Document, "移动地层点");
|
||||
if (scope.IsPermitted)
|
||||
{
|
||||
scope.Start(surface.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
Result= Result.Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
GeologyFailureProcessor processor = null;
|
||||
using (var ts = new Transaction(Document, "移动地层点"))
|
||||
{
|
||||
ts.Start();
|
||||
if (scope.IsActive)
|
||||
{
|
||||
var movePoint = surface.GetPoints().Where(p => p.CrossProduct(referpoint.Position).Normalize().Z == 0).FirstOrDefault();
|
||||
if (movePoint != null)
|
||||
{
|
||||
surface.MovePoint(movePoint, referpoint.Position);
|
||||
processor = new GeologyFailureProcessor();
|
||||
}
|
||||
}
|
||||
ts.Commit();
|
||||
}
|
||||
|
||||
scope.Commit(processor);
|
||||
}
|
||||
}
|
||||
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user