Get civil objects function civil 3d 2015

Get civil objects function civil 3d 2015

jcoon
Enthusiast Enthusiast
3,355 Views
20 Replies
Message 1 of 21

Get civil objects function civil 3d 2015

jcoon
Enthusiast
Enthusiast

All,

 

Because I just installed civil 3d 2015 with the VBA 7.1 enabler installed I thought I’d use a few routines I had made several years ago in VBA to speed up the drawing creation when I found out the get civil objects function fails at 10.4. I read in the reference library was for civil 3d 2015 was 10.4.

 

Is there a newer a newer way to retrieve the civil objects ?

 

I connected the Autodesk Civil Engineering 10.4 UI Land Object library

And the Autodesk Civil Engineering 10.4 Land Object library as weel as the Autocad 2015 type library

I thought this would be all I needed to use a trusted routine I had used for years in many versions of civil 3D.

 

Thanks you,

 

John

 

This is the old function I’ve used for years:

 

Function GetBaseCivilObjects() As Boolean

   Dim oApp As AcadApplication

   Set oApp = ThisDrawing.Application

   ' NOTE - Always specify the version number.

   Const sAppName = "AeccXUiLand.AeccApplication.10.4"

   Set g_oCivilApp = oApp.GetInterfaceObject(sAppName)

   If (g_oCivilApp Is Nothing) Then

       MsgBox "Error creating " & sAppName & ", exit."

       GetBaseCivilObjects = False

       Exit Function

   End If

   Set g_oDocument = g_oCivilApp.ActiveDocument

   Set g_oAeccDatabase = g_oDocument.Database

   GetBaseCivilObjects = True

End Function

0 Likes
3,356 Views
20 Replies
Replies (20)
Message 2 of 21

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

"AeccXUiLand.AeccApplication.10.4" is the correct ProgID parameter for GetInterfaceObject.

 

>> Is there a newer a newer way to retrieve the civil objects ?

As long as you use VBA it's the current method/API, if you want to change to C# or VB.NET you have a bit more options.

 

Just to remember: there is a special forum for Civil 3D customization >>>there<<<.

 

HTH, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 21

jcoon
Enthusiast
Enthusiast

Alfred,

 

Even with the function I attached and with "AeccXUiLand.AeccApplication.10.4" library attached I still seem to get and error

on programs that I 've run for years without issue.

 

These were VBA routines I didn't convert to dot net. I thought with 2015 and the new VBA 7.1 enablier I might be able to use some old rouutine to help finish a project.

 

I guess I keep looking. It's not a big issue as I have not used these routines in some time, as I said I thought I just need to change the function library numbers and i would be go to go.

 

Thanks for the help and confirming I had the correct library.

 

John

0 Likes
Message 4 of 21

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

if you want to continue...

 

>> I still seem to get and error

Which error message/number do you get (at what code-line)?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 21

jcoon
Enthusiast
Enthusiast

Alfred,

 

I spent a good bit of time over the weekend looking for anything in civil 3D Dev. guide on VBA  settings to connect to the civil object.

attached are the library connections I was using and the function is the same as posted.

 

what about something that reads the surfaces in a dwg.  As I said, It would be nice to be able to use some older VBA routines that I didn't convert to dot net. Maybe I should find the time to convert them or see if it's easier to connect with lisp for older routines.

 

'get surface names

 

If (GetBaseCivilObjects() = False) Then

        Exit Sub

    End If

Dim surfaceName As String

Dim oAcadObject As AcadObject

Dim osurf As AeccSurface

 

 

For Each oAcadObject In ThisDrawing.ModelSpace

If (TypeOf oAcadObject Is AeccSurface) Then

Set osurf = oAcadObject

 

surfaceName = osurf.name

 

End If

Next

'print to command line

 

Function GetBaseCivilObjects() As Boolean

   Dim oApp As AcadApplication

   Set oApp = ThisDrawing.Application

   ' NOTE - Always specify the version number.

   Const sAppName = "AeccXUiLand.AeccApplication.10.4"

   Set g_oCivilApp = oApp.GetInterfaceObject(sAppName)

   If (g_oCivilApp Is Nothing) Then

       MsgBox "Error creating " & sAppName & ", exit."

       GetBaseCivilObjects = False

       Exit Function

   End If

   Set g_oDocument = g_oCivilApp.ActiveDocument

   Set g_oAeccDatabase = g_oDocument.Database

   GetBaseCivilObjects = True

End Function

 

0 Likes
Message 6 of 21

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

I'm not sure to see a question in your post. ... or if your code fails then where does it fail and what error message you get.

 

>> what about something that reads the surfaces in a dwg. 

>> As I said, It would be nice to be able to use some older VBA routines

You can use the older routines, just change the ProgID to the current version of Civil 3D and all should run well.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 7 of 21

Dylandavid
Participant
Participant

NEED A DIFFERENT LIBRARY? When I load a sample .DVB it tries to reference: Autodesk Civil Engineering 8.0 [land, survey, ui land, ui survey]

I beleive that's the problem but I'm not sure. I think they've depricated help for this so I don't know how to find out

 

My vanilla AutoCAD 2015 macros still work swimmingly

See image below, notice path in vba ui caption

civil engineering 8.jpg

0 Likes
Message 8 of 21

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> When I load a sample .DVB it tries to reference

Yep, not all samples are updated to fit the current Civil 3D release, so it might be necessary to update the references.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 9 of 21

jcoon
Enthusiast
Enthusiast

Dylanddavid,

 

That sounds like what I was getting as well. All the Autocad only dvb worked fine. The civil 3d objects even with the updated link to library AeccXUiLand.AeccApplication.10.4 I could not get to work. I tought it was something I was doing wrong so I even went into the C3D tutoral samples provided with the software and all the Civil ones have been removed. I guess the VBA only works with vanilla autocad.

 

John 

0 Likes
Message 10 of 21

jcoon
Enthusiast
Enthusiast

Alfred

 

Please see that I have the new library selected from vba 7

 

I think I have everything set correctly.

 

John

0 Likes
Message 11 of 21

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

let's exchange DVB files, because screenshots can't be tried 😉

I have attached a DVB that is working for me on Civil 3D 2015, SP2, German on Windows 8.1 Prof. 64bit.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 12 of 21

norman.yuan
Mentor
Mentor

Just to back up Alfred's case, with my newly installed Civil 3D 2015 SP2 with Win 7 64-bit Enterprise, the folloing simple code works (that is, the VBA code has no issue creating AeccApplication object (with reference set to "Autodesk,Civil Engineering 10.4 UI Land Object Library"):

 

Option Explicit

Public Sub CivilTest()

    Dim cadApp As AcadApplication
    Dim civilApp As AeccApplication
   
    Set cadApp = ThisDrawing.Application
    Set civilApp = cadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.10.4")
    MsgBox civilApp.ActiveDocument.FullName

End Sub

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 13 of 21

jcoon
Enthusiast
Enthusiast

Norman.yuan,

 

 

Wouldn't you know it,  I didn't bring my lap[top in today becuase I had a project going out today. maybe I can get it during lunch otherwise I'll have to check tonight.

 

Thanks guys for looking into this. you guys are the best!

 

John

 

 

 

 

0 Likes
Message 14 of 21

jcoon
Enthusiast
Enthusiast

Alfred, Norman.yuan

 

Well it looks like it might be my machine. It's only a month old..... I have 2015 civil 3d installed with sp1 & 2 installed and I get the same error as before.

I tried both vba routines you posted. no joy

 

I guess this means that I'm going to select the old vba appys that I liked and convert them to dot net.

 

my machine is

 

win 8.1 with AMD a10-5745m apu

 

error was -2147221005(80041f3)   ..... problem in loading application

if anyone knows where or what to lok for

 

 

Thank you for all your help with this. I'll contine to keep looking for a solution. The good side is that the AUTOCAD ONLY apps still work.

 

Thank you

 

John

0 Likes
Message 15 of 21

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

you might try:

run a repair installation of your Civil 3D (antivirus off, internet off, as admin)

start Excel, within that VBA and just try to activate the reference to the C3D lib's, that might do some registration if missing.

 

Good luck, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 16 of 21

jcoon
Enthusiast
Enthusiast

Alfred,

 

Sounds like a plan for lunch. Thanks for the idea

 

John

0 Likes
Message 17 of 21

Dylandavid
Participant
Participant

MY USER ERROR

Your dvb worked for me. I didn't have the .application set up. Thanks for the example file

0 Likes
Message 18 of 21

Anonymous
Not applicable

Hello, my name is David and I have recently installed Autocad Civil 3D 2015 and VBA Enabler 7.1 for it to run old VBA Routines that are currently working in 2013 version with the VBA enabler 6.3 for 2013. Everything is installed and when I run the routine it goes through the prompts but once get to certain part where makes custom layer gives me the below error then takes me to my .dvb file. Checked under the references in the VBA editor and 2015 content library is selected. Is there something else that needs to be done, wondering what the problem could be. Thank you for any help you can give.

 

ActiveX 2015 WPA error.JPG

0 Likes
Message 19 of 21

jcoon
Enthusiast
Enthusiast

UZA1717,

 

I followed everything from Alfred posts and still could not get mine to work. I used the samples Alfred and Norman.yuan posted and they just didn't work on my machine. I ended up rewriting them for dot net.

 

Sorry I couldn't help

 

John 

0 Likes
Message 20 of 21

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> Is there something else that needs to be done

We don't see your code, what's the code-lines that bring up that message?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes