void asdktest5 () { //----- Select the entities ads_name ss, en ; if ( acedSSGet (NULL, NULL, NULL, NULL, ss) != RTNORM ) return ; //----- Append entity IDs to the collector long n ; AcDbObjectId id ; AsdkHlrCollector collector ; acedSSLength (ss, &n) ; for ( int i =0 ; i < n ; i++ ) { acedSSName (ss, i, en) ; acdbGetObjectId (id, en) ; collector.addEntity (id) ; } acedSSFree (ss) ; //----- Display a dialog box to select HLR controls, the user wants to apply to the HLR engine AfxSetResourceHandle (_hdllInstance) ; CControlsDlg dlg ; dlg.mnControls =kProject | kEntity | kBlock | kHonorInternals ; if ( dlg.DoModal () != IDOK ) { AfxSetResourceHandle (acedGetAcadResourceInstance ()) ; return ; } AfxSetResourceHandle (acedGetAcadResourceInstance ()) ; int control =dlg.mnControls ; acutPrintf (ACRX_T("\nAbout to call hidden Line calculation")) ; acutPrintf (ACRX_T("\nCalling with %d Entities"), collector.getInputEntityIds ().logicalLength ()) ; acutPrintf (ACRX_T("\nkProject %s "), control & kProject ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkShowAll %s "), control & kShowAll ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkEntity %s "), control & kEntity ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkBlock %s "), control & kBlock ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkSubentity %s "), control & kSubentity ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkHideTangents %s "), control & kHideTangents ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkCleanup %s "), control & kCleanup ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkIsolines %s "), control & kIsolines ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkUnite %s "), control & kUnite ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkReuse %s "), control & kReuse ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkProgress %s "), control & kProgress ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkHandlePoints %s "), control & kHandlePoints ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkHonorInternals %s "), control & kHonorInternals ? ACRX_T("On") : ACRX_T("Off")) ; acutPrintf (ACRX_T("\nkMeshSilhouettes %s "), control & kMeshSilhouettes ? ACRX_T("On") : ACRX_T("Off")) ; //----- Ask for virtual viewport settings AcDbViewport *pVp =NULL ; if ( !pickViewport (pVp) ) return ; //----- Process hidden line removal AsdkHlrEngine hlr (pVp, control) ; hlr.run (collector) ; delete pVp ; //----- The following code will collect the color of the originator entity of an edge //----- and will assign it to the resulting entity. actrTransactionManager->startTransaction () ; int nOutput =collector.mOutputData.logicalLength () ; acutPrintf (ACRX_T("\nHlr returned %d curves"), nOutput) ; for ( int j =0 ; j < nOutput ; j++ ) { AsdkHlrData *pResult =collector.mOutputData [j] ; AcDbEntity *pResultEntity =pResult->getResultEntity () ; AcDbObjectId id ; if ( postToDatabase (NULL, pResultEntity, id) != Acad::eOk ) { acutPrintf (_T("Failed to add entity to current space.\n")) ; break ; } actrTransactionManager->getObject ((AcDbObject *&)pResultEntity, id, AcDb::kForWrite) ; AcDbObjectIdArray ids =pResult->getObjectIds () ; int last =ids.logicalLength () - 1 ; AcCmColor color ; AcDbObjectId layerId ; color.setColorIndex (0) ; while ( last >= 0 && color.colorIndex () == 0 ) { AcDbObjectId innerId =ids.at (last) ; AcDbObject *pObj ; actrTransactionManager->getObject (pObj, innerId, AcDb::kForRead) ; AcDbEntity *pEnt =AcDbEntity::cast (pObj) ; color =pEnt->color () ; layerId =pEnt->layerId () ; last-- ; } if ( layerId != AcDbObjectId::kNull ) { pResultEntity->setColor (color) ; pResultEntity->setLayer (layerId) ; } else { AcDbEntity *pEnt =pResult->getEntity () ; if ( pEnt != NULL ) { pResultEntity->setColor (pEnt->color ()) ; pResultEntity->setLayer (pEnt->layer ()) ; } } pResultEntity->close () ; } actrTransactionManager->endTransaction(); }
void ZcEntityReactor::openedForModify(const AcDbObject* dbObj) { if (!dbObj->isKindOf(AcDbEntity::desc())) { acutPrintf(_T("\nObject is not a valid Entity!")); return; } AcDbEntity* pEnt = AcDbEntity::cast(dbObj); CString strLayer; strLayer.Format(_T("\nCurrent Entity:%s .The layerName:%s ."), pEnt->isA()->name(), pEnt->layer()); acutPrintf(strLayer); }
void CDlgReadInfo::OnBnClickedBtnSelect() { //交互选择实体 BeginEditorCommand(); CString strCadName; CComboBox* pCmb = (CComboBox*)GetDlgItem(IDC_COMBO_CADLY); pCmb->GetLBText(pCmb->GetCurSel(),strCadName); ads_name ssName; struct resbuf *filter=NULL; if(strCadName.CompareNoCase("所有图层") != 0) { filter=acutNewRb(AcDb::kDxfLayerName); filter->restype=AcDb::kDxfLayerName; filter->resval.rstring = (char*) malloc((strCadName.GetLength()+1)*sizeof(char)); strcpy(filter->resval.rstring,strCadName.GetBuffer(0)); filter->rbnext=NULL; } if (acedSSGet(":S", NULL, NULL, filter, ssName) != RTNORM) { acutPrintf("\n选择实体有误!"); acedSSFree(ssName); acutRelRb(filter); CompleteEditorCommand(); return; } if(filter != NULL) acutRelRb(filter); AcDbObjectId tempObjId; ads_name ssTemp; long nNum = 0; int nPos = 0; acedSSLength(ssName,&nNum); CString strSdeName,strId,strRowId; m_wndTree.DeleteAllItems(); // 清空属性列表 ResetListItems(); for(int i=0; i<nNum; i++) { acedSSName(ssName, i, ssTemp); if(Acad::eOk != acdbGetObjectId(tempObjId, ssTemp)) continue; strId.Format("%d",tempObjId.asOldId()); CDistXData tempXData(tempObjId,"ROWID_OBJS"); if(tempXData.Select("SDELYNAME",strSdeName)==FALSE) continue; if(tempXData.Select("OBJECTID",strRowId)==FALSE) continue; tempXData.Close(); HTREEITEM hItem = m_wndTree.InsertItem(strId); AcDbEntity *pEnt = NULL; if (Acad::eOk != acdbOpenObject(pEnt, tempObjId, AcDb::kForRead)) { return; } pEnt->close(); ITEM_DATA xxItemData; xxItemData.strID = strId; xxItemData.strSdelayerName = strSdeName; xxItemData.strCadLayerName = pEnt->layer(); xxItemData.strRowId = strRowId; mapItemData[strId] = xxItemData; nPos++; } acedSSFree(ssName); CompleteEditorCommand(); if (m_wndTree.GetCount() <= 0) { return; } HTREEITEM hItem = m_wndTree.GetFirstVisibleItem(); // 显示属性 OnSelectChanged(hItem); }
void ZcEntityReactor::modified(const AcDbObject* dbObj) { if (!dbObj->isKindOf(AcDbEntity::desc())) { acutPrintf(_T("\nObject is not a valid Entity!")); return; } AcDbEntity* pEnt = AcDbEntity::cast(dbObj); CString strLayer; strLayer.Format(_T("\nEntity:%s has been modified.The layerName:%s.\n"), pEnt->isA()->name(), pEnt->layer()); acutPrintf(strLayer); }