static void ALIGN3(void)
{
ads_name en; ads_point p1; ads_point p2;
if (acedEntSel(_T("\nВыберите объект: "),en,p1) != RTNORM ||
acedGetPoint(NULL,_T("\nПервая исходная точка: "),p1) != RTNORM ||
acedGetPoint(p1, _T("\nПервая целевая точка: "), p2) != RTNORM) return;
acdbUcs2Wcs(p1,p1,false); acdbUcs2Wcs(p2,p2,false);
AcGePoint3d pSrcPt1(p1[X],p1[Y],p1[Z]); AcGePoint3d pDestPt1(p2[X],p2[Y],p2[Z]);
if (acedGetPoint(NULL,_T("\nВторая исходная точка: "),p1) != RTNORM ||
acedGetPoint(p1, _T("\nВторая целевая точка: "), p2) != RTNORM) return;
acdbUcs2Wcs(p1,p1,false); acdbUcs2Wcs(p2,p2,false);
AcGePoint3d pSrcPt2(p1[X],p1[Y],p1[Z]); AcGePoint3d pDestPt2(p2[X],p2[Y],p2[Z]);
if (acedGetPoint(NULL,_T("\nТретья исходная точка: "),p1) != RTNORM ||
acedGetPoint(p1, _T("\nТретья целевая точка: "), p2) != RTNORM) return;
acdbUcs2Wcs(p1,p1,false); acdbUcs2Wcs(p2,p2,false);
AcGePoint3d pSrcPt3(p1[X],p1[Y],p1[Z]); AcGePoint3d pDestPt3(p2[X],p2[Y],p2[Z]);
AcGeVector3d v1(pSrcPt1 - pSrcPt2);
AcGeVector3d v2(pDestPt1 - pDestPt2);
AcDbObjectId id; acdbGetObjectId(id,en);
AcDbEntityPointer pEnt(id,AcDb::kForWrite);
if (pEnt.openStatus() != Acad::eOk) return;
AcGeMatrix3d mMatScale, mMatRot, mMatTrans;
mMatScale.setToScaling(v2.length()/v1.length(),pSrcPt1);
pEnt->transformBy(mMatScale); // Масштабируем
AcGePlane pl1(pSrcPt1,pSrcPt1-pSrcPt2,pSrcPt1-pSrcPt3),
pl2(pDestPt1,pDestPt1-pDestPt2,pDestPt1-pDestPt3);
AcGePoint3d pOrig1,pOrig2; AcGeVector3d vX1,vX2,vY1,vY2,vZ1,vZ2;
pl1.getCoordSystem(pOrig1,vX1,vY1); pl2.getCoordSystem(pOrig2,vX2,vY2);
mMatTrans.setToAlignCoordSys(pSrcPt1,vX1,vY1,pl1.normal(),pDestPt1,vX2,vY2,pl2.normal());
pEnt->transformBy(mMatTrans); // Остальные преобразования
pEnt->close();
}