ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

in Acad's three-dimensional view, zoom problem

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
635 Views, 1 Reply

in Acad's three-dimensional view, zoom problem

I have a function working well in 2-D View, but in 3-D view , the "zoom" funtion dose not  give me the corrent result.

the code below is the fuction, can anyone tell me what's wrong in this function, or give me some example?

 

void Zoom(const ads_point pt1,const ads_point pt2)
{
//  ads_command(RTSTR,_T("_zoom"),RTSTR,_T("w"),RT3DPOINT,pt1,RT3DPOINT,pt2,RTNONE);
//  return;
 //CS cs;
 //acedTrans(pt1,&cs.ucs,&cs.wcs,0,pt1);
 //acedTrans(pt2,&cs.ucs,&cs.wcs,0,pt2);
 //HINSTANCE hAcad = acedGetAcadResourceInstance();
 //HINSTANCE hCur = AfxGetResourceHandle();
 //AfxSetResourceHandle(hAcad);//在对话框的函数中,使用Zoom时,由于资料问题,下面的函数会崩溃。 设置CAD资源,这样可以解决方案问题。
 AcDbViewTableRecord view;
 struct resbuf rb;
 struct resbuf wcs, dcs, ccs; // acedTrans coord system flags
 ads_point vpDir;
 ads_point ptmax;
 AcGeVector3d viewDir;
 AcGePoint2d cenPt;
 ads_real lenslength, viewtwist, frontz, backz;
 ads_point target;
 int tilemode, cvport; // Get window to zoom to:

 wcs.restype = RTSHORT; // WORLD coord system flag
 wcs.resval.rint = 0;
 ccs.restype = RTSHORT; // CURRENT coord system flag
 ccs.resval.rint = 1;
 dcs.restype = RTSHORT; // DEVICE coord system flag
 dcs.resval.rint = 2; // Get the 'VPOINT' direction vector

 acedGetVar(_T("VIEWDIR"), &rb);
 acedTrans(rb.resval.rpoint, &ccs, &wcs, 0, vpDir);
 viewDir.set(vpDir[X], vpDir[Y], vpDir[Z]);
 ads_point pt;
 pt[X] = (pt1[X] + pt2[X])/2;
 pt[Y] = (pt1[Y] + pt2[Y])/2;
 pt[Z] = (pt1[Z] + pt2[Z])/2;

 acedTrans(pt, &ccs, &dcs, 0, ptmax);

 // set center point of view
 cenPt[X] = ptmax[X];
 cenPt[Y] = ptmax[Y];
 view.setCenterPoint(cenPt);
 {
  ads_point pt11,pt22;
  acedTrans(pt1, &ccs, &dcs, 0, pt11);
  acedTrans(pt2, &ccs, &dcs, 0, pt22);
  view.setHeight(fabs(pt11[Y]-pt22[Y]));
  view.setWidth(fabs(pt11[X]-pt22[X]));
 }

 view.setViewDirection(viewDir);

 // get and set other properties
 acedGetVar(_T("LENSLENGTH"), &rb);
 lenslength = rb.resval.rreal;
 view.setLensLength(lenslength);

 acedGetVar(_T("VIEWTWIST"), &rb);
 viewtwist = rb.resval.rreal;
 view.setViewTwist(viewtwist);//当前视图的转角,只能是平面的转,不能三维的

 acedGetVar(_T("FRONTZ"), &rb);
 frontz = rb.resval.rreal;

 acedGetVar(_T("BACKZ"), &rb);
 backz = rb.resval.rreal;

 view.setPerspectiveEnabled(false);
 view.setFrontClipEnabled(false);
 view.setBackClipEnabled(false);
 view.setFrontClipAtEye(false);

 acedGetVar(_T("TILEMODE"), &rb);
 tilemode = rb.resval.rint;

 acedGetVar(_T("CVPORT"), &rb);
 cvport = rb.resval.rint;

 // Paperspace flag
 bool paperspace = ((tilemode == 0) && (cvport == 1)) ? Adesk::kTrue
  :Adesk::kFalse;
 view.setIsPaperspaceView(paperspace);
 if (Adesk::kFalse == paperspace) {
  view.setFrontClipDistance(frontz);
  view.setBackClipDistance(backz);
 }
 else {
  view.setFrontClipDistance(0.0);
  view.setBackClipDistance(0.0);
 }

 acedGetVar(_T("TARGET"), &rb);
 acedTrans(rb.resval.rpoint, &ccs, &wcs, 0, target);
 view.setTarget(AcGePoint3d(target[X], target[Y], target[Z]));

 // update view
 //AcDbObjectId id=acedGetCurViewportObjectId();//这个函数只能在图纸空间中使用。
 //AcDbObjectId id = acedActiveViewportId();
 //AcDbObjectPointer<AcDbViewport> pVP(id,AcDb::kForRead);


 acedSetCurrentView(&view,NULL);
 //AfxSetResourceHandle(hCur);
 
 
}

1 REPLY 1
Message 2 of 2
owenwengerd
in reply to: Anonymous

You're more likely to get help if you define "correct result" and describe how the current code differs from what you expect.

--
Owen Wengerd
ManuSoft

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report