ObjectARX

Reply
Contributor
xeri0n
Posts: 19
Registered: ‎11-21-2011
Message 21 of 24 (475 Views)

Re: Accessing point cloud entity loaded from a .pcg file

05-08-2012 07:20 PM 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 ! 

 

 

Active Contributor
kubitTilo
Posts: 31
Registered: ‎09-02-2005
Message 22 of 24 (466 Views)

Re: Accessing point cloud entity loaded from a .pcg file

05-09-2012 03:00 AM 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

www.kubit-software.com
New Member
XXFW_AUTOCAD
Posts: 1
Registered: ‎01-16-2013
Message 23 of 24 (330 Views)

Re: Accessing point cloud entity loaded from a .pcg file

01-16-2013 05:32 AM 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;
}
Active Contributor
kubitTilo
Posts: 31
Registered: ‎09-02-2005
Message 24 of 24 (319 Views)

Re: Accessing point cloud entity loaded from a .pcg file

01-16-2013 11:17 AM 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

www.kubit-software.com

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community