Ad

Friday, October 12, 2012

Point Creation COM Style

Here is an example on how to create a point in Civil 3D using COM. To duplicate this feat, download the Civil 3D Reminders Pack. Right click on a folder, maybe the Points perhaps? Then choose create new class. Give the class a classy name. Then paste the code below into the class, replacing all of the items. Change the class name to match the file name.

Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AECC.Interop.Land
Imports Autodesk.AECC.Interop.UiLand
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Geometry
Imports Quux.C3DUtilities

<Assembly: CommandClass(GetType(PointCreation))>

Public Class PointCreation

<CommandMethod("CreatePointExample")> _
Public Sub HelloWorld()

Dim oCivil As New AeccAppConnection

Dim newPoint As AeccPoint
Dim dLocation(0 To 2) As Double
dLocation(0) = 0
dLocation(1) = 0
dLocation(2) = 0
newPoint = oCivil.AeccDoc.Points.Add(dLocation)

End Sub

End Class



If you don’t want to use the Civil 3D Reminders Pack make sure to download the Quux free edition and use a reference to it to get the AeccAppConnection to make it easier to get the Civil 3D document.

No comments:

LinkWithin

Blog Widget by LinkWithin

Ad