[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
// [Journaling(JournalingMode.NoCommandData)]
public class NewLine : IExternalCommand
{
public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
{
Document doc = revit.Application.ActiveUIDocument.Document;
// 需要启动一个事务
Transaction tr = new Transaction(doc, " test " );
tr.Start();
XYZ pt1 = new XYZ( 5 , 5 , 0 );
XYZ pt2 = new XYZ( 5 , 10 , 0 );
Line line = doc.Application.Create.NewLine(pt1, pt2, true );
XYZ origin = new XYZ( 0 , 0 , 0 );
XYZ normal = new XYZ( 0 , 0 , 1 );
Plane plane = doc.Application.Create.NewPlane(pt2.CrossProduct(pt1), pt1); // 平面
SketchPlane skplane = doc.Create.NewSketchPlane(plane); // 草图平面
ModelCurve modelcurve1 = doc.Create.NewModelCurve(line, skplane); // 模型曲线
tr.Commit();
return Autodesk.Revit.UI.Result.Succeeded;
}
}
[Regeneration(RegenerationOption.Manual)]
// [Journaling(JournalingMode.NoCommandData)]
public class NewLine : IExternalCommand
{
public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
{
Document doc = revit.Application.ActiveUIDocument.Document;
// 需要启动一个事务
Transaction tr = new Transaction(doc, " test " );
tr.Start();
XYZ pt1 = new XYZ( 5 , 5 , 0 );
XYZ pt2 = new XYZ( 5 , 10 , 0 );
Line line = doc.Application.Create.NewLine(pt1, pt2, true );
XYZ origin = new XYZ( 0 , 0 , 0 );
XYZ normal = new XYZ( 0 , 0 , 1 );
Plane plane = doc.Application.Create.NewPlane(pt2.CrossProduct(pt1), pt1); // 平面
SketchPlane skplane = doc.Create.NewSketchPlane(plane); // 草图平面
ModelCurve modelcurve1 = doc.Create.NewModelCurve(line, skplane); // 模型曲线
tr.Commit();
return Autodesk.Revit.UI.Result.Succeeded;
}
}