ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use acdbGetObjectMesh() method to tessellate an AcDb3dSolid object?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Jeffrey.Tian
1022 Views, 4 Replies

How to use acdbGetObjectMesh() method to tessellate an AcDb3dSolid object?

I got a problem when trying to triangulating a 3D solid entity.

 

To triangulate the 3D entity, I used the acdbGetObjectMesh() metho from RealDWG lib 2013. Here is the document on this method: http://docs.autodesk.com/ACDMAC/2011/ENU/ObjectARX%20Reference/index.html?frmname=topic&frmfile=acdb...

 

I also found two examples using this method:

http://adndevblog.typepad.com/autocad/2012/05/define-holes-with-acddsubdmeshsetsubdmesh-the-same-way...

http://forums.autodesk.com/t5/objectarx/how-to-facet-acdbsubdmesh-objects/td-p/3438699

 

Below is my code:

 

jobject create3dSolid(JNIEnv* env, jobject& tempRecord, AcDbEntity *pEntity)
{
       AcDbFaceterSettings faceter;
       AcGePoint3dArray vertexArray;
       AcArray<Adesk::Int32> faceArray;
       AcGiFaceData* faceData;
       //pEntity is pointing to an AcDb3dSolid object.
       Acad::ErrorStatus es = acdbGetObjectMesh(pEntity, &faceter, vertexArray, faceArray, faceData);
      
       if (es == Acad::eOk)
       {
              cerr << "OK.\n";
              cerr << vertexArray.length() << endl;
              cerr << faceArray.length() << endl;
       }
 
       if (faceData)
       {
              cerr << "faceData is not NULL. \n";
       }
 
       cerr << "Just before return \n";
       return NULL;
}

 

 

 

Below is console output  when above code is run:

 

8
30
Just before return

 

 

The code crashes just after outputting “Just before return”. According to my debugging, it crashes when faceArray is being destroyed.

 

Visual Studio 2010 also pops up dialogs including messages as below:

 

Expressio: _CrtlsValidHeapPointer(pUserData)
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
HEAP CORRUPTION DETECTED: before Free block(#771469516) at ...
HEAP CORRUPTION DETECTED: after Free block(#771469516) at ...

 

 

I've spent a couple of days on this problem. Could you give me some ideas on fixing it?

 

Thanks,

 

Jeffrey

 

4 REPLIES 4
Message 2 of 5
owenwengerd
in reply to: Jeffrey.Tian

You need to initialize faceter and you should initialize faceData to NULL before calling the acdbGetObjectMesh() function.

--
Owen Wengerd
ManuSoft
Message 3 of 5
Jeffrey.Tian
in reply to: owenwengerd

Thank you.

 

One of my coworkers told me the same way as you suggested, but it didn't work. 

 

I initialized faceter and faceData as below and I got the similar issue:

 

AcDbFaceterSettings faceter = {0.001, 0.001, 10, 1000, 1000, 3, 3, 2};
AcGePoint3dArray vertexArray;
AcArray<Adesk::Int32> faceArray;
AcGiFaceData* faceData = NULL;
Acad::ErrorStatus es = acdbGetObjectMesh(pEntity, &faceter, vertexArray, faceArray, faceData);

 

Message 4 of 5
owenwengerd
in reply to: Jeffrey.Tian

You'll need to provide sample code to reproduce the problem, as this code works fine for me in AutoCAD 2015.

--
Owen Wengerd
ManuSoft
Message 5 of 5
Jeffrey.Tian
in reply to: Jeffrey.Tian

I just solved the probem.

 

My project is a DLL project and the DLL file is called by a Java application.

 

This moring, I happend to find this article : http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CPP/Q_21804947.html

It says MSVCRT.lib should be added to linker because DLL is mixed-mode.

I followed its instruction and fixed the problem.

 

What I did is: In the Property Pages dialog box, click Linker, click Input., and then add msvcrt.lib to the Additional Dependencies property.

 

 

Jeffrey

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost