ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting started with ObjectARX & Civil3D 2014

12 REPLIES 12
Reply
Message 1 of 13
TheDabbler
875 Views, 12 Replies

Getting started with ObjectARX & Civil3D 2014

Hello all,

 

I am not sure whether I have eveerything on the Civil3D side installed, although I managed to find separately the reference manual with all the Civil3D classes etc. Maybe it is there, but I am not aware of how to access it all.

 

I have installed Vistual Studio C++ Express 2010, VB Express 2010, and of course ObjectARX.

 

Also having trouble trying to track down the ARX Wizards for setup, although I am persevering with the instructions in the ARX manual.

 

Maybe someone could provide some links to all this info - that would great.

 

What I really want to do: Place surface elevations on each of the points in a point group. I have a design surface, an asbuilt surface which I surveyed, and a TIN volume surface which is a comparison between the two. I would like the surface elevations to show the cut / fill of the comparison between my survey & the design, with the surface elevations on the Tin Volume surface, but at each point in the survey.

 

Maybe things would be easier using VB to start with. Even though I have VB Express 2010 installed, Civil3D won't let me do VB macros when I select that option from the ribbon. I just comes up with the message that VB is no longer distributed with C3D.

 

Thanks in advance for any help available  - regards

12 REPLIES 12
Message 2 of 13
owenwengerd
in reply to: TheDabbler

A good place to start is http://www.objectarx.com. If you're not an experienced C++ programmer, I recommend you start with VBA or .NET. Links to the VBA enabler are shown on the linked web site.

--
Owen Wengerd
ManuSoft
Message 3 of 13
TheDabbler
in reply to: owenwengerd

Hi Owen,
Thanks for your prompt reply. I have read through all the ARX documentation, but still don't see any thing related to Civil3D. At the start it says that can be used for any of the AutoCad based products including C3D, but it doesn't seem to elaborate on how to access it's classes etc. I have several years experience with C++, so I would prefer to use that if possible, but could use .NET or VBA if I had to. Is it possible to use C++ to program Civil3D? Thanks again for your knowledge & time.
Message 4 of 13
owenwengerd
in reply to: TheDabbler

Sorry, I'm not familiar with the C3D API. For C3D specific questions, you'll be best served to post in a C3D discussion forum.

--
Owen Wengerd
ManuSoft
Message 5 of 13
ow
Contributor
in reply to: TheDabbler

Hi!

 

The Civil3d API's are included with the Civil3d application. For ObjectARX C++ applications, there is a COM API you can use (See the samples), but I really recommend using the managed C# API as it is easier to use and generate faster and cleaner code too. Also it's more future proof as the COM API is more or less deprecated.

 

C:\Program Files\Autodesk\Autodesk AutoCAD Civil 3D 2014\Sample\Civil 3D API\DotNet\CSharp

C:\Program Files\Autodesk\Autodesk AutoCAD Civil 3D 2014\Sample\Civil 3D API\COM\VC++

 

http://docs.autodesk.com/CIV3D/2014/ENU/API_Reference_Guide/

 

 

 

Message 6 of 13
TheDabbler
in reply to: TheDabbler

@Owen 

 

Ok, no worries - I will try there, thanks 8+)

 

@ow

 

Thanks for your helpful reply :+)

 

OK, I had a look at the samples, but I still don't see where the include files for all the C3D classes are.

 

I guess that .NET C++ either managed or unmanaged would be good for me, seen as I have experience with C++. I would like to avoid (if possible) any intricacies with languages I am not really familar with.

 

I think I really am missing something major here. :+|

Message 7 of 13
ow
Contributor
in reply to: TheDabbler

Hi!

There are no native C++ classes like we have in the ObjectARX AutoCAD API , so in C++ you need to import the tlb's like this:

 

#import "C:\Program Files\Common Files\Autodesk Shared\AecXBase75.tlb" raw_interfaces_only named_guids no_namespace
#import "C:\Program Files\Common Files\Autodesk Shared\AecXUIBase75.tlb" raw_interfaces_only named_guids no_namespace
#import "C:\Program Files\Common Files\Autodesk Shared\Civil Engineering 103\AeccXLand.tlb" raw_interfaces_only named_guids no_namespace exclude("tagDOMNodeType", "IXMLDOMImplementation", "IXMLDOMParseError", "IXMLDOMNode", "IXMLDOMNodeList", "IXMLDOMNamedNodeMap", "IXMLDOMDocumentType", "IXMLDOMDocumentFragment", "IXMLDOMCharacterData", "IXMLDOMText", "IXMLDOMComment", "IXMLDOMCDATASection", "IXMLDOMProcessingInstruction", "IXMLDOMAttribute", "IXMLDOMElement", "IXMLDOMEntityReference", "IXMLDOMDocument")
#import "C:\Program Files\Common Files\Autodesk Shared\Civil Engineering 103\AeccXUiLand.tlb" raw_interfaces_only named_guids no_namespace exclude("UINT_PTR")
#import "C:\Program Files\Common Files\Autodesk Shared\Civil Engineering 103\AeccXPipe.tlb" raw_interfaces_only named_guids no_namespace exclude("UINT_PTR", "AeccLabelDimensionAnchorType")
#import "C:\Program Files\Common Files\Autodesk Shared\Civil Engineering 103\AeccXUiPipe.tlb" raw_interfaces_only named_guids no_namespace exclude("UINT_PTR")
#import "C:\Program Files\Common Files\Autodesk Shared\Civil Engineering 103\AeccXUiRoadway.tlb" raw_interfaces_only named_guids no_namespace exclude("UINT_PTR")
#import "C:\Program Files\Common Files\Autodesk Shared\Civil Engineering 103\AeccXRoadway.tlb" raw_interfaces_only named_guids no_namespace exclude("UINT_PTR")

 

And use the COM pointers to access the Civil3d model like this:

 

CComQIPtr<IAcadApplication> pAcadApp(acedGetAcadWinApp()->GetIDispatch(TRUE));

CComQIPtr<IDispatch> pDisp;
HRESULT hr = pAcadApp->GetInterfaceObject(XUILAND_APP, &pDisp);
if(SUCCEEDED(hr))
{
CComQIPtr<IAeccApplication> pAeccApp;
hr = pDisp->QueryInterface(__uuidof(IAeccApplication), (LPVOID*)&pAeccApp);
if(SUCCEEDED(hr))
{
hr = pAeccApp->Init(pAcadApp);
if(SUCCEEDED(hr))
{
CComQIPtr<IAcadDocument> pDoc;
hr = pAeccApp->get_ActiveDocument(&pDoc);
if(SUCCEEDED(hr))
{
hr = pDoc->QueryInterface(__uuidof(IAeccDocument), (void**)&pAeccDoc);
if(SUCCEEDED(hr))
{
CComQIPtr<IAcadDatabase> pAcadDb;
hr = pAeccDoc->get_Database(&pAcadDb);
if(SUCCEEDED(hr))
{
hr = pAcadDb->QueryInterface(__uuidof(IAeccDatabase),(void**)&pAeccDb);

//etc.
}
}
}
}
}
}

 

 

 

 

-With .NET you have managed classes which can be accessed by referencing the dll's AecBase.dll, AeccDbMgd.dll along with the AutoCAD .NET dll's. -It's much easier to work with. 

 

 

Message 8 of 13
TheDabbler
in reply to: ow

@ow,

 

Wow, thanks for your reply.

 

> There are no native C++ classes like we have in the ObjectARX AutoCAD API

 

Crikey, I have spent quite a bit of time in the Linux world the last few years, so I am not used to not seeing files :+)

 

Your code doesn't seem that tricky - Although I would have never worked that out myself anytime soon!! I mean once one has all those pointers then hopefully it is not too bad after that. I am guessing that I put  your code that assigns the pointers into the implementation file of my own custom class, so that the pointers are acessible elsewhere? I will make the pointers member variables. And the #import code I will put in a header file.

 

Managed C++ .NET might be the way to go for me, so I will have a go at installing that also, if persevering with straight C++ turns out to be too hard. Will have to have a think about that.

 

Any way it's getting late at this end, have to sort out concreter's & graders tomorrow (I am an Engineering Surveyor). Hopefully I will have a decent amount of time to play on Sunday. I probably won't reply to anyone until about 24 hrs time.

 

Regards

Message 9 of 13
veli_vaisanen
in reply to: TheDabbler

Hi,

there is a few thing about developing upon Civil 3D 2015.

Civil 3D 2015 Dev Help

 

C++ is not an easiest platform to code upon Civil 3D. I recommend .NET platform.

Cheers

Veli V.

Message 10 of 13
TheDabbler
in reply to: veli_vaisanen

@veli

 

Thanks for your reply.

 

So I have decide to go with .NET C++ unmanaged code, because I would like to do reasonably pure C++, because that is what I know.

 

@e veryone

 

Thanks for all of your help, I will mark this as solved, but ask a question in the Civil3D forum instead, perhaps if you wish to help me further you could reply there?

 

Cheers.

Message 11 of 13
TheDabbler
in reply to: TheDabbler

Hello All,

 

So I spent all day trying to port C# code to C++, but no luck. I have a post with all the gory details on the Civil3D Customisation page.

 

Now I am trying the simple code shown in the ARX guide, but am having trouble with the acutPrintf function, it shows this error:

 

1>------ Build started: Project: ConformARX, Configuration: Debug Win32 ------
1>  ConformARX.cpp
1>ConformARX.cpp(25): error C2664: 'acutPrintf' : cannot convert parameter 1 from 'const char [28]' to 'const ACHAR *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>ConformARX.cpp(28): error C2664: 'acutPrintf' : cannot convert parameter 1 from 'const char [30]' to 'const ACHAR *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

#include "rxregsvc.h"
#include "acutads.h"

#include "stdafx.h"  
// Simple acrxEntryPoint code. Normally intialization and cleanup
// (such as registering and removing commands) should be done here.
//
extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)
{
    switch(msg) {
    case AcRx::kInitAppMsg:
        // Allow application to be unloaded
        // Without this statement, AutoCAD will
        // not allow the application to be unloaded
        // except on AutoCAD exit.
        //
        acrxUnlockApplication(appId);
        // Register application as MDI aware. 
        // Without this statement, AutoCAD will
        // switch to SDI mode when loading the
        // application.
        //
        acrxRegisterAppMDIAware(appId);
        acutPrintf("\nExample Application Loaded");
    break;
    case AcRx::kUnloadAppMsg:
        acutPrintf("\nExample Application Unloaded");
    break;
    }
    return AcRx::kRetOK;
}

Wondering why it won't work with a string literal?

 

I found some code that had :

 

acutPrintf(_T"\nExample Application Unloaded");
//or this

 

acutPrintf(L"\nExample Application Unloaded");
acutPrintf(ARX_T"\nExample Application Unloaded");

But none of these worked.

 

Maybe I created the application wrongly in VS2010 Express: I made a CLR class library so I would get a .dll file. Maybe I should have started with an empty project?

 

Also had trouble with ARX wizards - the project creation failed. I tried the workaround Here,

but still no good.

 

Any help will be much appreciated

 

Regards.

 

 
 
Message 12 of 13
owenwengerd
in reply to: TheDabbler

The fact you're getting tripped up by simple things like wide character literal strings in C++ serves to amplify the advice you've been given to stick with C#.

--
Owen Wengerd
ManuSoft
Message 13 of 13
maisoui
in reply to: owenwengerd

Hi,

 

It's not:

_T"my text")
...

But:

_T("my text")
...

 

--
Jonathan

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost