setFromOldId cannot access private member declared in class 'AcDbObjectId'

setFromOldId cannot access private member declared in class 'AcDbObjectId'

chockalingam
Advocate Advocate
741 Views
3 Replies
Message 1 of 4

setFromOldId cannot access private member declared in class 'AcDbObjectId'

chockalingam
Advocate
Advocate

Hi,

 

I have a function as below, which is working fine when using with RealDWG 2010 32-bit reference.
Now i am migrating my project from RealDWG2010 to 2013 64-bit version, so i migrated from vs2008 to vs2010.
But when i am trying to build the solution, i am getting the following error in Line 6.
Can any one help me in solving this issue.

*********************************Error received**********************************


error C2248: 'AcDbObjectId::setFromOldId' : cannot access private member declared in class 'AcDbObjectId'

 

*********************************************************************************

**********************************Code  used************************************

int DWGMgr::GetInsertionPoint(long nObjectID, CNSPoint3D &pt)
{
    Acad::ErrorStatus es;
    AcDbObject *pEntity;
    AcDbObjectId pBlockObjID;
    pBlockObjID.setFromOldId(nObjectID);
    es = acdbOpenObject(pEntity, pBlockObjID, AcDb::kForRead);
    if(es != Acad::eOk)
        return NS_FAIL;
    if(!pEntity->isKindOf(AcDbBlockReference::desc()))
    {
        pEntity->close();
        return NS_FAIL;
    }
    AcDbBlockReference *pRef = (AcDbBlockReference*)pEntity;
    AcGePoint3d p3dPosition   = pRef->position();
    pt.m_dXX = p3dPosition.x;
    pt.m_dYY = p3dPosition.y;
    pt.m_dZZ = p3dPosition.z;

    pRef->close();
    pEntity->close();
    return NS_SUCCESS;
}

**********************************************************************************

 

 

Thanks in Advance.

 

 

Regards,

Chockalingam.

0 Likes
742 Views
3 Replies
Replies (3)
Message 2 of 4

owenwengerd
Advisor
Advisor

A long is not large enough to hold an AcDbObjectID on a 64-bit system. You'll need to change your code to use something that is large enough to hold a 64-bit pointer.

--
Owen Wengerd
ManuSoft
0 Likes
Message 3 of 4

Anonymous
Not applicable
Hi, Owen Wengerd

I am facing the same error when migrating 32bit source to 64bit.
If long is not enough to hold AcDbObjectID, then what should be used instead? Can you specify it in detail? An example would be great.
According to the error message, it seems more like a access permission issue to me? Because passing a parameter of long type would result in same error. ObjectARX SDK explicitly set the access permission to private for 64 bit environment. I don't know why, but what do you think?
Sorry for asking a lot and thanks in advanced.
I am new to C++, AutoCad & ObjectARX.
Thank you.
0 Likes
Message 4 of 4

artc2
Autodesk
Autodesk
Looking at the AcDbObjectId class declaration in dbid.h, I see that you can use this version of setFromOldId:

AcDbObjectId& setFromOldId(Adesk::IntDbId oldId);

for both 32-bit and 64-bit. so, you'd be using an Adesk::IntDbId instead of a long. Adesk::IntDbId is an Int32 on 32-bit and an Int64 on 64-bit (see the adesk.h header file for the typedefs).

Or, for 64-bit only you can use this one:

inline AcDbObjectId& setFromOldId(Adesk::UIntPtr nUnsignedId)

which is just an inline that calls the Adesk::IntDbId version.