Beispiel #1
0
 bool ArxEntityHelper::SelectEntities( const AcDbObjectIdArray& objIds )
{
	//acedSSSetFirst(NULL, NULL);

	if( objIds.isEmpty() ) return false;

	ads_name ss;
	//创建一个空的选择集
	if(RTNORM != acedSSAdd( NULL, NULL, ss )) return false;
	bool ret = true;
	for(int i=0;i<objIds.length();i++)
	{
		ads_name ename;
		if( Acad::eOk != acdbGetAdsName( ename, objIds[i] ) ) 
		{ 
			ret = false;;
			break;
		}
		if( RTNORM != acedSSAdd( ename, ss, ss ) )  // 添加到选择集
		{
			ret = false;;
			break;
		}
	}

	if(ret)
	{
		acedSSSetFirst( ss, NULL ); // 高亮选中
	}
	acedSSFree( ss );           // 释放选择集

	return ret;
}
Beispiel #2
0
String GetSelectedExtent() {
  ads_name selection;
  int returnValue = acedSSGet(_T("I"), NULL, NULL, NULL, selection);
  if (returnValue == RTCAN) return 0;
  if (returnValue != RTNORM) {
    return L"";
  }

  if (acedSSSetFirst(selection, NULL) != RTNORM) {
    acedSSFree(selection);
    return L"";
  }
  ads_name element;
  acedSSName(selection, 0, element);
  acedSSFree(selection);
  
  AcDbObjectId idEntity;
  if (acdbGetObjectId(idEntity, element) != Acad::eOk) {
    acedSSFree(element);
    return L"";
  }
  
  AcDbEntity * entity;
  if ((acdbGetObjectId(idEntity, element) != Acad::eOk) || 
      (acdbOpenObject(entity, idEntity, AcDb::kForRead) != Acad::eOk)) {
    
    acedSSFree(element);
    return L"";
  }
  
  acedSSFree(element);
  
  if (!entity->isKindOf(AcDbPolyline::desc())) return L"";
  
  AcDbPolyline * poly = static_cast<AcDbPolyline*>(entity);
  if (!poly->isClosed()) return 0;
  
  String extent = L"POLYGON((";
  AcGePoint2d start;
  AcGePoint2d current;
  for (int i = 0; i < poly->numVerts(); i++) {
    poly->getPointAt(i, current);
    
    if (i > 0) {
      extent += L", ";
    } else {
      start = current;
    }
    extent += Round(current.x, 0) + L" " + Round(current.y, 0);
  }
  if (!start.isEqualTo(current)) {
    extent += L", " + Round(start.x, 0) + L" " + Round(start.y, 0);
  }
  
  extent += L"))";
  
  poly->close();
  
  return extent;
}
Beispiel #3
0
int ads_gm_get_data() 
{
  ads_name selection;
  int returnValue = acedSSGet(_T("I"), NULL, NULL, NULL, selection);
  if (returnValue == RTCAN || returnValue != RTNORM) return 0;
  
  long num = 0;
  returnValue = acedSSLength(selection, &num);
  if (returnValue == RTCAN || returnValue != RTNORM) return 0;
  if (num != 1) {
    acedSSSetFirst(NULL, NULL);
    
    returnValue = acedSSGet(L"_:S", NULL, NULL, NULL, selection);
    if (returnValue == RTCAN || returnValue != RTNORM) return 0;
    
    if (acedSSSetFirst(selection, NULL) != RTNORM) {
      acedSSFree(selection);
      return 0;
    }
  }
  ads_name element;
  acedSSName(selection, 0, element);
  acedSSFree(selection);
  
  AcDbObjectId idEntity;
  if (acdbGetObjectId(idEntity, element) != Acad::eOk) {
    acedSSFree(element);
    return 0;
  }

  acedSSFree(element);
  
  CCadEntity * cadEntity = CCadEntityFactory::GetCadEntity(idEntity);
  acutPrintf((L"\n" + cadEntity->GetData().ToFormattedString() + L"\n").c_str());
  delete cadEntity;
  
  return 1;
}
Beispiel #4
0
/*
 * 帮助文档中acedSSSetFirst以及acedSSGetFirst
 * 要求使用它的命令应该开启ACRX_CMD_USEPICKSET和ACRX_CMD_REDRAW选项
 * 但测试结果显示,貌似不使用也可以??????
 */
 bool ArxEntityHelper::SelectEntity( const AcDbObjectId& objId )
{
    //acedSSSetFirst(NULL, NULL);

    if( objId.isNull() ) return false;

    ads_name ename;
    if( Acad::eOk != acdbGetAdsName( ename, objId ) ) return false;;

    ads_name ss;
    if( RTNORM != acedSSAdd( ename, NULL, ss ) ) return false; // 创建选择集

    acedSSSetFirst( ss, NULL ); // 高亮选中
    acedSSFree( ss );           // 释放选择集

    return true;
}