Vous êtes sur la page 1sur 71

AutoCAD Civil 3D 2008 API Overview

Partha Sarkar Developer Technical Services


Autodesk Confidential Info

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.

Autodesk Confidential Info

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)

New API in Civil 3D 2008 (Beta)


.NET based Subassembly

Enhancements to existing API

2005 Autodesk

Referencing the Automation Type Libraries


Before any coding begins, this ActiveX programming interface requires references to automation type libraries as follows:

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)

Autodesk Confidential Info

2005 Autodesk

Referencing the Automation Type Libraries


If referencing Roadway objects, then additional references must be added as follows:

Autodesk Civil Engineering Corridor 5.0 Object Library (AeccXRoadway) Autodesk Civil Engineering UI Corridor 5.0 Object Library (AeccXUIRoadway)

Autodesk Confidential Info

2005 Autodesk

Getting the Application Objects


Following is the recommended method (assuming VBA is used) to get an instance of AeccApplication:
Dim AeccApp as AeccApplication Set AeccApp = ThisDrawing.Application.GetInterfaceObject("AeccXUiLand.AeccApplication")

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")

Autodesk Confidential Info

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

oPoint.Name = "Mytest Point"

2005 Autodesk

Points Import / Export from External Files


To import points into Civil 3D from ASCII (text) file or a Microsoft Access database (.mdb) file, use the ImportPoints() method.
Public Sub InsertPoints() getCivilObjects Dim cPoints As AeccPoints Dim options As New AeccPointImportOptions options.ExpandCoordinateData = True Set cPoints = g_oAeccDb.Points cPoints.ImportPoints "c:\Existing Ground Points PENZD.txt", "PENZD (space delimited)", options End Sub
Autodesk Confidential Info

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

Points Import / Export from External Files


The second parameter of the ImportPoints and ExportPoints methods is a string that describes how the point values are stored in the file. The following table lists some commonly available file formats. Custom formats can be created by using the Point File Format dialog box.

Autodesk Confidential Info

2005 Autodesk

Points Adding to Point Group


' Add point 1 and point 2 to the point group.
oPtGroup.QueryBuilder.IncludeNames = "point1," & oPoint2.Name

' Add point 3 to the point group by using its number.


oPtGroup.QueryBuilder.IncludeNumbers = oPoint3.Number

' You can also use wildcards. The following would select all points with a name beginning with "pol".
oPtGroup.QueryBuilder.IncludeNames = "pol*"

' Exclude those points with an alitude above 300.


Autodesk Confidential Info

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.

Autodesk Confidential Info

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

Autodesk Confidential Info

12

2005 Autodesk

Surfaces Create From LandXML


Using AeccSurfaces:: ImportXML() Method we can add a LandXML surface data file to create a new Surface (AeccSurface) in Civil 3D.
Dim oSurface As AeccSurface Dim sFileName As String sFileName = D:\My_Temp\EG.xml" Set oSurface = oAeccDocument.Surfaces.ImportXML(sFileName) Dim oTinSurface as AeccTinSurface If (oSurface.Type = aecckTinSurface) Then Set oTinSurface = oSurface End If

Autodesk Confidential Info

13

2005 Autodesk

Surfaces Adding DEM files / Contours / BreakLine etc


Adding a DEM file
oTinSurface.DEMFiles.Add("D:\Temp_Test\file1.dem")

' adding a contour to a surface


Dim oNewContour As AeccSurfaceContour Set oNewContour = oTinSurf.Contours.Add(oEntities, "Sample Contour", dWeedDist, dWeedAngle, dDist, dMidOrdDist)

' adding a Standard BreakLine


ThisDrawing.Utility.GetEntity Ent, Pt, "Select a polyline for breakline" Set SelObjs(0) = Ent Set oBrkLn = oTinS.Breaklines.AddStandardBreakline(SelObjs, BrklnDesc, 1#) oTinS.Rebuild

Autodesk Confidential Info

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.

Autodesk Confidential Info

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.

Autodesk Confidential Info

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)

Autodesk Confidential Info

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

Autodesk Confidential Info

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.####")

Autodesk Confidential Info

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.

Autodesk Confidential Info

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

Other methods... AddFreeCurve1() AddFloatingCurve1() AddFixedSpiral1()

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

Alignment - Create From Offset of Another Alignment


Alignments can also be created based on the layout of existing alignments. The AeccAlignment.Offset method will create a new alignment with a constant offset and add it to the same parent site as the original alignment.

' Add an offset alignment 10.0 units to the left of the original. oAlignment.Offset -10.0
Autodesk Confidential Info

25

2005 Autodesk

Alignment - Add Station Equation


Dim oAlign As AeccAlignment Dim oStationEquation As AeccStationEquation ThisDrawing.Utility.GetEntity obj, pt, "pick alignment" If TypeOf obj Is AeccAlignment Then Set oAlign = obj End If Set oStationEquation = oAlign.StationEquations.Add(700, 0, 1100, aeccIncreasing)

Autodesk Confidential Info

26

2005 Autodesk

Alignment - Add Design Speeds


If TypeOf obj Is AeccAlignment Then Set oAlign = obj ' Starting at station 0 + 00.00 Set oDesignSpeed = oAlign.DesignSpeeds.Add(0#) oDesignSpeed.Value = 40 oDesignSpeed.Comment = "Straightaway" ' Starting at station 1 + 00.00 Set oDesignSpeed = oAlign.DesignSpeeds.Add(100#) oDesignSpeed.Value = 60 oDesignSpeed.Comment = "Straight Road" ' Starting at station 6 + 0.00 to the end. Set oDesignSpeed = oAlign.DesignSpeeds.Add(600#) oDesignSpeed.Value = 45 oDesignSpeed.Comment = "Curves start here" ZoomExtents MsgBox "Design Speeds are Added to Alignment !" End If
27
2005 Autodesk

Autodesk Confidential Info

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

Siteless Alignments What is it ?


If Alignments are placed on a site, they will interact with other objects on the site in two ways :

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.

Autodesk Confidential Info

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.

Autodesk Confidential Info

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

Dim oProfileView As AeccProfileView . .


'Get access to existing AeccProfileViewBandStyleSet in the drawing

Dim oPVBandStyleSet As AeccProfileViewBandStyleSet Set oPVBandStyleSet = g_oAeccDoc.ProfileViewBandStyleSets.Item(0)


Autodesk Confidential Info

'Create a Profile view by adding a AeccProfileView object to the ProfileViews collection

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

'Add PVIs to the profile


oPVIs.Add 0 + 2.51, 286.7, aeccTangent oPVIs.Add 0 + 23.14, 284.09, aeccTangent oPVIs.Add 0 + 37.021, 288.23, aeccTangent oPVIs.Add 0 + 57.486, 288.29, aeccTangent oPVIs.Add 0 + 88.251, 291.86, aeccTangent oPVIs.Add 0 + 91.892, 289.3, aeccTangent
33
2005 Autodesk

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.

Autodesk Confidential Info

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

Corridors & Subassemblies


A corridor model builds on and uses various Autodesk Civil 3D objects and data, including subassemblies, assemblies, alignments, surfaces, and profiles. Corridor objects are created a baseline (alignments) by placing a 2D section (assembly) at incremental locations and by creating matching slopes that reach a surface model at each incremental location

Autodesk Confidential Info

37

2005 Autodesk

Creating Custom Subassemblies


Subassemblies are the basic building blocks of a corridor design. A subassembly is an AutoCAD drawing object (AECCSubassembly) that defines the geometry of a component used in a corridor section. Through the tool palette and tool catalogues, Autodesk Civil 3D provides preconfigured subassemblies for components such as carriageways, kerbs, batter slopes and ditches. These subassemblies are defined by a set of points, links, and optionally closed areas referred to as shapes. The subassemblies provided with Autodesk Civil 3D have built-in intelligent behavior.

Autodesk Confidential Info

38

2005 Autodesk

Creating Custom Subassemblies


You can develop Visual Basic for Applications (VBA) scripts to define custom subassemblies that provide specific behavior. The actions that occur when a subassembly is used in an assembly, and when subassemblies are processed during corridor creation, are specified through VBA scripts. The Autodesk Civil 3D COM API includes objects, methods, and properties specifically designed to provide an interface to assemblies and corridor models for subassembly VBA scripts.

Autodesk Confidential Info

39

2005 Autodesk

Creating Custom Subassemblies


VBA Structure for Subassemblies Each subassembly should have a separate module in the VBA library, where the module name matches the subassembly name. For example, the subassembly adskRailType01 is executed by the subroutines in a module that is also called adskRailType01.

Autodesk Confidential Info

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

Creating Custom Subassemblies


VBA Structure for Subassemblies -

Autodesk Confidential Info

41

2005 Autodesk

Creating a Subassembly Tool


Catalog
You can create an Autodesk tool catalog to organize groups of customized subassemblies and make them available to Autodesk Civil 3D users. Autodesk tool catalogs are defined using xml-formatted files with an .atc (Autodesk Tool Catalog) extension. You also need to create a catalog registry file since catalogs must be registered in the Windows registry. Some items within the .atc and registry files must contain unique identifiers known as GUIDs (Global Unique Identifiers).

Autodesk Confidential Info

42

2005 Autodesk

Creating a Subassembly Tool


Catalog
Sample Tool Catalog ATC File
1. <Catalog> 2. <ItemID idValue="{410D0B43-19B3-402F-AB4105A6E174AA3F}"/> 3. <Properties> 4. <ItemName>Corridor Modeling Catalogs (Imperial)</ItemName> 5. <Images> 6. <Image cx="93" cy="123" src=".\Images\AeccCorridorModel.png"/> 7. </Images> 8. <AccessRight>0</AccessRight> 9. <Description>This catalog contains Subassembly tools for corridor modeling with Imperial units.</Description>

Autodesk Confidential Info

<Refer Civil 3D Help File for the complete Sample>


43
2005 Autodesk

Corridors
New Methods in Civil 3D 2008 :

AeccBaseline.AddStation AeccBaseline.DeleteStation AeccCorridors.Add AeccCorridor.AddBaseline


Autodesk Confidential Info

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

Autodesk Confidential Info

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

Autodesk Confidential Info

46

2005 Autodesk

Survey Create Figures / Lineworks


Add Figure Objects Dim oFigure As AeccSurveyFigure Set oFigure = oSurveyProject.Figures.Create("Figure_01") ' Draw a line to the location of survey point 3001. Dim oPoint1 As AeccSurveyPoint Set oPoint1 = oSurveyProject.GetPointByNumber(3001) oFigure.AddLineByPoint oPoint1.Easting, oPoint1.Northing, 3001

Autodesk Confidential Info

' Draw a line 30 meters long at 10 degrees from the major axis. oFigure.AddLineByAzimuthDistance 0.17453, 30

47

2005 Autodesk

Survey Add Figures to Drawing


Adding lines and arcs to a figure changes the survey database but does not automatically change the drawing. After adding elements to the figure use AeccSurveyFigure.AddToDrawing method to make them visible and editable through the user interface.

'Save figure and write it to drawing


oFig.Save oFig.AddToDrawing ThisDrawing.Application.ZoomExtents
Autodesk Confidential Info

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.

Autodesk Confidential Info

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.

Autodesk Confidential Info

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

Getting the Pipe Application Objects


Following is the recommended method (assuming VBA is used) to get an instance of AeccPipeApplication:
Dim AeccPipeApp as AeccPipeApplication AeccPipeApplication Set AeccPipeApp = ThisDrawing.Application.GetInterfaceObject("AeccXUiPipe.AeccPipeApplication")

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")

Autodesk Confidential Info

52

2005 Autodesk

Create Pipe Network


To create Network, you should get the networks through AeccPipeDocument firstly, then use add method to create it or use Item method to return it by inputting the name
Dim oNetworks As AeccPipeNetworks Dim oNetwork As AeccPipeNetwork Set oNetworks = g_oAeccPipeDoc.PipeNetworks Set oNetwork = Nothing Set oNetwork = oNetworks.Item("SampleNetwork") If oNetwork Is Nothing Then Set oNetwork = oNetworks.Add("SampleNetwork") End If ' set the reference alignment and surface Dim oAlign As AeccAlignment Dim oSurface As AeccSurface Set oAlign = g_oAeccPipeDoc.Sites.Item(0).Alignments.Item("ROAD1") Set oSurface = g_oAeccPipeDoc.Surfaces.Item("EG") oNetwork.ReferenceAlignment = oAlign oNetwork.ReferenceSurface = oSurface

Autodesk Confidential Info

53

2005 Autodesk

Creating Pipe and Structure


After we get or create the network object, we can create pipe or structure object, before we do this we should return the PartFamilyGuid and PartSizeFilter to prepare for the creation. Just like the following code:
Dim oAeccPipeSettingRoot As AeccPipeSettingsRoot Set oAeccPipeSettingRoot = g_oAeccPipeDb.Settings Dim oAeccPartlists As AeccPartLists Dim oAeccPartlist As AeccPartList Set oAeccPartlists = oAeccPipeSettingRoot.PartLists Set oAeccPartlist = oAeccPartlists.Item(0) Dim oPartFamily As AeccPartFamily Dim oPipeSizeFilters As AeccPartSizeFilters Dim oPipeSizeFilter As AeccPartSizeFilter Dim sPipeGuid As String
Autodesk Confidential Info

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

Create Pipe and Structure


Add a new structure to the network:
Dim oStructure As AeccStructure Set oStructure = oNetwork.Structures.Add(sStructGuid, oStructSizeFilter, pt0, 1) set the style Set oStructure.Style = oStructureStyle

Add a new Pipe to the network:


Dim oPipe As AeccPipe Set oPipe = oNetwork.Pipes.Add(sPipeGuid, oPipeSizeFilter, pt0, pt1) Set oPipe.Style = oPipeStyle 'connect the pipe to the structure oPipe.ConnectToStructure aeccPipeStart, oStructure

Autodesk Confidential Info

55

2005 Autodesk

Pipe and Structure Information


Go through the current drawing to print the main properties of the pipe or structure object information:
Sub outputPipeInfo() Dim obj As AcadObject Dim oPipe As AeccPipe Dim oStructure As AeccStructure For Each obj In ThisDrawing.ModelSpace If TypeOf obj Is AeccPipe Then Set oPipe = obj ThisDrawing.Utility.Prompt (vbCrLf & "pipe's name:" & oPipe.Name) ThisDrawing.Utility.Prompt (vbCrLf & "Description:" & oPipe.Description) ThisDrawing.Utility.Prompt (vbCrLf & "Start point:(" & oPipe.StartPoint.X & "," & oPipe.StartPoint.Y & "," & oPipe.StartPoint.Z & ")") ThisDrawing.Utility.Prompt (vbCrLf & "End point:(" & oPipe.EndPoint.X & "," & oPipe.EndPoint.Y & "," & oPipe.EndPoint.Z & ")") Dim dSlope As Double dSlope = (oPipe.EndPoint.Z - oPipe.StartPoint.Z) / oPipe.Length2D ThisDrawing.Utility.Prompt (vbCrLf & "Slope :" & dSlope & vbCrLf) Autodesk Confidential Info ElseIf TypeOf obj Is AeccStructure Then Set oStructure = obj ThisDrawing.Utility.Prompt (vbCrLf & "Structure name:" & oStructure.Name) ThisDrawing.Utility.Prompt (vbCrLf & "Description:" & oStructure.Description) ThisDrawing.Utility.Prompt (vbCrLf & "Position:(" & oStructure.Position.X & "," & oStructure.Position.Y & "," & oStructure.Position.Z & ")" & vbCrLf) End If Next End Sub

56

2005 Autodesk

Pipe and Structure Styles


New Objects in Civil 3D 2008 :

AeccPipeNetworkLabelStyles AeccPipeLabelStyles AeccStructureLabelStyles

Autodesk Confidential Info

57

2005 Autodesk

Custom Draw API


A C++ API used to enhance / supplant existing graphics for customized display Used in Object ARX context No proxy objects / no object enablers involved

CustomDraw Sample available at <AutoCAD Civil 3D 2008 Installation Folder>\Sample\Civil 3D API\VC++\CustomDraw


Autodesk Confidential Info

58

2005 Autodesk

Custom Draw API


How it works One or more user-implemented callback functions are registered when application is initialized, e.g.
AeccCustomDraw.setAlignmentDraw(AlignmentCallbackFunction)

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

New graphics are part of the object for the display

59

2005 Autodesk

.NET Subassemblies
The default subassemblies included with Civil 3D 2008 are now created using .NET framework.

Autodesk Confidential Info

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

Autodesk Confidential Info

61

2005 Autodesk

Designing Subassemblies (.NET)

Autodesk Confidential Info

Detailed information about these requirements of designing custom subassemblies are available in Civil 3D 2008 Developers Guide topic Designing Custom Subassemblies.
62
2005 Autodesk

Creating Subassemblies Help Files


You can provide detailed construction and behavior information of Custom Subassembly in a Help file. The same help file can be displayed in AutoCAD Civil 3D using any of the following methods:
From a Tool Palette - Right-click a subassembly in a tool palette, then

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

Structure of Subassembly (.NET)


The Subassembly Template (SATemplate.vb) The Corridor State Object Support Files (CodeSpecific.vb, Utility.vb)

Autodesk Confidential Info

64

2005 Autodesk

Subassembly Template (SATemplate.vb)


All custom subassemblies are defined as classes that inherit from the SATemplate class. SATemplate provides four methods which you can override in your own class to provide functionality of your subassembly.

Autodesk Confidential Info

65

2005 Autodesk

Corridor State Object


The CorridorState object is the primary interface between the custom subassembly and the collection of points, links, and shapes of the current assembly which the subassembly is to connect to. The CorridorState methods provide useful calculation functions for corridor design. These include the following:

Autodesk Confidential Info

66

2005 Autodesk

Support Files (CodeSpecific.vb, Utility.vb)


You can also use the two support files CodeSpecific.vb and Utility.vb in your subassembly. CodeSpecific.vb provides the CodeType and AllCodes structures and the global variable Code - an instance of an AllCodes structure with all code information filled.

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

Utilities.RecordError(corridorState, CorridorError.ParameterNotFound, "Edge Offset", "BasicLaneTransition")

67

2005 Autodesk

Sample VB.NET Subassembly


Imports System.Math Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.Civil.Corridor Imports Autodesk.Civil Imports Autodesk.Civil.Alignment Imports Autodesk.Civil.Profile Imports Shape = Autodesk.Civil.Corridor.Shape Imports DBTransactionManager = Autodesk.AutoCAD.DatabaseServices.TransactionManager
Autodesk Confidential Info

.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

Custom Subassemblies - Installation


1.

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

Autodesk Confidential Info

70

2005 Autodesk

Thank You

Autodesk Confidential Info

71

2005 Autodesk

Vous aimerez peut-être aussi