AE实现点击一个要素,并显示其属性

第一步:根据鼠标点击处的点,找到被选中的要素

 1 public IFeature Find2(IPoint pPoint)
 2         {
 3             ITopologicalOperator pTopoOpe = pPoint as ITopologicalOperator;
 4             double dis = m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.FromPoints(5);
 5             if (dis < 0.01)
 6                 dis = 0.01;
 7             IGeometry pBuffer = pTopoOpe.Buffer(dis);
 8             pBuffer.SpatialReference = m_pMapControl.Map.SpatialReference;
 9 
10             UIDClass id = new UIDClass();
11             id.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"
  • 0
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以使用 ArcObjects 来获取图层中要素属性并更新属性表。下面是一些示例代码: 1. 获取要素属性: ```csharp // Open the feature class IFeatureClass featureClass = workspace.OpenFeatureClass("yourFeatureClassName"); // Create a query filter to select features IQueryFilter queryFilter = new QueryFilter(); queryFilter.WhereClause = "yourWhereClause"; // Use a cursor to retrieve the features IFeatureCursor featureCursor = featureClass.Search(queryFilter, false); // Loop through the features and retrieve the attribute values IFeature feature = featureCursor.NextFeature(); while (feature != null) { // Get the attribute values object attributeValue = feature.get_Value(feature.Fields.FindField("yourFieldName")); // Do something with the attribute value feature = featureCursor.NextFeature(); } // Clean up System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor); ``` 2. 更新属性表: ```csharp // Open the feature class IFeatureClass featureClass = workspace.OpenFeatureClass("yourFeatureClassName"); // Create a query filter to select features IQueryFilter queryFilter = new QueryFilter(); queryFilter.WhereClause = "yourWhereClause"; // Use a cursor to retrieve the features IFeatureCursor featureCursor = featureClass.Update(queryFilter, false); // Loop through the features and update the attribute values IFeature feature = featureCursor.NextFeature(); while (feature != null) { // Set the new attribute value feature.set_Value(feature.Fields.FindField("yourFieldName"), "yourNewValue"); // Update the feature featureCursor.UpdateFeature(feature); feature = featureCursor.NextFeature(); } // Clean up System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor); ``` 请注意,上述代码中的“workspace”可以是您的工作空间,例如,一个文件地理数据库或一个SDE连接。此外,您需要替换“yourFeatureClassName”和“yourFieldName”为实际的要素类和字段名称。最后,您需要提供一个有效的“where”子句来选择要处理的要素

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值