|  | 
 
| AcDbText text(position, _T("hello"), AcDbObjectId::kNull, 20); // now zoom extents to show where it was drawn
 //store the temporary lines
 m_tempExt.addPoint(startPoint);
 m_tempExt.addPoint(endPoint);
 if (mCurrentDwg->extmin().distanceTo(mCurrentDwg->extmax()) < 1e20)
 {
 m_tempExt.addPoint(mCurrentDwg->extmin());
 m_tempExt.addPoint(mCurrentDwg->extmax());
 }
 AcDbExtents viewExtents(m_tempExt);
 viewExtents.transformBy(m_viewMatrix);
 mPreviewCtrl.mpView->zoomExtents(viewExtents.minPoint(),viewExtents.maxPoint());
 // 测试代码开始
 CMyEntity* pMyEnt = new CMyEntity;
 pMyEnt->setDatabaseDefaults();
 // 测试代码结束
 后来经由测试发现,这个问题仅在 AutoCAD 2009 下呈现,2002、2004、2005、2006、2007、2008、2010 均不会涌现。
 AcDbRotatedDimension dimension(0, startPnt, endPnt, dimPnt);
 text.setHorizontalMode(AcDb::kTextCenter);
 text.setVerticalMode(AcDb::kTextVertMid);
 text.setAlignmentPoint(position);
 text.worldDraw(mode);
 text.setHorizontalMode(AcDb::kTextCenter);
 text.setVerticalMode(AcDb::kTextVertMid);
 text.setAlignmentPoint(position);
 text.worldDraw(mode);
 }
 Adesk::Boolean CMyEntity::worldDraw(AcGiWorldDraw* mode)
 {
 AcGePoint3d startPnt = AcGePoint3d::kOrigin;
 AcGePoint3d endPnt = startPnt + AcGeVector3d::kXAxis * 200;
 AcGePoint3d dimPnt = (startPnt + endPnt.asVector() / 2.0) + AcGeVector3d::kYAxis * 10;
 AcGePoint3d position = (startPnt + endPnt.asVector() / 2.0);
 return Adesk::kTrue;
 }
 return Adesk::kTrue;
 }
 dimension.worldDraw(mode);
 }
 奇异的是假如在 worldDraw 中将 AcDbRotatedDimension、AcDbText 实体的相干代码放在一起,则不会崩溃,代码如下:
 3.修正 void CBlockViewDlg::OnAddtempentity() 函数(增加的代码为红色),buy ralph lauren online,如下:
 // if we created it ok
 if (line ,air jordan!= NULL)
 {
 // add the newly created line to the AcGsView
 mPreviewCtrl.mpView->add (line, mPreviewCtrl.model());
 // next record the temporary entity so we can free it later
 mPreviewCtrl.addTempEntity(line);
 void CBlockViewDlg::OnAddtempentity()
 {
 AcGePoint3d startPoint (rand()/100,rand()/100,rand()/100);
 AcGePoint3d endPoint (rand()/100,rand()/100,rand()/100);
 // create a new line with random coords
 AcDbLine *line = new AcDbLine (startPoint,burberry sneakers, endPoint);
 line->setDatabaseDefaults();
 Adesk::Boolean CMyEntity::worldDraw(AcGiWorldDraw* mode)
 {
 AcGePoint3d startPnt = AcGePoint3d::kOrigin;
 AcGePoint3d endPnt = startPnt + AcGeVector3d::kXAxis * 200;
 AcGePoint3d dimPnt = (startPnt + endPnt.asVector() / 2.0) + AcGeVector3d::kYAxis * 10;
 AcGePoint3d position = (startPnt + endPnt.asVector() / 2.0);
 // 测试代码开端
 mPreviewCtrl.mpView->add (pMyEnt, mPreviewCtrl.model());
 mPreviewCtrl.addTempEntity(pMyEnt);
 // 测试代码停止
 {
 AcDbText text(position,gianmarco lorenzi website, _T("hello"), AcDbObjectId::kNull, 20);
 4.在 AutoCAD 2009 中加载 BlockView 程序,单击 Add Temp Entity,程序瓦解。
 这一段在 AutoCAD 2009 版本下应用 BlockView 例程预览自定义实体时,发明 worldDraw 函数的某些代码会导致程序崩溃。重现步骤如下:
 1.从 AcDbEntity 派生一个自定义实体 CMyEntity。
 2.实现 worldDraw 函数,ugg boots clearance,代码如下:
 dimension.worldDraw(mode);
 mPreviewCtrl.SetFocus();
 }
 }
 {
 AcDbRotatedDimension dimension(0, startPnt, endPnt, dimPnt);
 // update the gsView
 refreshView(mPreviewCtrl.mpView);
 | 
 |