- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi can anyone assist with the code in blue below
The code reports polyline id and alignment name for the alignment creation
but fails to create any alignment either empty with out geometry, the indented plops options
or any error reports
cheers
for any pointers
Trefor
Option Explicit On
Option Strict Off
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.Civil.DatabaseServices.Styles
Imports Autodesk.Civil.ApplicationServices
Imports Autodesk.Civil.DatabaseServices
<Assembly: CommandClass(GetType(Halign))>
<Assembly: ExtensionApplication(GetType(Halign))>
Public Class Halign
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
Private m_doc As CivilDocument = Nothing
Private m_trans As Transaction = Nothing
Private m_Database As Database = Nothing
Private m_Editor As Editor = Nothing
Private m_AlignmentLabelStyleSetId As ObjectId = ObjectId.Null
Private m_AligmentStyleId As ObjectId = ObjectId.Null
Private m_SiteId As ObjectId = ObjectId.Null
Private m_Alignment As Alignment = Nothing
''' <summary>
''' Implement Initialize of IExtensionApplication
''' </summary>
''' <remarks></remarks>
Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
End Sub
Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate
End Sub
<CommandMethod("halign")>
Public Sub halign()
'' Get the current document and database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim docCol As Autodesk.AutoCAD.ApplicationServices.DocumentCollection = Application.DocumentManager
m_Database = docCol.MdiActiveDocument.Database
m_Editor = docCol.MdiActiveDocument.Editor
m_doc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument()
'' 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 read
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace),
OpenMode.ForRead)
'' Step through the Block table record
For Each acObjId As ObjectId In acBlkTblRec
If (acObjId.ObjectClass.DxfName = "LWPOLYLINE") Then
ed.WriteMessage(vbLf & acObjId.ToString)
Dim acount As Integer
acount += 1
Dim Alignmentlabel As String = "A"
Dim AlignmentName = Alignmentlabel & acount
ed.WriteMessage(vbLf & AlignmentName)
''Dim plops As Autodesk.Civil.DatabaseServices.PolylineOptions
''plops.AddCurvesBetweenTangents = False
''plops.EraseExistingEntities = True
''plops.PlineId = acObjId
Dim alignId As ObjectId = Nothing
alignId = Alignment.Create(m_doc, AlignmentName, "Site 1", "alignments", "Basic", "Basic")
End If
Next
'' Dispose of the transaction
End Using
End Sub
End Class
Solved! Go to Solution.