You can edit the properties of an open or closed spline, and even convert it to a polyline. Use the following properties to open or close a spline, change its control points, or reverse the direction of a spline:
In addition, you can use the following methods to edit splines:
Gets the fit point of the spline at a given index. (Gets one fit point only. To query all the fit points of the spline, use the FitData property and then query the FitData object returned with its GetFitPoints member function.) The NumFitPoints property contains the number of fit points of the spline.
Use the following read-only properties to query splines:
For more information about editing splines, see “Modify Splines” in the AutoCAD User's Guide.
Change a control point on a spline
This example creates a spline and then changes the first control point for the spline.
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
<CommandMethod("EditSpline")> _
Public Sub EditSpline()
'' Get the current document and database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' Open the Block table for read
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, _
OpenMode.ForRead)
'' Open the Block table record Model space for write
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
OpenMode.ForWrite)
'' Create a Point3d Collection
Dim acPt3dColl As Point3dCollection = New Point3dCollection()
acPt3dColl.Add(New Point3d(1, 1, 0))
acPt3dColl.Add(New Point3d(5, 5, 0))
acPt3dColl.Add(New Point3d(10, 0, 0))
'' Set the start and end tangency
Dim acStartTan As Vector3d = New Vector3d(0.5, 0.5, 0)
Dim acEndTan As Vector3d = New Vector3d(0.5, 0.5, 0)
'' Create a spline
Dim acSpline As Spline = New Spline(acPt3dColl, _
acStartTan, _
acEndTan, 4, 0)
'' Set a control point
acSpline.SetControlPointAt(0, New Point3d(0, 3, 0))
'' Add the new object to the block table record and the transaction
acBlkTblRec.AppendEntity(acSpline)
acTrans.AddNewlyCreatedDBObject(acSpline, True)
'' Save the new objects to the database
acTrans.Commit()
End Using
End Sub
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
[CommandMethod("EditSpline")]
public static void EditSpline()
{
// Get the current document and database
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// Start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the Block table for read
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;
// Open the Block table record Model space for write
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
// Create a Point3d Collection
Point3dCollection acPt3dColl = new Point3dCollection();
acPt3dColl.Add(new Point3d(1, 1, 0));
acPt3dColl.Add(new Point3d(5, 5, 0));
acPt3dColl.Add(new Point3d(10, 0, 0));
// Set the start and end tangency
Vector3d acStartTan = new Vector3d(0.5, 0.5, 0);
Vector3d acEndTan = new Vector3d(0.5, 0.5, 0);
// Create a spline
Spline acSpline = new Spline(acPt3dColl,
acStartTan,
acEndTan, 4, 0);
// Set a control point
acSpline.SetControlPointAt(0, new Point3d(0, 3, 0));
// Add the new object to the block table record and the transaction
acBlkTblRec.AppendEntity(acSpline);
acTrans.AddNewlyCreatedDBObject(acSpline, true);
// Save the new objects to the database
acTrans.Commit();
}
}