How to create Custom Entity With its Name in Properties palette.

How to create Custom Entity With its Name in Properties palette.

nathan307
Enthusiast Enthusiast
1,806 Views
8 Replies
Message 1 of 9

How to create Custom Entity With its Name in Properties palette.

nathan307
Enthusiast
Enthusiast

Dear Friends,
        I Created custom entity and I want to add some properties, that will show in the property palette.(ie..)how to show name of custom entity in properties palette in ObjectArx.

Thanks...

0 Likes
1,807 Views
8 Replies
Replies (8)
Message 2 of 9

autodaug
Autodesk
Autodesk
0 Likes
Message 3 of 9

nathan307
Enthusiast
Enthusiast

Thanks For Your Help.I want to Add Properties to the Custom Entity,And Show the Name Of Entity As UserDefined like MyEntity in Properties Palette,Can You Give your Suggestion

0 Likes
Message 4 of 9

maisoui
Advocate
Advocate

Use one of the autodaug solutions. (COM solution) To define the name of the custom entity in the OPM, you need to implement GetDisplayName(DISPID, BSTR) and return a string value when DISPID is DISPID_DISPLAYNAME.

 

Regards,

--
Jonathan
0 Likes
Message 5 of 9

nathan307
Enthusiast
Enthusiast

Dear Friend..

Thanks For your Suggestion,I Implement com Wrapper and Also implement GetDisplayName(DISPID, BSTR)  but the Entity Name MyEntity is not shown in the property window...

  I am Exactly Want a Sample to create Custom Entity like Line, Circle,..etc,  I am able to set property for that Entity,also I want to Display its Name in the Property Palette as "My Entity"...Give A Sample or Give a detailed explain about this Problem...

0 Likes
Message 6 of 9

autodaug
Autodesk
Autodesk

The arx sdk's ComPoly sample shows how to do the COM wrapper - but you are probably already looking at that.

One thing to check is whether your object is properly registering itself with the COM runtime when it loads up. You could try making some COM calls on your object from a test app to see if they succeed as expected.

 

Here is another link about overriding DisplayName:

http://adndevblog.typepad.com/autocad/2013/01/changing-the-entity-type-name-that-appears-in-the-opm-...

 

Message 7 of 9

nathan307
Enthusiast
Enthusiast

Thanks for Your Help....

 

   How  to check is whether my object is properly registering itself with the COM runtime when it loads up. How to make some COM calls on my object from a test app to see if they succeed as expected.

 

 

   Thanks.........

0 Likes
Message 8 of 9

Anonymous
Not applicable

To check if it is properly registered: 

 

As part of creating your COM wrapper you should have generated a .rgs file. If you open that up, one of the very first lines (under HKCR) is the name of your object, something like 

 

ProjectName.ClassNameWrap.1

 

If you now open the registry editor (regedit.exe), select the HKEY_CLASSES_ROOT branch, then go to Edit - Find and paste that string in (including the .1 on the end), then if your class is properly registered it *should* find it against a ProgID branch under a GUID, something like this: 

 

reg-entry.png

 

(The GUID will obviously be the one that appears in your .rgs file, and the name of your class as you pasted it in will appear in the right half of RegEdit's window.) 

 

When you added your override of GetDisplayName(), did you add a specific case for the DISPID_xxx value suggested? Showing us a little snippet of your code where you return this string may help. 

 

Also, make sure your object class (not the wrapper class, the actual object class) overrides the relevant methods to provide the CLSID information - for example: 

 

Acad::ErrorStatus ClassName::subGetClassID(CLSID * pClsid) const

{
    CLSID clsid ; 

    if (SUCCEEDED(CLSIDFromProgID(L"ProjectName.ClassNameWrap", &clsid) ) )
    {
        *pClsid = clsid;
        return Acad::eOk;
    }

    return (__super::subGetClassID(pClsid) ); // Fall back on the default. 


}

 

(it is actually better to override initCLSID() and make the call to ClassFromProgID() there, and save it as a member variable; the above is for demo purposes only). 

 

0 Likes
Message 9 of 9

autodaug
Autodesk
Autodesk

Also, here is one way to get a pointer to the COM wrapper for your entity and call the method on it. It assumes that  you have a pointer to your entity (pEnt) opened for read, and that the COM wrapper object has already been created and attached to the entity (by OPM, e.g.):

 

#include "initguid.h"
#include "oleaprot.h"
#include "opmext.h"

    AcAxOleLinkManager *pOLM = AcAxGetOleLinkManager();
    IUnknown *pUnk = pOLM->GetIUnknown(pEnt);
    if (pUnk != nullptr) {
        IOPMPropertyExtension * pProp;
        if (SUCCEEDED(pUnk->QueryInterface(IID_IOPMPropertyExtension, (void **)&pProp))) {
            BSTR bstr;
            if (SUCCEEDED(pProp->GetDisplayName(0x401, &bstr)))
                ads_printf(L"name: %s\n", bstr);

 

0 Likes