TheSwamp

Code Red => VB(A) => Topic started by: MSTG007 on September 24, 2013, 01:51:02 PM

Title: VBA - Civil3D 2012
Post by: MSTG007 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!
Title: Re: VBA - Civil3D 2012
Post by: Jeff_M on September 24, 2013, 02:30:25 PM
C3D2012 needs the version number passed with the AeccPipeApplication

sAppName = "AeccXUiPipe.AeccPipeApplication.9.0"
Title: Re: VBA - Civil3D 2012
Post by: MSTG007 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.
Title: Re: VBA - Civil3D 2012
Post by: MSTG007 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?
Title: Re: VBA - Civil3D 2012
Post by: Jeff_M 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
Title: Re: VBA - Civil3D 2012
Post by: MSTG007 on September 24, 2013, 04:31:25 PM
Can you check your pm please?