Author Topic: VBA - Civil3D 2012  (Read 4862 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
VBA - Civil3D 2012
« on: September 24, 2013, 01:51:02 PM »
I keep erroring out on this line. Any ideas?

Function GetPipeObjects()
' Function to set up the Civil 3D Pipe application, document and database object
' NOTE: use the pipe application to get the pipe settings
    Dim oApp As AcadApplication
    Set oApp = ThisDrawing.Application
    Dim sAppName As String
    sAppName = "AeccXUiPipe.AeccPipeApplication"
    Set g_oCivilPipeApp = oApp.GetInterfaceObject(sAppName)
    If g_oCivilPipeApp Is Nothing Then
        MsgBox "Error creating " & sAppName & ", exit."
        GetCivilObjects = False
        Exit Function
    End If
    Set g_oAeccPipeDoc = g_oCivilPipeApp.ActiveDocument
    Set g_oAeccPipeDb = g_oAeccPipeDoc.Database
   
End Function

Thanks for the help!
Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: VBA - Civil3D 2012
« Reply #1 on: September 24, 2013, 02:30:25 PM »
C3D2012 needs the version number passed with the AeccPipeApplication

sAppName = "AeccXUiPipe.AeccPipeApplication.9.0"

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: VBA - Civil3D 2012
« Reply #2 on: September 24, 2013, 02:47:27 PM »
Jeff.
To be honest with you, I saw most of your post about this... I am really really thankful for your feed back. All Works as Expected.
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: VBA - Civil3D 2012
« Reply #3 on: September 24, 2013, 03:30:28 PM »
Another fun question!

I have code that looks like the following:

 Dim oExcelBook As Excel.Workbook
   
    Dim dataNWPipeName As String
   
    StartExcel

    fileHHCalcs = "C:\P2X\storm.xls"
   
    Set oExcelBook = g_oExcelApp.Workbooks.Open(fileHHCalcs) 'g_oExcelApp.Workbooks.Add
    If oExcelBook Is Nothing Then
        MsgBox "Error creating Excel document, exit."
        Exit Sub
    End If
    ' dictionary objects to hold column names and positions
    Set dictPipe = New Dictionary
    Set dictStructure = New Dictionary
    'make a new sheet for structures

How can I specify what excel file to use rather than hard coding it?
Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: VBA - Civil3D 2012
« Reply #4 on: September 24, 2013, 03:46:22 PM »
You can ask the user for a string for the path, but that would mean they'd need to type it in. Or, better, use the OpenSave Class dialog to get the fie name & path. I've attached the Class code, here's a quick display of how to use it:

    Dim cOpenSave As New OpenSaveClass

    cOpenSave.MultiSelect = True
    cOpenSave.Filter = "Text files (*.txt)|*.txt"
    cOpenSave.Title = "Select File to Open"
    cOpenSave.InitialDir = survPath
   
    strFile = cOpenSave.ShowOpen
    If strFile <> "" Then

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: VBA - Civil3D 2012
« Reply #5 on: September 24, 2013, 04:31:25 PM »
Can you check your pm please?
Civil3D 2020