bool ArxEntityHelper::GetEntitiesColor( const AcDbObjectIdArray& objIds, AcArray<Adesk::UInt16>& colors ) { AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return false; bool ret = true; // 默认返回true int len = objIds.length(); for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForRead ) ) { actrTransactionManager->abortTransaction(); ret = false; colors.removeAll(); // 清空 break; } AcDbEntity* pEnt = AcDbEntity::cast( pObj ); if( pEnt == 0 ) { actrTransactionManager->abortTransaction(); ret = false; colors.removeAll(); // 清空 break; } Adesk::UInt16 ci = pEnt->colorIndex(); colors.append( ci ); // 记录原有的颜色 } actrTransactionManager->endTransaction(); return ret; }
virtual Acad::ErrorStatus getOsnapInfo( AcDbEntity* pickedObject, Adesk::GsMarker gsSelectionMark, const AcGePoint3d& pickPoint, const AcGePoint3d& lastPoint, const AcGeMatrix3d& viewXform, AcArray<AcGePoint3d>& snapPoints, AcArray<int>& geomIdsForPts, AcArray<AcGeCurve3d*>& snapCurves, AcArray<int>& geomIdsForLines) { // Generic curve function for all AcDbCurves (except AcDbPolylines) // Protocol Extension insures that the following assertion is always // true, but check in non-prod versions just to be safe. assert( pickedObject->isKindOf( AcDbCurve::desc() )); // but in production, a hard cast is fastest AcDbCurve *pCurve = (AcDbCurve*)pickedObject; double startParam, endParam; AcGePoint3d pt; Acad::ErrorStatus es; es=pCurve->getStartParam( startParam); es=pCurve->getEndParam( endParam ); es=pCurve->getPointAtParam( startParam + ((endParam - startParam) / 3), pt ); assert( Acad::eOk == es); snapPoints.append( pt ); es=pCurve->getPointAtParam( startParam + ((endParam - startParam) * 2 / 3), pt ); assert(Acad::eOk==es); snapPoints.append( pt ); if ( pCurve->isClosed() ) { es=pCurve->getStartPoint( pt ); assert(Acad::eOk==es); snapPoints.append( pt ); } return Acad::eOk; }
void ContourColorDlg::OnBnClickedOk() { UpdateData( TRUE ); // 获取图层名称 CString layer; if( !GetLayer( layer ) ) { MessageBox( _T( "没有选择包含等值线的图层" ) ); return; } AcGeDoubleArray zValues; AcArray<COLORREF> colors; int n = m_colorList.GetItemCount(); for( int i = 0; i < n; i++ ) { ColorListItemData* pData = ( ColorListItemData* )m_colorList.GetItemData( i ); zValues.append( pData->z ); colors.append( pData->rgb ); } // 删除最后一个z值 zValues.removeLast(); // 删除color list上的附加数据 DeleteColorListItemDatas(); // 获取图层上的等值线信息图元 AcDbObjectId objId = GetContourInfoOnLayer( layer ); SetContourInfo( objId, zValues, colors, m_bFillColor ); // 获取边界坐标数据 AcGePoint3dArray bounds; GetBoundaryPoints( bounds ); if( bounds.isEmpty() ) { MessageBox( _T( "请添加一个闭合的井田边界" ) ); return; } // 获取点集数据 AcGePoint3dArray datas; GetContourDatas( objId, datas ); //assert((colors.length()-zValues.length()) == 1); // 绘制填充 DrawFill( layer, bounds, datas, zValues, colors, m_bFillColor ); OnOK(); }
void LineFrameBuilder::buildFramePoints(AcArray<AcGePoint3d>& arrayPoints, AcDbObjectPointer<AcDbEntity>& lineObject, int granularity) { acutPrintf(_T("Building the points using LineFrameBuilder ...\n")); _pLine = AcDbLine::cast(lineObject); arrayPoints.append(_pLine->startPoint()); double length; _pLine->getDistAtPoint(_pLine->endPoint(), length); acutPrintf(_T("The length and other params: %f, %d, %d ...\n"), length, ((int) length)/granularity, granularity); for (int i = 1; i< ((int) length)/granularity; i++) { AcGePoint3d newPoint; _pLine->getPointAtDist(i*granularity, newPoint); arrayPoints.append(newPoint); } arrayPoints.append(_pLine->endPoint()); acutPrintf(_T("Built the points using LineFrameBuilder ...\n")); }
static void addDoc(AcApDocument* pDoc) { AsdkCmdCountDocData newData; newData.doc = pDoc; docData.append(newData); }
virtual Acad::ErrorStatus getOsnapInfo( AcDbEntity* pickedObject, Adesk::GsMarker gsSelectionMark, const AcGePoint3d& pickPoint, const AcGePoint3d& lastPoint, const AcGeMatrix3d& viewXform, AcArray<AcGePoint3d>& snapPoints, AcArray<int>& geomIdsForPts, AcArray<AcGeCurve3d*>& snapCurves, AcArray<int>& geomIdsForLines) { // Specialised implementation for AcDbPolylines: // Parametrisation of AcDbPolylines is different: each whole numbered paramater appears // at a vertex, so we cannot simply divide by three to get the correct parameter. // Protocol Extension insures that the following assertion is always // true, but check in non-prod versions just to be safe. assert( pickedObject->isKindOf( AcDbPolyline::desc() )); // but in production, a hard cast is fastest AcDbPolyline *pPline = (AcDbPolyline*)pickedObject; Acad::ErrorStatus es; if ( bSnapToSegments ) { // Snap to a third of each of the segments unsigned int numSegs = pPline->numVerts() - 1; AcGeLineSeg3d segLn; AcGeCircArc3d segArc; double startParam, endParam, newParam, dist; AcGePoint3d pt; for ( unsigned int idx = 0; idx < numSegs; idx++ ) { switch( pPline->segType( idx )) { case AcDbPolyline::kLine: es=pPline->getLineSegAt( idx, segLn ); startParam = segLn.paramOf( segLn.startPoint() ); endParam = segLn.paramOf( segLn.endPoint() ); snapPoints.append(segLn.evalPoint( startParam + ((endParam - startParam) / 3 ))); snapPoints.append(segLn.evalPoint( startParam + ((endParam - startParam) * 2 / 3 ))); break; case AcDbPolyline::kArc: es=pPline->getArcSegAt( idx, segArc ); startParam = segArc.paramOf( segArc.startPoint() ); endParam = segArc.paramOf( segArc.endPoint() ); dist = segArc.length( startParam, endParam ); newParam = segArc.paramAtLength( startParam, dist / 3 ); snapPoints.append( segArc.evalPoint( newParam )); newParam = segArc.paramAtLength( startParam, dist * 2 / 3 ); snapPoints.append( segArc.evalPoint( newParam )); break; default: break; } } } else { double endParam; AcGePoint3d pt; double dist; es=pPline->getEndParam( endParam ); es=pPline->getDistAtParam( endParam, dist ); es=pPline->getPointAtDist( dist / 3, pt ); assert(Acad::eOk==es); snapPoints.append( pt ); es=pPline->getPointAtDist( dist * 2 / 3, pt ); assert(Acad::eOk==es); snapPoints.append( pt ); if ( pPline->isClosed() ) { es=pPline->getStartPoint( pt ); snapPoints.append( pt ); } } return Acad::eOk; }