AutoCAD Civil 3D Customization

AutoCAD Civil 3D Customization

Reply
Active Member
TJB627
Posts: 6
Registered: ‎06-25-2008
Message 1 of 5 (252 Views)

Help Changing Elevation of Points in Civil 3D

252 Views, 4 Replies
06-26-2008 05:15 AM
Reply

Hey guys, I am totally new to AutoCAD development so any help would be greatly appreciated. What I have been asked to do is write a VB.NET app that can change the elevation on an AECCPoint in Civil 3D. I can't seem to figure out how to do this since all of this is brand new to me. So far, what I have is:



Imports System
Imports AutoCAD = Autodesk.AutoCAD.Interop
Imports AeccLandLib = Autodesk.AECC.Interop.Land
Imports AeccUiLandLib = Autodesk.AECC.Interop.UiLand
Imports AecUIBase = Autodesk.AEC.Interop.UIBase
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices

Public Class Elevation
Private m_oAcadApp As Autodesk.AutoCAD.Interop.AcadApplication
Private m_oAeccApp As AeccUiLandLib.IAeccApplication
Private m_oAeccDoc As AeccUiLandLib.IAeccDocument
Private m_oAeccDb As AeccLandLib.IAeccDatabase

Private Sub btnChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChange.Click

Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocum ent.Editor
Try
m_oAcadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
m_oAeccApp = m_oAcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.5.0")

m_oAeccDoc = m_oAeccApp.ActiveDocument
m_oAeccDb = m_oAeccApp.ActiveDocument.Database

Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim lock As DocumentLock = doc.LockDocument

Dim mybt As BlockTable
Dim mybtr As BlockTableRecord
Dim mytransman As Autodesk.AutoCAD.DatabaseServices.TransactionManager
Dim mytrans As Transaction
Dim mydb As Database
mydb = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocum ent.Database
mytransman = mydb.TransactionManager
mytrans = mytransman.StartTransaction
mybt = mydb.BlockTableId.GetObject(OpenMode.ForRead)
mybtr = mybt(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)

Dim temp As New AeccLandLib.AeccPoint
temp = m_oAeccDb.Points.Find(1)
temp.Elevation = 5

mybtr.AppendEntity(temp) 'temp is not an entity so this throws an exception, not sure how to cast a point to an entity
mytrans.AddNewlyCreatedDBObject(temp, True)
mytrans.Commit()
mytrans.Dispose()
mytransman.Dispose()
Catch ex As System.Exception

End Try

End Sub
End Class


I know that this is totally wrong but if somebody could help me figure out which part or parts are wrong that would be greatly appreciated. Somebody over in the LDD group told me that I can just edit the point, I don't have to re-add it so I know I need tk take that part out but am I editing the point correctly? Thanks.
Active Member
TJB627
Posts: 6
Registered: ‎06-25-2008
Message 2 of 5 (252 Views)

Re: Help Changing Elevation of Points in Civil 3D

06-26-2008 05:39 AM in reply to: TJB627
Okay, I think I figured out part of my problem. I was making it too complicated. Really what I needed was

Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Try
m_oAcadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
m_oAeccApp = m_oAcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.5.0")

m_oAeccDoc = m_oAeccApp.ActiveDocument
m_oAeccDb = m_oAeccApp.ActiveDocument.Database

Dim temp As New AeccLandLib.AeccPoint
temp = m_oAeccDb.Points.Find(1)
Dim mydouble As Double = txtElevation.Text
temp.Elevation = mydouble

Me.Close()
Catch ex As System.Exception


Now I just need to figure out how to select a point with the mouse and get it to edit the point I selected.
Active Member
TJB627
Posts: 6
Registered: ‎06-25-2008
Message 3 of 5 (252 Views)

Re: Help Changing Elevation of Points in Civil 3D

06-26-2008 05:51 AM in reply to: TJB627
Also, sorry for the extra post, one more thing, from the time I click my Change Elevation button, to closing the form and the elevation on the point actually changing, there is about a 3 second delay and I'm not sure why it is taking so long. Should I update the drawing somehow? Any help that can be provided would be greatly appreciated.
*Expert Elite*
Sinc
Posts: 6,207
Registered: ‎11-18-2006
Message 4 of 5 (252 Views)

Re: Help Changing Elevation of Points in Civil 3D

06-26-2008 07:43 AM in reply to: TJB627
If you can translate from C#.NET, there is a large sample source code project at the following link, which gives you examples for interacting with a large number of C3D objects using a .NET language.

The big point of confusion is that, while there is a .NET API for the core vanilla Autocad functionality, there is no .NET API for the C3D stuff. So all the C3D interactions actually use COM objects. That's why there's a lot of converting between DBObjects and AcadObjects.

http://www.quux.biz/SincpacC3D_source.aspx
Sinc
Active Member
TJB627
Posts: 6
Registered: ‎06-25-2008
Message 5 of 5 (252 Views)

Re: Help Changing Elevation of Points in Civil 3D

06-26-2008 08:29 AM in reply to: TJB627
No way! I just took a look at your website, I work for Withers & Ravenel. Jamey was actually the person that assigned this project to me. I'll take a look at that source code, hopefully it will help. I mainly just need to be able to select a point with a mouse and be able to obtain the point id from that.
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.