How to get name of inherited class of selected entity

How to get name of inherited class of selected entity

majklha
Advocate Advocate
841 Views
7 Replies
Message 1 of 8

How to get name of inherited class of selected entity

majklha
Advocate
Advocate

If I select entity from DWG, by ssgeg function, I have a general entity pointer (AcDbEntity* pEntity). How I get a real class name of this netity (eg. AcDbLine or AcDbText, etc...). Like string.

pEntity->className() return "AcDbEntity"

pEntity->isA()->desc()->className() return some unsence ("AcRxObject").

I, of course, dont know, what type pEntity is. I cannot use AcDbLine::desc(pEntity).....

 

Thanks.

0 Likes
Accepted solutions (1)
842 Views
7 Replies
Replies (7)
Message 2 of 8

daniel_cadext
Advisor
Advisor
Accepted solution
    static auto entsel()
    {
        AcGePoint3d pnt;
        ads_name name = { 0L };
        int res = acedEntSel(L"\nSelect it: ", name, asDblArray(pnt));
        AcDbObjectId id;
        if(auto es = acdbGetObjectId(id, name); es != eOk)
            return std::make_tuple(Acad::PromptStatus::eError, id, pnt);
        return std::make_tuple(Acad::PromptStatus(res), id, pnt);
    }

    static void AcRxMyApp_idoit(void)
    {
        auto [es, id, pnt] = entsel();
        if (es == Acad::PromptStatus::eNormal)
        {
            AcDbEntityPointer pEnt(id);
            acutPrintf(pEnt->isA()->name());
        }
    }

 

name.png

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 3 of 8

majklha
Advocate
Advocate

easy reply is:

pEntity->isA()->name();

0 Likes
Message 4 of 8

daniel_cadext
Advisor
Advisor

easy reply is: thank you : )

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 5 of 8

majklha
Advocate
Advocate

Of course, thank you. I forgot...

Sorry, it shouldn't be any irony. Your answer has been very helpful. 

I wrote "easy answer" for others. 🙂

Message 6 of 8

1127204185
Advocate
Advocate
Hello! The result is AcDbLine or AcDbText. Can I get Line or Text? A zero value similar to DXF。thank you!
0 Likes
Message 7 of 8

daniel_cadext
Advisor
Advisor

 

This should return the dxf name

pEnt->isA()->dxfName()

 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 8 of 8

1127204185
Advocate
Advocate
thank you!