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

Accessing point cloud entity loaded from a .pcg file

23 REPLIES 23
Reply
Message 1 of 24
xeri0n
1241 Views, 23 Replies

Accessing point cloud entity loaded from a .pcg file

Hello,

 

I had a look at the objectArx header files and I saw that there is a AcPointCloud.h file hinting at some Point cloud processing functions. 

What I want to do is obtain the point cloud points for specific extents. In essence the points that are located in a bounding box. The function to do that is acdbProcessPointCloudData which requires 4 parameters.

 

One of the input parameters is the point cloud of course. Is there a way to get the AcDbEntity of the .pcg loaded file, if we assume its only one for simplicity, so I can work with it ?

 

In AcDbPointcloud.h it is stated that it is the Api for AcDbPointCloud, however I see no class for AcDbPointCloud. Am I missing something ?

 

Thanks in advance! 

23 REPLIES 23
Message 21 of 24
xeri0n
in reply to: owenwengerd

I was looking into the class Dictionary since you proposed it. 

Certainly I can obtain an AcRxClass so I wanted to ask 2 things if they are possible.

 

In the case that I have various point clouds in my dwg file how can I get a pointer to each them. I tried iterating through the class dictionary but I am definitely doing something wrong since the ->name() calls are nothing I was expecting to see. So the second question is can i actually get an AcDbEntity* out of the the AcRxClass or acRXObject or I do have to iterate through the block table record?

 

for (; !pDictItr->done(); pDictItr->next())
{
    AcRxClass* pRxClass = pDictItr->isA();
    AcRxObject* pRxObject = pDictItr->object();
}

 

 

Cheers ! 

 

 

Message 22 of 24
kubitTilo
in reply to: xeri0n

Why not iterating the BlockTable? The performance overhead should be relatively small compared with what you will probably do with the point clouds...

 

In case you need all the point clouds from MODEL_SPACE it's easy like that: 

 

void iteratePointCloudsInModelSpace()
{
	static const AcString className(L"AcDbPointCloud");
	AcDbBlockTableRecordPointer pBlockRec(ACDB_MODEL_SPACE,acdbHostApplicationServices()->workingDatabase(),AcDb::kForRead);
	if (Acad::eOk == pBlockRec.openStatus()) 
	{
		AcDbBlockTableRecordIterator* it = NULL;
		if (Acad::eOk == pBlockRec->newIterator(it)) 
		{
			it->start();
			while(!it->done())
			{
				AcDbObjectId entId;
				it->getEntityId(entId);
				// open for read should be sufficient in case you like to process point clouds
				AcDbEntityPointer pEnt(entId,AcDb::kForRead);
				if (Acad::eOk == pEnt.openStatus())
				{
					if(AcString(pEnt->isA()->name())==className)
					{
						// here you go with your point cloud entity
					}
				}
				it->step();
			}
		}
		delete it;
	}
}

 Sorry for the bad formatting...




Tilo Pfliegner
Message 23 of 24
XXFW_AUTOCAD
in reply to: kubitTilo

I am using the ObjectARX 2013 to import the point cloud data into AutoCAD 2013.
I have successfully indexed the .las file into .pcg file using funtion acpcIndexPointCloud() ;
 
Then I tried to create an entity with the generated .pcg file using function acdbCreatePointCloudEntity();
but it always return error value: eCantOpenFile. 
The same thing also happened when using function acdbAttachPointCloudEntity();
 
And the PCG file is correct since I successfully attached the some file into AutoCAD with command Insert=>PointCloud=>Attach.
 
Why that error happened? What is the correct way to attach the point cloud?
 
I have read your questions and replies, it seems that the only way to access the point cloud entity is to iterate the  
AcRxtime to compare the name of entity?
 
Your response will be appreciated, thank you!
 
The source code are listed as below:
nRet = acpcIndexPointCloud(arrInputFiles, strIndexFilePathOut, NULL, false);
 
if(nRet != Acad::eOk){
acutPrintf(_T("\nFailed to index the point cloud, \
  please check if pointcloud file is valid!"));
return;
}
 
AcDbEntity* pEntPC;
AcGePoint3d ptLocation(0.0, 0.0, 0.0);
nRet = acdbCreatePointCloudEntity(pEntPC, strIndexFilePathOut,L"",ptLocation);
 
if(nRet != Acad::eOk){
acutPrintf(_T("\nFailed to create point cloud entity, \
  please check if pointcloud file and its index file are valid!"));
        return;
}
 
AcDbObjectIdobjIdPC;
nRet = acdbAttachPointCloudEntity(objIdPC, strIndexFilePathOut, "", ptLocation);
 
if(nRet != Acad::eOk){
acutPrintf(_T("\nFailed to create point cloud entity, \
  please check if pointcloud file and its index file are valid!"));
return;
}
Message 24 of 24
kubitTilo
in reply to: XXFW_AUTOCAD

I don't find anything that's wrong with your code.

My first suspicion was that you accidently call acpcIndexPointCloud asynchronously because the respective parameter defaults to true..., but you do correctly set it to false.

Have you already tried to attach the PCG in another command?

Another workaround could be to attach the point cloud using AutoCAD's "-POINTCLOUDATTACH" command and acedCommand() or sendStringToExecute() API's.




Tilo Pfliegner

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

Post to forums  

Autodesk Design & Make Report

”Boost