Hi everybody! I am learning objectarx now (2011 version) and I want to create my custom object with some custom properties (which can be edited throug com, for example with VBA). There is a good example in SDK called square wrapper. Everything is ok with it, I have added some extra functionality to square and It works fine, but the question is: how to implement add function , which will be adding my custom entity to autocad drawing. The function should be the same as AddCircle or AddLine. Any suggestions?
You can implement a COM class for your application, then add a AddMyEntity method on an interface exposed by that class. The main point is that you have to implement it yourself; AutoCAD has no way of doing it for you.
Sorry, I guess I don't understand the problem. If you already have an entity, and you're writing a function on the entity's COM wrapper class to add the existing entity to a database, then you need some way to specify where to add it, either as an argument to the function or some other way. I would probably use a single argument to specify the block table record to add the entity to.
I meant my function don't work. Here is the code:
STDMETHODIMP CMyClass::AddFunction (DOUBLE val, LONG node, SHORT type)
// TODO: Add your implementation code here
HRESULT hr = S_OK;
hr = pSquare.CoCreateInstance(CLSID_AsdkSquareWrapper);
pSquareBase = pSquare;
hr = pSquareBase->CreateObject();
// Set the square object up for OPM
AcAxPoint3d pnt3d(0, 0, 0);
hr = pSquareBase->AddToDb(squareId, curDoc()->database()->currentSpaceId());
The problem is in the curdoc(). It doesn't know what is the current document. I hope you will understand me =)
You can use acdbHostApplicationServices()->workingDatabase() to get the working database, but your code must handle the case when this function returns NULL.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.