Hello All,
I had a topic in the ObjectArx forum which is similar to this, but was directed here to perhaps get more replies.
I have several years experience with C++, so I would like to develop with reasonably pure C++ if possible. So I chose Unmanaged C++ .NET as my platform, although Managed C++ might be alright if it is not too different. I would rather not learn a new language like C# if I can help it.
There doesn't seem like a lot of C++ examples on the internet (not that I have managed tro find anyway). If anyone has links to more C++ examples (in addition to the samples) that would be awesome. I already have the Developers Manual & the API reference.
What I am actually trying to do:
I have a design surface, a surface which I surveyed, and a TIN Volume surface as a comparison between the two. Am trying to place surface elevations on the comparison surface at the location of each point in the surveyed surface (I have a Point Group for it). So my dwg will show cut / fill values.
My request:
Could I indulge someone to post the code for something simple like printing out the names of each surface in the dwg. It is mainly the setup of a custom class along with all the required namespaces, initialisation etc, that I am interested in. That is, a very simple but complete set of code. Meanwhile, I will have a go at porting some C# code to C++ - which could be tricky because I don't know much about C#.
Questions:
1. When one makes a .dll with a custom class, then loads it in C3D: How does C3D know which function to run? Does one call a function from a constructor?
Thanks in advance for any help - Cheers
Hello All,
So I spent the whole day trying to port C# code to Managed C++, but am stuck trying to do a Transaction. Here is the code:
Conformance.cpp
// This is the main DLL file. #include "stdafx.h" #include "Conformance.h" using namespace Autodesk::Civil::ApplicationServices; using namespace Autodesk::Civil::DatabaseServices; typedef Autodesk::Civil::DatabaseServices::Surface CivSurface; //typedef Application::DocumentManager::MdiActiveDocument doc; typedef namespace Conformance { void CSurfaceElevation::MyFunc() { Transaction ts = CivilApplication::ActiveDocument::Database::TransactionManager.StartTransaction()) ; try { CivilDocument ^ActiveDoc = CivilApplication::ActiveDocument; // Get the first surface in a document // "doc" is the CivilApplication.ActiveDocument ObjectId ^surfaceId = ActiveDoc->GetSurfaceIds()[0]; CivSurface ^oSurface = surfaceId->GetObject(OpenMode.ForRead) //as CivSurface; // print out general properties: GeneralSurfaceProperties ^genProps = oSurface->GetGeneralProperties(); String propsMsg = "\nGeneral Properties for " + oSurface->Name; propsMsg += "\n-------------------"; propsMsg += "\nMin X: " + genProps->MinimumCoordinateX; propsMsg += "\nMin Y: " + genProps->MinimumCoordinateY; propsMsg += "\nMin Z: " + genProps->MinimumElevation; propsMsg += "\nMax X: " + genProps->MaximumCoordinateX; propsMsg += "\nMax Y: " + genProps->MaximumCoordinateY; propsMsg += "\nMax Z: " + genProps->MaximumElevation; propsMsg += "\nMean Elevation: " + genProps->MeanElevation; propsMsg += "\nNumber of Points: " + genProps->NumberOfPoints; propsMsg += "\n--"; editor.WriteMessage(propsMsg); } catch (System.Exception e) { editor.WriteMessage(e.Message); } ts.Commit } void CSurfaceElevation::Initialize() { throw gcnew System::Exception("The method or operation is not implemented."); } void CSurfaceElevation::Terminate() { throw gcnew System::Exception("The method or operation is not implemented."); } } // end of namespace Conformance
Conformance.h
// Conformance.h #pragma once using namespace System; using namespace Autodesk::AutoCAD::Runtime; using namespace Autodesk::Civil::ApplicationServices; namespace Conformance { public ref class CSurfaceElevation : IExtensionApplication { // TODO: Add your methods for this class here. // #pragma region IExtensionApplication Members public: void MyFunc(); virtual void Initialize(); virtual void Terminate(); //#pragma endregion }; } // end of namespace Conformance
So I guess one might be able to see my lack of knowledge on how to do this properly. I would really appreciate it if someone could post a small & simple but complete set of code to start me off.
I am also trying some ObjectARX, but having some problems there too.
Cheers.
Thanks in advance.
Hi,
Did you look into this sample -
C:\Program Files\Autodesk\Autodesk AutoCAD Civil 3D 2014\Sample\Civil 3D API\COM\VC++\Managed C++
Does it help ?
Thanks,
Partha Sarkar