Author Topic: Pipe - Alignment StationOffset (C3D)  (Read 868 times)

0 Members and 1 Guest are viewing this topic.

surveyor_randy

  • Guest
Pipe - Alignment StationOffset (C3D)
« on: November 20, 2007, 10:33:56 AM »
I am trying to extract the station and offset from an alignment for a particular pipe, here is my code so far:

Code: [Select]
Sub AddCOGOPointsForPipe()

Dim sCivilAppName As String
sCivilAppName = "AeccXUiLand.AeccApplication.5.0"
Dim oAcadApp As AcadApplication
Set oAcadApp = ThisDrawing.Application
Dim oEnt As AcadEntity
Dim oCivilApp As AeccApplication
Set oCivilApp = oAcadApp.GetInterfaceObject(sCivilAppName)
Dim oDocument As AeccDocument
Set oDocument = oCivilApp.ActiveDocument
Dim oPoints As AeccPoints
Set oPoints = oDocument.Points
Dim oPoint As AeccPoint
Dim oPipe As AeccPipe
Dim vStation As Double
Dim vOffset As Double
Dim vPipeStart(2) As Double
Dim vPipeEnd(2) As Double
Dim vSelectedPoint As Variant
   
ThisDrawing.Utility.GetEntity oEnt, vSelectedPoint, "Select Pipe: "
   
Set oPipe = oEnt

oPipe.StartPoint.GetPoint vPipeStart(0), vPipeStart(1), vPipeStart(2)
oPipe.Endpoint.GetPoint vPipeEnd(0), vPipeEnd(1), vPipeEnd(2)
vPipeStart(2) = vPipeStart(2) - oPipe.InnerHeight
vPipeEnd(2) = vPipeEnd(2) - oPipe.InnerHeight

[color=red]oPipe.Alignment.StationOffset vPipeStart(0), vPipeStart(1), vStation, vOffset
MsgBox "station: " & vStation & " - offset: " & vOffset[/color]

Set oPoint = oPoints.Add(vPipeStart)
Set oPoint = oPoints.Add(vPipeEnd)

Set oPipe = Nothing
Set oPoint = Nothing
Set oAcadApp = Nothing
Set oCivilApp = Nothing
Set oDocument = Nothing
Set oPoints = Nothing

End Sub

The Red portion of the code is where I am having trouble.  Could someone tell me what I am doing wrong here, thanks a bunch!

Jeff_M

  • King Gator
  • Posts: 3946
  • C3D user & customizer
Re: Pipe - Alignment StationOffset (C3D)
« Reply #1 on: November 20, 2007, 12:28:26 PM »
Hi Randy,
Could you describe what the problem is? I tested this with the Tutorial drawing "PipeNetworks-3C", selected the 24" pipe between structures 2 & 12, and it gave me the correct result.

Jeff

surveyor_randy

  • Guest
Re: Pipe - Alignment StationOffset (C3D)
« Reply #2 on: November 20, 2007, 12:45:42 PM »
Hi Jeff,

I am getting a Run-time error '91':
Object variable or With block variable not set
on the 'oPipe.Alignment.StationOffset vPipeStart(0), vPipeStart(1), vStation, vOffset' line of the code.

surveyor_randy

  • Guest
Re: Pipe - Alignment StationOffset (C3D)
« Reply #3 on: November 20, 2007, 12:50:13 PM »
Hmmmm....  I just tried it with the same drawing and it produces the proper results.  I was working with a drawing from the book 'Mastering AutoCAD Civil 3D 2008'.  It is probably an incomplete drawing that doesn't have alignments associated with pipes or something of that nature.

Jeff_M

  • King Gator
  • Posts: 3946
  • C3D user & customizer
Re: Pipe - Alignment StationOffset (C3D)
« Reply #4 on: November 20, 2007, 01:10:44 PM »
Yep, I was thinking that there must not be an alignment associated with the pipe.