There's a new TF.NET version posted on
http://code.google.com/p/tf-net/. Now supports few more managed ObjectARX types reading/writing.
Take a look at examples on exposed JTS spatial data types, binary predicates and spatial analysis methods here:
http://www.jump-project.org/project.php?PID=JTS&SID=OVERHere's short example of creating a Buffer around a polyline:
1) Open polyline
2) Closed polyline
And a source (no-error-trapping-or-anything):
Imports Topology.Geometries
Imports Topology.IO.Dwg
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.EditorInput
Public Class Test
<CommandMethod("CREATEBUFFER")> _
Public Shared Sub CreateBuffer()
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim selOptions As PromptSelectionOptions = New PromptSelectionOptions
selOptions.MessageForAdding = "Select object:"
selOptions.AllowDuplicates = False
selOptions.SingleOnly = True
Dim result As PromptSelectionResult = ed.GetSelection(selOptions)
If result.Status = PromptStatus.OK Then
Dim selSet As SelectionSet = result.Value
Dim objId As ObjectId = selSet.GetObjectIds(0)
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Dim inEnt As Entity = tr.GetObject(objId, OpenMode.ForRead)
Dim reader As New DwgReader
Dim writer As New DwgWriter
Dim lineString As LineString = lineString.Empty
Dim outEnts() As Polyline = Nothing
Try
Select Case inEnt.GetRXClass.Name
Case "AcDbPolyline"
lineString = reader.ReadLineString(CType(inEnt, Polyline))
Case "AcDb3dPolyline"
lineString = reader.ReadLineString(CType(inEnt, Polyline3d))
Case "AcDb2dPolyline"
lineString = reader.ReadLineString(CType(inEnt, Polyline2d))
End Select
Dim dblOptions As New PromptDoubleOptions("Enter buffer offset: ")
dblOptions.AllowNegative = False
dblOptions.AllowNone = False
dblOptions.AllowZero = False
Dim dblOptionsResult As PromptDoubleResult = ed.GetDouble(dblOptions)
If dblOptionsResult.Status = PromptStatus.OK Then
Dim offset As Double = dblOptionsResult.Value
Dim buffer As Geometry = lineString.Buffer(offset)
If buffer.GeometryType = "Polygon" Then
outEnts = writer.WritePolyline(CType(buffer, Polygon))
End If
End If
Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim btr As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)
If outEnts IsNot Nothing Then
For Each outEnt As Entity In outEnts
outEnt.ColorIndex = 1
btr.AppendEntity(outEnt)
tr.AddNewlyCreatedDBObject(outEnt, True)
Next
End If
tr.Commit()
Finally
tr.Dispose()
End Try
End If
End Sub
End Class