YouTube | Facebook | X(Twitter) | RSS

Engine でスケッチに対してスナップを設定する方法

2016/9/1 (木)

' http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/SnapEditorForm/0048000000m7000000/
 
'/ <summary>
'/ Turns on or turns off the Edit Sketch snap agents by adding or removing them
'/ </summary>
Private Sub AddSketchSnapAgents()
  'give anchor snap (i.e. vertex snap) priority to get more accurate snap tips while snapped to a vertex
  Dim t As Type = Type.GetTypeFromProgID("esriControls.EngineAnchorSnap")
  Dim obj As System.Object = Activator.CreateInstance(t)
  Dim snapAgent As IEngineSnapAgent = DirectCast(obj, IEngineSnapAgent)
  snapEnvironment.AddSnapAgent(snapAgent)
 
  'edge sketch edges
  t = Type.GetTypeFromProgID("esriControls.EngineSketchSnap")
  obj = Activator.CreateInstance(t)
  snapAgent = DirectCast(obj, IEngineSnapAgent)
  snapEnvironment.AddSnapAgent(snapAgent)
 
  'perpendicular to edit sketch
  t = Type.GetTypeFromProgID("esriControls.EnginePerpendicularSnap")
  obj = Activator.CreateInstance(t)
  snapAgent = DirectCast(obj, IEngineSnapAgent)
  snapEnvironment.AddSnapAgent(snapAgent)
End Sub
 
 
/// <summary>
/// Adds, and hence turns on, Edit Sketch snap agents
/// </summary>
private void AddSketchSnapAgents()
{
  //give anchor snap (i.e. vertex snap) priority to get more accurate snap tips while snapped to a vertex
  Type t = Type.GetTypeFromProgID("esriControls.EngineAnchorSnap");
  System.Object obj = Activator.CreateInstance(t);
  IEngineSnapAgent snapAgent = (IEngineSnapAgent)obj;
  snapEnvironment.AddSnapAgent(snapAgent);
 
  //edge sketch edges
  t = Type.GetTypeFromProgID("esriControls.EngineSketchSnap");
  obj = Activator.CreateInstance(t);
  snapAgent = (IEngineSnapAgent)obj;
  snapEnvironment.AddSnapAgent(snapAgent);
 
  //perpendicular to edit sketch
  t = Type.GetTypeFromProgID("esriControls.EnginePerpendicularSnap");
  obj = Activator.CreateInstance(t);
  snapAgent = (IEngineSnapAgent)obj;
  snapEnvironment.AddSnapAgent(snapAgent);
}
  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『"地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

-プログラミング, ArcGIS
-,