/* Extract entities out of a selection set and add them to the * appropriate list. */ int SampleEnts(ads_name selset, ExportMode expMode) { char layer[64], type[16]; long int num, numtot; ads_name ename; ADSResBuf *edata; DLL_LIST list; if (ads_sslength(selset, &numtot) != RTNORM) return 0; for (num = 0; num < numtot; num++) { if (num % 20 == 0) ads_printf("Sampling entities: %ld/%ld\r", num, numtot); if (ads_ssname(selset, num, ename) != RTNORM) return 0; if ((edata = ads_entget(ename)) == NULL) { WarnMsg("SampleEnts: can't get ent: %lx", ename); return 0; } if (strcmp(RBSearch(edata, 0)->resval.rstring, "INSERT") == 0) { if ((list = DllNewList(entListsSetup)) == NULL) { WarnMsg("SampleEnts: can't make block entity list"); return 0; } (void)DllPushF(list, NewADSName(ename), NULL); AddToBlockList(list); ads_relrb(edata); continue; } if (!IsValidEntType(GetEntType(edata, type))) { ads_relrb(edata); continue; } if ((list = DllNewList(entListsSetup)) == NULL) { WarnMsg("SampleEnts: can't make entity list"); ads_relrb(edata); return 0; } (void)DllPushF(list, NewADSName(ename), NULL); switch (expMode) { case EXP_BYCOLOR: if (!AddEntToColorLists(list, GetColorVal(edata, NULL, 0))) return 0; break; case EXP_BYLAYER: if (!GetLayerVal(layer, edata, list, 0)) return 0; if (!AddEntToLayerLists(list, layer)) return 0; break; default: ads_fail("SampleEnts: unknown export mode."); } ads_relrb(edata); } ads_printf("Sampling entities: %ld/%ld\n", num, numtot); return RTNORM; }
void CTwAutoRedraw::Remove() { long Len = 0; ads_sslength( m_ss, &Len ); for ( int i = 0; i < Len; i++ ) { ads_name ent; ads_ssname( m_ss, i, ent ); ads_redraw( ent, 4 ); } ads_ssfree( m_ss ); ads_name_clear( m_ss ); }
Adesk::Boolean AecUiPrSubentity::retrievePickDataAt(long index) { AecRmCString hardErrMsg(GetAecUiBaseAppName(), AECU_STR_RETRIEVEPICKDATAAT_AECUIPRSUBENTITY_ERROR_COULD_NOT, TRUE); //~ "\nERROR: could not retreive pick data!" resbuf* rb; ads_name selSet; m_ss.asAdsName(selSet); if (ads_ssnamex(&rb, selSet, index) != RTNORM) return Adesk::kFalse; // find out the objectId of the item picked AcDbObjectId mainId; ads_name ent; ads_ssname(selSet, index, ent); if (Aec::enameToObjId(ent, mainId) != Acad::eOk) { ads_printf(hardErrMsg); return Adesk::kFalse; } resbuf* tmp = rb; if ((tmp == NULL) || (tmp->restype != RTLB)) { // should start with this AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } // second element is selection method, which should always be pickPt=1 tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RTSHORT) || (tmp->resval.rint != 1)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } // third element is entity name of object selected tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RTENAME)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } // fourth element is the gsMarker tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RTSHORT)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } int gsMarker = tmp->resval.rint; // fifth element is start of list for pickPt tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RTLB)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } // sixth element is point descriptor tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RTSHORT)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } // seventh element is pick point tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RT3DPOINT)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } AcGePoint3d pickPt(tmp->resval.rpoint[0], tmp->resval.rpoint[1], tmp->resval.rpoint[2]); // eigth element is either end of list or the direction vector tmp = tmp->rbnext; if (tmp == NULL) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } AcGeVector3d pickVector; if (tmp->restype == RT3DPOINT) pickVector.set(tmp->resval.rpoint[0], tmp->resval.rpoint[1], tmp->resval.rpoint[2]); else pickVector.set(0.0, 0.0, 1.0); // WCS Z-axis ads_relrb(rb); // if this is the first time its picked, set mainId to this objectId. // All subsequent picks must match this id if (m_mainEnt == AcDbObjectId::kNull) { m_mainEnt = mainId; // add this to the "set" of objects selected (which in our case is 1 item) m_selSet.setLogicalLength(0); // reset array m_selSet.append(mainId); } else { // must be from same entity! if (m_mainEnt != mainId) { AecRmCString msg; msg.LoadString(GetAecUiBaseAppName(), AECU_STR_SUBENT_MUST_BE_FROM_MAINENT); ads_printf(msg); return Adesk::kFalse; } } // unhighlight any existing edges doUnHighlight(m_mainEnt); // if the same edge is picked twice, remove it out of the set int atIndex; if (m_gsMarkers.find(gsMarker, atIndex)) { m_gsMarkers.removeAt(atIndex); m_pickPts.removeAt(atIndex); m_pickVecs.removeAt(atIndex); DEBUG_ONLY(ads_printf(_DNT(_T("\nAecUiPrSubentity:: removed gsmarker: %d")), gsMarker)); } else { m_isValidssnamexData = Adesk::kTrue; // this isn't really accurate Nth time thru loop m_gsMarkers.append(gsMarker); m_pickPts.append(pickPt); m_pickVecs.append(pickVector); DEBUG_ONLY(ads_printf(_DNT(_T("\nAecUiPrSubentity:: added gsmarker: %d")), gsMarker)); } // re-highlight with new data doHighlight(m_mainEnt); return Adesk::kTrue; }