请教遍历的问题
<P>问题:构造选择集,获取选择集里的特征点并充放在数组中,然后在比较特征点在数组中的位置。以下是代码,但结果总是不正确,虽然调试是通了。</P><P>请各位帮忙,谢谢!</P>
<P>void zhao_rank()<BR>{<BR> // TODO: Implement the command<BR> int i,cod_number;<BR> int j;<BR> long ilast;<BR> ads_name ent;<BR> float coordinate;</P>
<P> acedSSLength(ssname,&ilast);</P>
<P> AcDbEntity *pEntity;<BR> AcDbObjectId objId;<BR> //*********以下程序是将选择集中实体坐标储存在二维数组***********// <BR> for(i=1;i<ilast+1;i++)<BR> {<BR> acedSSName(ssname,ilast-i,ent);<BR> acdbGetObjectId(objId,ent);<BR> acdbOpenObject(pEntity,objId,AcDb::kForRead);//打开点实体<BR> <BR> if(pEntity->isKindOf(AcDbCircle::desc()))<BR> {<BR> // 显示圆的圆心<BR> AcDbCircle *pCircle = AcDbCircle::cast(pEntity); <BR> AcGePoint3d ptCenter; <BR> ptCenter = pCircle->center(); <BR> <BR> coordinate=ptCenter;<BR> coordinate=ptCenter;<BR> coordinate=ptCenter;<BR> }<BR> if(pEntity->isKindOf(AcDbPoint::desc()))<BR> {<BR> // 显示点的坐标<BR> AcDbPoint *pPoint = AcDbPoint::cast(pEntity); <BR> AcGePoint3d ptPoint; <BR> ptPoint = pPoint->position(); <BR> <BR> coordinate=ptPoint;<BR> coordinate=ptPoint;<BR> coordinate=ptPoint;<BR> }<BR> pEntity->close(); <BR> }</P>
<P> //*********以下程序是为实体标号***********// <BR>for(i=1;i<ilast+1;i++)<BR>{<BR> cod_number=1;<BR> acedSSName(ssname,ilast-i,ent);<BR> acdbGetObjectId(objId,ent);<BR> acdbOpenObject(pEntity,objId,AcDb::kForRead);//打开点实体<BR> if(pEntity->isKindOf(AcDbCircle::desc()))<BR> {<BR> AcDbCircle *pCircle = AcDbCircle::cast(pEntity); <BR> AcGePoint3d ptCenter; <BR> ptCenter = pCircle->center(); <BR> for(j=1;j<ilast+1;j++)<BR> if(ptCenter<coordinate||(ptCenter==coordinate&&ptCenter<coordinate))<BR> cod_number=cod_number+1;<BR> acutPrintf("\n %d",cod_number);<BR> }<BR> if(pEntity->isKindOf(AcDbPoint::desc()))<BR> {<BR> AcDbPoint *pPoint = AcDbPoint::cast(pEntity); <BR> AcGePoint3d ptPoint; <BR> ptPoint = pPoint->position(); <BR> for(j=1;j<ilast+1;j++)<BR> if(ptPoint<coordinate||(ptPoint==coordinate&&ptPoint<coordinate))<BR> cod_number=cod_number+1;<BR> acutPrintf("\n %d",cod_number);<BR> }<BR> </P>
<P>}<BR> acedSSFree(ssname);<BR>}</P> <P>用AcDbObjectIdArray</P>
页:
[1]