|
- void asdktest()
- {
- AcGePoint3d pnt1;
- // get the first point
- int res = acedGetPoint (NULL, "\nPick crossing window : ", asDblArray (pnt1));
- // if ok
- if (res == RTNORM)
- {
- AcGePoint3d pnt2;
- res = acedGetCorner (asDblArray (pnt1), "\nSpecify other corner : ", asDblArray (pnt2));
- // if ok
- if (res == RTNORM)
- {
- AcGePoint3d distPnt;
- res = acedGetPoint (asDblArray (pnt1), "\nPick distance : ", asDblArray (distPnt));
- // if ok
- if (res == RTNORM)
- {
- // get the stretch distance
- AcGeVector3d stretchVec = distPnt - pnt1;
- // create a bounding box - we have to use the set method like this because of
- // a defect in the other set method :-(
- AcGeBoundBlock3d box;
- box.set (pnt1, AcGeVector3d ((pnt2-pnt1).x, 0,0),
- AcGeVector3d (0,(pnt2-pnt1).y,0),
- AcGeVector3d (0,0,(pnt2-pnt1).z));
- ads采用name ss;
- // get a strech selection set
- res = acedSSGet ("采用C", asDblArray (pnt1), asDblArray (pnt2), NULL, ss);
- // if ok
- if (res == RTNORM)
- {
- // get the length of the selection set
- long length = 0l;
- acedSSLength (ss, &length);
- // now loop round
- for (long i=0; i<length; ++i)
- {
- ads采用name ename;
- // extract the ename
- if (acedSSName (ss, i, ename) != RTNORM)
- continue;
- AcDbObjectId id;
- // convert the ename into an ObjectId
- acdbGetObjectId(id, ename);
- // open the entity for write
- AcDbObjectPointer<AcDbEntity>ent (id, AcDb::kForWrite);
- // if ok
- if (ent.openStatus() == Acad::eOk)
- {
- AcGePoint3dArray pnts;
- // get the stretch points
- if (ent->getStretchPoints(pnts) != Acad::eOk)
- continue;
- // find out what points need processing
- AcDbIntArray idxAry;
- bool found = false;
- for (int i=0; i<pnts.length(); ++i)
- {
- // get one of the stretch points
- AcGePoint3d pnt = pnts.at(i);
- // if the point is in the crossing window
- if (box.contains(pnt))
- {
- // add it to our list
- idxAry.append(i);
- found = true;
- }
- }
- // if the stretch is valid
- if (found || pnts.length() == 0)
- {
- // then update the points!!
- ent->moveStretchPointsAt(idxAry, stretchVec);
- }
- }
- }
- // free up the selection set
- acedSSFree (ss);
- }
- }
- }
- }
- }
复制代码 |
|