Export Parcel as LWPolyline

Export Parcel as LWPolyline

Anonymous
Not applicable
914 Views
7 Replies
Message 1 of 8

Export Parcel as LWPolyline

Anonymous
Not applicable
Does anyone have any sample code to export an parcel as a LWPolyline? I noticed that there was a built in function to export an alignment as a LWPolyline, but I don't see one for parcels.
0 Likes
915 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Here ya go....I tested this with all the parcels in the 2008 Tutorial
drawing "Parcel-3".

[code]
Option Explicit

Sub Parcel2Pline()
Dim Parcel As AeccParcel
Dim pLoop As AeccParcelLoop
Dim pObj As Object
Dim parLine As AeccParcelSegmentLine
Dim parArc As AeccParcelSegmentCurve
Dim oEnt As AcadEntity
Dim vPick As Variant
Dim vCoords() As Double
Dim vBulge() As Double

On Error Resume Next
Dim i As Integer

Do Until Err.Number <> 0
ThisDrawing.Utility.GetEntity oEnt, vPick, vbCr & "Select Parcel to draw
pline of: "
If TypeOf oEnt Is AeccParcel Then
Set Parcel = oEnt
Set pLoop = Parcel.ParcelLoops(0)
ReDim vCoords(pLoop.Count * 2 + 1)
ReDim vBulge(pLoop.Count - 1)
i = 0
For Each pObj In pLoop
If TypeOf pObj Is AeccParcelSegmentLine Then
Set parLine = pObj
If i = 0 Then
vCoords(i) = parLine.StartX
vCoords(i + 1) = parLine.StartY
End If
vCoords((i + 1) * 2) = parLine.EndX
vCoords((i + 1) * 2 + 1) = parLine.EndY
Else
Set parArc = pObj
If i = 0 Then
vCoords(i) = parArc.StartX
vCoords(i + 1) = parArc.StartY
End If
vCoords((i + 1) * 2) = parArc.EndX
vCoords((i + 1) * 2 + 1) = parArc.EndY
vBulge(i) = parArc.Bulge
End If
i = i + 1
Next
Dim oPline As AcadLWPolyline
Set oPline = ThisDrawing.ModelSpace.AddLightWeightPolyline(vCoords)
For i = 0 To UBound(vBulge)
oPline.SetBulge i, vBulge(i)
Next
End If
Loop

End Sub
[/code]

wrote in message news:[email protected]...
Does anyone have any sample code to export an parcel as a LWPolyline? I
noticed that there was a built in function to export an alignment as a
LWPolyline, but I don't see one for parcels.
0 Likes
Message 3 of 8

Anonymous
Not applicable
I am trying to use some of your code below for a different application. I can't get my VBA to recognize the type of Aecc. . . objects.

This line in my code:

If TypeOf objSelect Is AeccParcelSegmentLine Then

renders a

Compile error:
User-defined type not defined

Error.

Do I need to initiate some reference? Is there something I'm missing?

Thanks,
David
0 Likes
Message 4 of 8

Anonymous
Not applicable
Yes, you must reference the Civil3D Land Libraries, as outlined in the
"Getting Started" section of the Civil API reference.

wrote in message news:[email protected]...
I am trying to use some of your code below for a different application. I
can't get my VBA to recognize the type of Aecc. . . objects.

This line in my code:

If TypeOf objSelect Is AeccParcelSegmentLine Then

renders a

Compile error:
User-defined type not defined

Error.

Do I need to initiate some reference? Is there something I'm missing?

Thanks,
David
0 Likes
Message 5 of 8

Anonymous
Not applicable
Jeff,

I am new at the Civil 3D thing. Where can I find the Civil API reference.

Thanks,
David
0 Likes
Message 6 of 8

Anonymous
Not applicable
Hi,

Further to Jeff's comment, you may find that you cannot actually select a
Parcel segment and then find that it is a AeccParcelSegmentLine.

If you need to work with the Segment, then you will probably find you need
to select the Parcel (which you do by Selecting the Parcel label) and then
selecting a point, followed by examining the parcel segment collection to
find which one is nearest the point you select.

Here's some very rough code I used to confirm my thinking

Sub test()
Dim objSelect As AcadObject
Dim pt(0 To 2) As Double
Dim ff As AeccParcelSegmentLine
Dim gg As AeccParcel
Dim hh As AeccParcelLoop
' ThisDrawing.Utility.GetEntity objSelect, pt, "Select a parcel side"
ThisDrawing.Utility.GetEntity objSelect, pt, "Select a parcel label"
' If TypeOf objSelect Is AeccParcelSegmentLineThen
If TypeOf objSelect Is AeccParcel Then
' Set ff = objSelect
Set gg = objSelect
Set hh = gg.ParcelLoops.Item(0)
Set ff = hh.Item(1)

End If

End Sub

To work with Parcel sides - depending on what you want to do, you may find
it easier to set up a form allowing the user to select a Site for a list of
sites with parcels
From the site populate a list of parcels in the site
Allow the user to select a parcel and zoom to the parcel, draw a polyline
with arrow head along the first segment and give the user a
option and/or type in a segment number and/or select the segment number from
a list of the number of segments in that parcel to identify the required
side. Update the polyline (and zoom window if relevant) each time the user
changes anything in the form.

--

Laurie Comerford
CADApps
www.cadapps.com.au
www.civil3Dtools.com

"Jeff Mishler" wrote in message
news:[email protected]...
Yes, you must reference the Civil3D Land Libraries, as outlined in the
"Getting Started" section of the Civil API reference.

wrote in message news:[email protected]...
I am trying to use some of your code below for a different application. I
can't get my VBA to recognize the type of Aecc. . . objects.

This line in my code:

If TypeOf objSelect Is AeccParcelSegmentLine Then

renders a

Compile error:
User-defined type not defined

Error.

Do I need to initiate some reference? Is there something I'm missing?

Thanks,
David
0 Likes
Message 7 of 8

Anonymous
Not applicable
Hi David,
First, in C3D press F1 for the Help, in the left pane expand AutoCAD Civil3D
Help, select AutoCAD Civil 3D API Help, in the right pane select AutoCAD
Civil 3D API Reference, the first page displayed is the Getting Started
guide.....

Good Luck

wrote in message news:[email protected]...
Jeff,

I am new at the Civil 3D thing. Where can I find the Civil API reference.

Thanks,
David
0 Likes
Message 8 of 8

Anonymous
Not applicable
Hi,

In the VBA editor, select [Tools][References]

Look at the attached screen grabs will give you an idea what is needed for
R2008. These come from the Parcel Volumes report which I'm currently
adjusting to Australian Standards and the "Report_Utilities" is generally
only relevant for the Report projects.

However, the best way of overcoming the libraries issues is to ALWAYS start
a new Civil 3D project from one of the supplied sample files. That way the
libraries will already be in place and you will have the code to initiate
Civil 3D in place. Probably quite a bit of other code you need will be in
the sample file.

Note that with Civil 3D the libraries are version dependent and need to be
changed to run in the different versions of Civil 3D.


--

Laurie Comerford
CADApps
www.cadapps.com.au
www.civil3Dtools.com

wrote in message news:[email protected]...
Jeff,

I am new at the Civil 3D thing. Where can I find the Civil API reference.

Thanks,
David
0 Likes