AcGeVoidPointerArray problem...

AcGeVoidPointerArray problem...

Anonymous
Not applicable
1,188 Views
7 Replies
Message 1 of 8

AcGeVoidPointerArray problem...

Anonymous
Not applicable

how to find ARC type entity or any type entity in AcGeVoidPointerArray...

 

example..

 

AcGeVoidPointerArray d;
d.setPhysicalLength(30);
aBloc->explode(d);
int g = d.length();

 

 

(aBloc is pointer of a BlockRefrence..)

 

please help..

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

thierry_prince
Advocate
Advocate
Accepted solution

Hi,

 

You should test each pointer stored in the array if it is the expected entity.

For example :

for (int i = 0; i < d.length(); i++)
{
  AcDbEntity* pEnt = (AcDbEntity*)d[i];
  if (pEnt == NULL)
    continue;
  if (pEnt->isKinkOf(AcDbArc::desc()))
  {
    // Do something...
  }
}

Cheers,

Thierry

 

0 Likes
Message 3 of 8

Anonymous
Not applicable

thank you Sir

0 Likes
Message 4 of 8

Anonymous
Not applicable

one more problem....

 

if  AcGeVoidPointerArray has axis points..so how can access those points....

0 Likes
Message 5 of 8

7598165
Advocate
Advocate

Use AcGePoint3dArray to store points instead of AcGeVoidPointerArray

 

AcGeVoidPointArray is used to store an array of AcGeEntity3d or AcGeEntity2d class objects

 

and 

 

 

Are you sure that you use the AcGevoidPointerArray stored AcDbEntity ? Not AcDbVoidPointerArray?

0 Likes
Message 6 of 8

autodaug
Autodesk
Autodesk

There does seem to be some confusion here between the AcDb* and AcGe* namespaces. The two frameworks are different, but they use a lot of the same or similar names ("explode", "isKindOf", etc).

 

In the AcGe world, we have type AcGeVoidPointerArray, while in the AcDb world, we have AcDbVoidPtrArray. Both types are defined as AcArray<void *>, so they can be used interchangeably, but using the right identifier makes the code a little more readable.

 

AcGeCurve2d::explode() populates an AcGeVoidPointerArray, where each array entry actually points to an AcGeEntity2d. Likewise, AcGeCurve3d::explode() populates an array with ptrs to AcGeEntity3d's. AcDbEntity::explode(), otoh, gives you an AcDbVoidPtrArray containing pointers to AcDbEntity's.

 

The original question says that aBloc is a pointer to a BlockReference, so we must be talking about an AcDbBlockReference (since the AcGe* namespace doesn't have block references). Thus it is calling AcDbEntity::explode(), and the solution provided above is correct about using AcDbArc::isKindOf() etc to determine the type of AcDbEntity being pointed to.

 

Fwiw, the AcRx cast() method might be useful besides isKindOf(). E.g.:

 

AcDbArc *pArc = AcDbArc::cast(pEnt);
if (pArc != nullptr) {
   // do stuff with pArc
}
else if (AcDbLine *pLine = AcDbLine::cast(pEnt)) {
    // do stuff with pLine
}
etc

And about "axis points", I'm not sure what the question is. Can you clarify?

 

 

 

Message 7 of 8

Anonymous
Not applicable

i'll try to get points on "kExternal" type Hatch ... and i use getLoopAt method ....

 

In case Polyline Hatch its easy to get points ...here getLoopAt method is working fine for getting vertices..

 

what can i do for kExternal type Hatch..??

 

 

 

code::

 

AcGeVoidPointerArray edgepoint;
edgepoint.setPhysicalLength(30);
AcGeIntArray edgetype;
edgetype.setPhysicalLength(50);
Adesk::Int32 loopType;

aHac->getLoopAt(ind, loopType, edgepoint, edgetype);

 

acutPrintf(_T("\n%d"), edgepoint.length());

 

where edgepoint.length gives....4

which is total no. of vertices in hatch..

how can i get the x,y,z values of that vertices??

 

pls help...

0 Likes
Message 8 of 8

7598165
Advocate
Advocate
Accepted solution

not points, you get 4 AcGeCurve2d-type curves,

indicating that the LOOP boundary you took is not a polyline but consists of four curves.

 

for (int i=0;i<EdgePoint.length();i++)
{
	AcGeCurve2d *pGe = (AcGeCurve2d *)EdgePoint[i];

	acutPrintf(_T("\nGe Curve Type=%d"), (int)pGe->type());

	if (pGe->type() == AcGe::kLineSeg2d)
	{
	}
	else if (pGe->type() == AcGe::kCircArc2d)
	{

	}
	else if (pGe->type() == AcGe::kEllipArc2d)
	{

	}
	else if (pGe->type() == AcGe::kNurbCurve2d)
	{

	}else if (pGe->type() == AcGe::kCompositeCrv2d)
	{
	}
	else {
        ....
	}

}