static void CPickUp_pickup(void)
{
while (true)
{
struct resbuf eb;
TCHAR sbuf[10];
eb.restype=0; // имя примитива
_tcscpy(sbuf,_T("INSERT"));
eb.resval.rstring=sbuf;
eb.rbnext=0;
ads_name ss;
if(acedSSGet(0,0,0,&eb,ss) !=RTNORM)
{
acutRelRb(&eb);
return;
}
acutRelRb(&eb);
long length=0;
if((acedSSLength(ss,&length)!=RTNORM)||(length==0))
{
acedSSFree(ss);
return;
}
ads_point pointBaz;
ads_real Zlevel=0.0;
int stat;
TCHAR kw[20];
acedInitGet(RSG_OTHER,0);
bool b=true;
while(b)
{
if((stat=acedGetPoint(0,_T("\nВыбери точку или введи значение: "),pointBaz))==RTCAN)
{
acedSSFree(ss);
return;
}
else if (stat==RTNORM)
{
Zlevel=pointBaz[Z];
b=false;
}
else if(stat==RTKWORD && acedGetInput(kw) == RTNORM)
{
if( (stat=acdbDisToF(kw, -1, &Zlevel))== RTNORM)
b=false;
}
}
ads_name ent;
AcDbObjectId id = AcDbObjectId::kNull;
// Walk through the selection set and open each entity
for (long i = 0; i < length; i++)
{
if (acedSSName(ss,i,ent) != RTNORM) continue;
if (acdbGetObjectId(id,ent) != Acad::eOk) continue;
AcDbEntity* pEnt = NULL;
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForWrite) != Acad::eOk)
continue;
if ( !pEnt->isKindOf (AcDbBlockReference::desc ()) )
{
pEnt->close();
continue;
}
AcDbBlockReference* pBl=AcDbBlockReference::cast(pEnt);
AcGePoint3d pPoint=pBl->position();
resbuf fromrb, torb;
fromrb.restype=RTSHORT;
fromrb.resval.rint=0; // WCS
torb.restype=RTSHORT;
torb.resval.rint=1; // UCS
// disp==0 indicates that pt is a point??????????????
ads_point result, objPoint;
objPoint[0]=pPoint[0];objPoint[1]=pPoint[1];objPoint[2]=pPoint[2];
acedTrans(objPoint,&fromrb,&torb,false,result);
result[Z]=Zlevel;
fromrb.resval.rint=1; // UCS
torb.resval.rint=0; // WCS
acedTrans(result,&fromrb,&torb,false,objPoint);
AcGePoint3d oldPosition= pBl->position();
AcGePoint3d newPosinion(objPoint[X],objPoint[Y],objPoint[Z]);
AcGeVector3d v=newPosinion-oldPosition;
pBl->transformBy(AcGeMatrix3d().setToTranslation(v));
pEnt->close(); pEnt=0;
}
acedSSFree(ss);
}
return;
}