Author Topic: TF.NET (Topology Framework .NET)  (Read 2955 times)

0 Members and 1 Guest are viewing this topic.

MaksimS

  • Guest
TF.NET (Topology Framework .NET)
« on: November 27, 2007, 10:38:14 AM »
Hi all,

Take a look at http://code.google.com/p/tf-net/

TF.NET (Topology Framework .NET) represents a topology manipulation API capable of handling managed objects representation of topological entities based on other popular APIs, exposing it's JTS-based common topology manipulation core to them. In short - a NetTopologySuite extension, and more. Don't forget to read the help file (Download section) :-)

I've also added couple of classes for reading/writing few managed ObjectARX entities, just for starters (http://code.google.com/p/tf-net/wiki/DwgReaderWriter). All libraries are under LGPL and available for download. There's no source yet, I'll post it to repository as soon as I get my CSV client talk to Google.

Regards,
Maksim Sestic
« Last Edit: November 27, 2007, 10:41:12 AM by MaksimS »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: TF.NET (Topology Framework .NET)
« Reply #1 on: November 27, 2007, 12:39:58 PM »

Thanks Maksim.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MaksimS

  • Guest
Re: TF.NET (Topology Framework .NET)
« Reply #2 on: November 29, 2007, 05:55:25 AM »
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=OVER

Here's short example of creating a Buffer around a polyline:

1) Open polyline

2) Closed polyline


And a source (no-error-trapping-or-anything):

Code: [Select]
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


« Last Edit: November 29, 2007, 05:56:38 AM by MaksimS »