Académique Documents
Professionnel Documents
Culture Documents
Legal Disclaimer
Autodesk may make statements regarding planned or future development efforts for our existing or new products and services in this document. These statements are not intended to be a promise or guarantee of future delivery of products, services or features but merely reflect our current plans, which may change. Purchasing decisions should not be made based upon reliance on these statements.
Autodesk assumes no obligation to update these forwardlooking statements to reflect events that occur or circumstances that exist or change after the date on which they were made.
2005 Autodesk
Agenda
Overview of Civil 3D API
Autodesk Confidential Info
Points Surfaces Parcels Alignments Profiles Sections Custom Subassembly (VBA) Survey Piping C++ API (customDraw)
2005 Autodesk
AEC Base 5.5 Object Library (AecXBase) AEC Base 5.5 Application Library (AecXUiBase) Autodesk Civil Engineering Land 5.0 Object Library (AeccXLand) Autodesk Civil Engineering UI Land 5.0 Object Library (AeccXUiLand)
2005 Autodesk
Autodesk Civil Engineering Corridor 5.0 Object Library (AeccXRoadway) Autodesk Civil Engineering UI Corridor 5.0 Object Library (AeccXUIRoadway)
2005 Autodesk
VB users can get the AeccApplication object through an instance of the AutoCAD.Application object:
Dim oTest As AutoCAD.AcadApplication On Error Resume Next oTest = GetObject(,"AutoCAD.Application") If Err.Number <> 0 Then Err.Clear() oTest = CreateObject("AutoCAD.Application") If Err.Number <> 0 Then Exit Sub End If End If Dim oAeccApp as AeccXUiLandLib.AeccApplication oAeccApp = oTest.GetInterfaceObject("AeccXUiLand.AeccApplication")
2005 Autodesk
Points
AeccPoint Object in Civil 3D encapsulates a COGO point object, with associated information such as elevation, marker display styles, etc. To create a new point with the given location use Add() method of AeccPoints Collection.
Dim point1 As Variant Dim oPoint As AeccPoint point1 = ThisDrawing.Utility.GetPoint(, Select a Location : ") Set oPoint = g_oAeccDb.Points.Add(point1) oPoint.Elevation = 100 oPoint.RawDescription = "Test Description"
Autodesk Confidential Info
2005 Autodesk
Note -1. This method will fail if you don't specify a supported FileFormatName. Note -2. When you add points using the ImportPoints method, it is possible that the point Numbers will conflict with those that already exist in the drawing. In such cases, the user is given an option to renumber the point numbers from the file, or to cancel the operation which will result with a Visual Basic error. An application that uses ImportPoints should take this into account.
2005 Autodesk
2005 Autodesk
' You can also use wildcards. The following would select all points with a name beginning with "pol".
oPtGroup.QueryBuilder.IncludeNames = "pol*"
oPtGroup.QueryBuilder.ExcludeElevations = ">300"
' And include those points with identification numbers 100 through 200 ' inclusive, and point number 206.
oPtGroup.QueryBuilder.IncludeNumbers = "100-200,206"
10
2005 Autodesk
Surfaces
Surfaces are basic building blocks in Autodesk Civil 3D. A surface is a three-dimensional geometric representation of the surface of an area of land, or, in the case of volume surfaces, is a difference or composite between two surface areas. Points or contours are usually a primary part of the original surface information and are supplemented with breaklines and boundaries. Breaklines are constraint lines, such as retaining walls, stream banks and beds, ridge lines, curbs, and other abrupt changes in the surface.
11
2005 Autodesk
Surfaces
AddTinSurface() method creates a new TIN surface using the specified creation data.
Public Sub createSurfaceByImport() If getCivilObjects = True Then Dim oSurface As AeccSurface Dim oTinSurfaceData As New AeccTinCreationData Const sPointFile = "D:\C3D2008API\Points_PENZD.txt" oTinSurfaceData.Description = "Existing Surface" oTinSurfaceData.Name = "adsk_EG" Dim oTinSurface As AeccTinSurface Set oTinSurface = g_oAeccDb.Surfaces.AddTinSurface(oTinSurfaceData) oTinSurface.DefinitionProperties.UseAddPoint = True oTinSurface.PointFiles.Add (sPointFile) ' Setting a criteria to Exclude Points with an ' Elevation Less Than a value (here set to 100) oTinSurface.DefinitionProperties.ExcludeElevationsLessThan = True oTinSurface.DefinitionProperties.LowerElevation = 100 oTinSurface.Rebuild End If End Sub
12
2005 Autodesk
13
2005 Autodesk
14
2005 Autodesk
Surfaces
Use AeccTinVolumeSurface to perform a volume calculation i.e. cut & fill quantities.
Dim oSurfaces As AeccSurfaces Dim oTinVolSurfData As New AeccTinVolumeCreationData Set oTinVolSurfData.BaseSurface = g_oAeccDb.Surfaces.Item(EG") Set oTinVolSurfData.ComparisonSurface = g_oAeccDb.Surfaces.Item("FG") oTinVolSurfData.Name = "adsk_TinVol" Dim oTinVolSurface As AeccTinVolumeSurface Set oTinVolSurface = g_oAeccDb.Surfaces.AddTinVolumeSurface(oTinVolSurfData) Dim CutVol As Long, FillVol As Long, NetVol As Long CutVol = oTinVolSurface.Statistics.CutVolume FillVol = oTinVolSurface.Statistics.FillVolume NetVol = oTinVolSurface.Statistics.NetVolume
Autodesk Confidential Info
15
2005 Autodesk
Surfaces
We can create a 3dPolyline between two selected points on the surface along with a LWPolyline. Viewing them together in an Object Viewer will show the actual surface profile between the selected points. Use the SampleElevations function to get the point array between two selected points on the surface.
Dim oSurf As AeccSurface Set oSurf = g_oAeccDb.Surfaces.Item(0) If oSurf Is Nothing Then MsgBox "Error: no surface exists." End If Set oSurf = g_oAeccDoc.Surfaces.Item(0) oPoint1 = ThisDrawing.Utility.GetPoint(, "Select a point on the surface ") oPoint2 = ThisDrawing.Utility.GetPoint(oPoint1, "Select a point on the surface ") pointarray = oSurf.SampleElevations(oPoint1(0), oPoint1(1), oPoint2(0), oPoint2(1)) Set polyObj = ThisDrawing.ModelSpace.Add3DPoly(pointarray)
16
2005 Autodesk
Parcels
AeccParcel objects in Autodesk Civil 3D are typically used to represent real estate parcels, such as lots in a subdivision. Parcel objects can also represent other features with closed boundaries, such as bodies of water and soil regions.
17
2005 Autodesk
Sites
All sites in a document are held in the AeccDocument.Sites collection, an object of type AeccSites. The AeccSites.Add method will create a new empty site with the specified name.
' Create a new site. Dim oSites As AeccSites Set oSites = oAeccDocument.Sites Dim oSite As AeccSite Set oSite = oSites.Add("Sample Site")
Autodesk Confidential Info
18
2005 Autodesk
Parcels
To create a Parcel, we need to access an existing AeccSite object and next start creating AeccParcelSegment objects for each side of the parcel boundary. Use properties of AeccParcelSegment objects like AddLine, AddCurve, etc to define the physical outline of the parcel.
Set oSite = g_oAeccDb.Sites.Item(0) Const sParcelStyleName = "Adsk_ParcelStyle" Dim oParcelStyle As AeccParcelStyle Const sLbl = "adsk_ParcelLabelStyle" Dim oParcelLabelStyle As AeccLabelStyle Set oParcelStyle = g_oAeccDb.ParcelStyles(sParcelStyleName) Set oParcelLabelStyle = g_oAeccDb.ParcelLabelStyles.AreaLabelStyles.Item(sLbl ) Dim oPSeg01 As AeccParcelSegment Dim oPSeg02 As AeccParcelSegment Set oPSeg01 = oSite.ParcelSegments.AddLine(0, 0, 0, 200) Set oPSeg02 = oSite.ParcelSegments.AddCurve(0, 200, -0.5, 200, 200)
19
2005 Autodesk
Parcels - Settings
AeccSite site class has many essential properties which allows Set and Get these settings like - NextAutoCounterParcel , NextManualCounterParcel, NextAutoCounterParcelLine etc.
For Each oSite In g_oAeccDoc.Sites If oSite.Name = sSiteName Then GoTo SiteFound Next Set oSite = g_oAeccDoc.Sites.Add(sSiteName) oSite.NextAutoCounterParcel = 20 oSite.NextManualCounterParcel = 20 oSite.NextAutoCounterParcelCurve = 20 oSite.NextAutoCounterParcelLine = 20
20
2005 Autodesk
Parcels - Statistics
AeccParcelStatistics Object encapsulates statistical data about the parcel, such as area and perimeter.
'Check if parcel exists in the drawing Dim oParcel As AeccParcel If oSite.Parcels.Count = 0 Then MsgBox "No parcels found" Exit Sub Else Set oParcel = oSite.Parcels.Item(0) End If ' Display parcel statistics MsgBox "Parcel name : " & oParcel.Name & vbLf _ & "Area : " & Format(CStr(oParcel.Statistics.Area), "0.####") & vbLf _ & "Perimeter : " & Format(CStr(oParcel.Statistics.Perimeter), "0.####")
21
2005 Autodesk
Alignments
Alignment objects can represent centerlines, lanes, shoulders, right-of ways, or construction baselines. Creating and defining the horizontal alignment is one of the first steps in roadway, railroad, or site design. You can draw the alignment geometry as a polyline and create the named alignment from that geometry, or create an alignment object using the Alignment Layout Tools. You can also make edits to alignments using grips, or the commands on the Alignment Layout Tools toolbar, while automatically maintaining tangency between the alignment components.
22
2005 Autodesk
Alignments
We create alignments as a combination of lines, curves, and spirals that are viewed as one object. Alignments can be standalone objects or the parent object of profiles, profile views, and cross sections. If we edit an alignment, the changes are automatically reflected in any related objects.
Dim oAlignment As AeccAlignment Set oAlignment = g_oAeccDb.Sites.Item("adsk_site1").Alignments.Add(strAlignName, "alignment", g_oAeccDb.AlignmentStyles.Item("Design Style"), g_oAeccDb.AlignmentLabelStyleSets.Item("All Labels")) Dim fstLine As AeccAlignmentTangent Set fstLine = oAlignment.Entities.AddFixedLine1(pt1, pt2)
Autodesk Confidential Info
23
2005 Autodesk
Alignments
Sub AlignmentWithAddFreeSTSGroup1() Dim Curve1 As AeccAlignmentArc Dim Curve2 As AeccAlignmentArc ' Create the 1st Curve Set Curve1 = oAlignment.Entities.AddFixedCurve1(0, pt1, pt2, pt3) ' Create the 2nd Curve Set Curve2 = oAlignment.Entities.AddFixedCurve1(0, pt1, pt2, pt3)
Autodesk Confidential Info
' Add STS (Spiral-Line-Spiral) oAlignment.Entities.AddFreeSTSGroup1 Curve1.Id, Curve2.Id, 30, 25, aeccAlignmentSpiralClothoid, True End Sub
24
2005 Autodesk
' Add an offset alignment 10.0 units to the left of the original. oAlignment.Offset -10.0
Autodesk Confidential Info
25
2005 Autodesk
26
2005 Autodesk
Siteless Alignments
AlignmentsSiteless Alignments can now be created outside of sites. The AeccDocument object contains a new property called AlignmentsSiteless which contains a collection of alignments. ' Get the collection of all siteless alignments. Dim oAlignments as AeccAlignments Set oAlignments = oDocument.AlignmentsSiteless
Autodesk Confidential Info
28
2005 Autodesk
If an alignment exists on a site with parcels, the alignment will subdivide any parcels it crosses over. If one or more alignments on a site form a closed region, a parcel will be created from the region.
If you do not want an alignment to interact with other objects use this new object - AlignmentsSiteless while creating an Alignment.
29
2005 Autodesk
Profiles
There are two distinct Civil 3D entities when using Profiles, the Profile itself and the Profile View. The Profile is the actual section cut through a surface or the proposed design profile and has it's associated style and label style. The Profile View is the data surrounding the display of the profile line - grids, axes, labels and desired band styles, which contain data on any side of the grid, horizontal / vertical geometry data etc.
30
2005 Autodesk
Profiles
'Create a profile named "Adsk Sample Profile" Dim oProfile As AeccProfile Set oProfile = oProfiles.AddFromSurface(sProfileName, aeccExistingGround, oProfileStyle, _ oSurf.Name, oAlignment.StartingStation, oAlignment.EndingStation, "0") If oProfile Is Nothing Then MsgBox "Error creating an existing ground profile" Exit Sub End If
Autodesk Confidential Info
'Set properties to the newly created profile oProfile.Style.LineDisplayStyle2d.color = acRed oProfile.Style.PVIPointDisplayStyle2d.color = acGreen
31
2005 Autodesk
Profiles
Creating a Profile View
'Set parameters that are need to create a profile view
If oProfileView Is Nothing Then Set oProfileView = oAlignment.ProfileViews.Add(sPViewName, _ sLayerName, originPt, oPVStyle, oPVBandStyleSet) End If
32
2005 Autodesk
Profiles
Creating a Profile By Layout
'Add a new profile to the AeccAlignment object
Dim oProfl As AeccProfile Set oProfl = oAlignment.Profiles.Add("FGProfile", aeccFinishedGround, "Finished Ground", oAlignment.StartingStation, oAlignment.EndingStation, "0") Dim oPVIs As AeccProfilePVIs Set oPVIs = oProfl.PVIs
Autodesk Confidential Info
Sections
Typically, sections are cut across horizontal (plan) alignments at a specified station interval using specified swath widths. These sections are then plotted, individually for a station, or as a group for a range of stations.
34
2005 Autodesk
Sections
Creating Sample Lines
' Create a sample line group Dim oSampleLineGroup As AeccSampleLineGroup Set oSampleLineGroup = oAlignment.SampleLineGroups.Add(sSLGName, sLayerName, oGPStyle, oSLStyle, oSLabelStyle) 'Set parameters for sample line Dim oSampleLine As AeccSampleLine Const sKey = "Adsk Sample Line" Dim dStationID As Double dStationID = 0 + 51.963 Dim dLeftSwathLenghth As Double dLeftSwathLenghth = 30#
Autodesk Confidential Info
'Create sample line by Station If oSampleLine Is Nothing Then Set oSampleLine = oSampleLineGroup.SampleLines.AddByStation(sKey, dStationID, dLeftSwathLenghth, dRightSwathLenghth) End If
35
2005 Autodesk
Sections
Creating Section View
'Set parameters for section view Const sSectionView = "Adsk Section View" Const sLayer = "Adsk Layer" Dim originPt(0 To 2) As Double ' Select the Origin Point 'Set section view style for the section view Dim oSVStyle As AeccSectionViewStyle 'Set section view band style set for the section view Dim oSVBStyleSet As AeccSectionViewBandStyleSet
Autodesk Confidential Info
'Create section view Dim oSectionView As AeccSectionView If oSectionView Is Nothing Then Set oSectionView = oSampleLine.SectionViews.Add(sSectionView, sLayer, originPt, oSVStyle, oSVBStyleSet) End If
36
2005 Autodesk
37
2005 Autodesk
38
2005 Autodesk
39
2005 Autodesk
There are several standard subroutines that must be implemented for each subassembly within its module. These subroutines are described below for a sample subassembly called adskRailType01.
40
2005 Autodesk
41
2005 Autodesk
42
2005 Autodesk
Corridors
New Methods in Civil 3D 2008 :
44
2005 Autodesk
Survey
Function GetSurveyObjects() ' Function to set up the Civil 3D Survey application, document and database object Dim oApp As AcadApplication Set oApp = ThisDrawing.Application Dim sAppName As String sAppName = "AeccXUiSurvey.AeccSurveyApplication" Set g_oCivilSurveyApp = oApp.GetInterfaceObject(sAppName) If g_oCivilSurveyApp Is Nothing Then MsgBox "Error creating " & sAppName & ", exit." GetCivilObjects = False Exit Function End If Set g_oAeccSurveyDoc = g_oCivilSurveyApp.ActiveDocument End Function
45
2005 Autodesk
Survey
Create a Survey Project Set oSurveyProjs = g_oAeccSurveyDoc.Projects If oSurveyProjs.Count = 0 Then Set oSurveyProj = oSurveyProjs.Create("Survey 1") Else
'Create a Survey network Set oNetworks = oSurveyProj.Networks If oNetworks.Count = 0 Then Set oNetwork = oSurveyProj.Networks.Create("Survey Network 1") Else
46
2005 Autodesk
' Draw a line 30 meters long at 10 degrees from the major axis. oFigure.AddLineByAzimuthDistance 0.17453, 30
47
2005 Autodesk
48
2005 Autodesk
Pipe Network
A pipe network object manages a collection of pipe objects and structure objects that are associated with each other to represent a pipe system. Typically, the pipes and structures are connected to each other, forming a single pipe run or pipe network. The pipe and structure objects in a pipe network are typically associated with an alignment, and/or a surface(s), which provide them with station offset and elevation data. The pipe network object is used as the container object to associate pipes and structures that are part of the same pipe run or pipe network. A pipe network typically contains pipe objects and structure objects.
49
2005 Autodesk
Pipe
A pipe object is a drawing shape that represents straight or curved pipes used in utility networks, such as sewer and irrigation systems. In a drawing, the three-dimensional pipe shape is defined by: 1) the two-dimensional Part Shape (circular, elliptical, egg-shaped, or rectangular) of the pipe part that is selected from the part catalog; and 2) by specifying a linear path (for straight piped) or a curved path (for curved piped). Object names for pipes are not displayed in the Prospector tree. They are, however, displayed in the Prospector list view when you click Pipes under a pipe network in the Prospector tree.
50
2005 Autodesk
Structure
A structure object is a drawing shape that is used to represent items, such as manholes, catch basins, and headwalls, used in utility networks. Structure shapes are inherently more complex than pipe shapes. In a drawing, the three-dimensional structure shape is defined by the definition of the structure part that is selected from the part catalog. Like pipes, object names for structures are not displayed in the Prospector tree. They are, however, displayed in the Prospector list view when you click Structures under a pipe network in the Prospector tree.
Autodesk Confidential Info
51
2005 Autodesk
VB users can get the AeccPipeApplication object through an instance of the AutoCAD.Application object:
Dim oTest As AutoCAD.AcadApplication On Error Resume Next oTest = GetObject(,"AutoCAD.Application") If Err.Number <> 0 Then Err.Clear() oTest = CreateObject("AutoCAD.Application") If Err.Number <> 0 Then Exit Sub End If End If Dim oAeccPipeApp as AeccXUiPipe.AeccPipeApplication oAeccApp = oTest.GetInterfaceObject("AeccXUiPipe.AeccApplication")
52
2005 Autodesk
53
2005 Autodesk
For Each oPartFamily In oAeccPartlist If oPartFamily.Domain = aeccDomPipe Then If oPartFamily.Name = "Concrete Pipe" Then sPipeGuid = oPartFamily.GUID Set oPipeSizeFilter = oPartFamily.SizeFilters.Item(1) Exit For End If End If Next
54
2005 Autodesk
55
2005 Autodesk
56
2005 Autodesk
57
2005 Autodesk
58
2005 Autodesk
During object draw, the callback function is called with an interface pointer for the object as well as an anonymous block
bool AlignmentCallbackFunction(const AeccDisplayOrientation &viewMode, IAeccAlignment *pAlign, IAcadBlock *pAnonymousBlock ) { //// }
Return true, if you want Civil 3D to draw the block, false otherwise
Autodesk Confidential Info
Using the object you calculate the graphics to draw an add them to the anonymous block (instead of Modelspace) Block is returned to the object, and added to the graphics stream
59
2005 Autodesk
.NET Subassemblies
The default subassemblies included with Civil 3D 2008 are now created using .NET framework.
60
2005 Autodesk
.NET Subassemblies
To maintain backward compatibility, VBA subassemblies are also supported in Civil 3D 2008. Civil 3D 2008 includes a Utility to convert VBA Subassemblies to .NET
61
2005 Autodesk
Detailed information about these requirements of designing custom subassemblies are available in Civil 3D 2008 Developers Guide topic Designing Custom Subassemblies.
62
2005 Autodesk
click Help. From a Tool Catalog - Right-click a subassembly in a tool catalog, then click Help. From the Subassembly Properties dialog box Parameters tab - Rightclick a subassembly in the Prospector tree, then click Properties Parameters tab Subassembly Help.
Autodesk Confidential Info
You can use any type of document file (.dwf, .doc, .pdf, .txt, .chm, .hlp) to create the subassembly help file. For more information, see Creating Customized Help in the AutoCAD Developer Help.
63
2005 Autodesk
The Subassembly Template (SATemplate.vb) The Corridor State Object Support Files (CodeSpecific.vb, Utility.vb)
64
2005 Autodesk
65
2005 Autodesk
66
2005 Autodesk
Utility.vb provides a series of shared helper functions for error handling, computing subassembly geometry, attaching code strings, and other tasks. For example, to report a parameter not found error to the Civil event viewer, use the following line:
Autodesk Confidential Info
67
2005 Autodesk
.NET source code of subassemblies available at - C:\Documents and Settings\All Users\Application Data\Autodesk\C3D 2008\enu\Sample\Civil 3D API\C3DstockSubAssemblies
68
2005 Autodesk
Copy the compiled subassembly .dll library to its destination directory. By default, libraries are located in C:\Program Files\Autodesk Civil 3D 2008\Data\Models. Copy the tool catalog .atc files to its destination directory. The tool catalog files are normally located in the C:\Documents and Settings\All Users\Application Data\Autodesk\C3D 2007\enu\Tool Catalogs directory. Copy optional files such as the image file representing the subassemblies or the help file to their destination directory. Copy the catalog cover page .html file to its destination. Usually this is the same location as the .atc file, although it can be any directory as long as the .atc file has the correct relative path information.
2.
3.
4.
Autodesk Confidential Info
5.
Register the tool catalog using a registry (.reg) file. This .reg file must have the correct paths to the .atc file and the catalog image file from steps 2) and 3).
69
2005 Autodesk
Developer Resources
Civil 3D API Help file Code Samples provided with Product installation at C:\Program Files\Autodesk Civil 3D 2008\Sample\Civil 3D API ADN site & Devnotes Civil 3D site www.autodesk.com/civil3d
70
2005 Autodesk
Thank You
71
2005 Autodesk