POST
|
Hi, Could someone tell me how to retrieve the Feature Class name for each layer in an MXD? I tried this: MapControlClass mapControl = new ESRI.ArcGIS.MapControl.MapControlClass(); mapControl.LoadMxFile(filename,null,null); ESRI.ArcGIS.Carto.IFeatureLayer layer = (ESRI.ArcGIS.Carto.IFeatureLayer)mapControl.get_Layer(1) as ESRI.ArcGIS.Carto.IFeatureLayer; But the Feature Class property is null? ESRI.ArcGIS.Carto.IFeatureLayer ptestLayer = mapcontl.FocusMap.get_Layer(1).Name; Thanks and Regards, Venkat
... View more
12-09-2010
09:34 PM
|
0
|
0
|
220
|
POST
|
Thanks a lot... It was my answer.. can u help me in one more thing.... if i want to select feature on mousedown event---> first,i created a point,then i buffered it. now i need to check whether this point intersects with any other feature(i have a polyline shapefile also) If it does intersect then that line shud be selected.... I used spatial filter but it returns null value can u check the code please: public void OnMouseDown(int button, int shift, int x, int y) { // # region attribute activeView = m_mxDoc.ActiveView; IPoint ppoint = new PointClass(); ppoint = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); ITopologicalOperator topologicalOperator = ppoint as ITopologicalOperator; IGeometry gm = topologicalOperator.Buffer(1); ISpatialFilter spatialFilter = new SpatialFilterClass(); IMap map = activeView.FocusMap; pageLayout = (PageLayout)m_mxDoc.PageLayout; l1 = map.get_Layer(0); l2 = map.get_Layer(1); if (l1.Name == "SSE_Access") { layer_working = l1; } else if (l2.Name == "SSE_Access") { layer_working = l2; } else { layer_working = null; MessageBox.Show("Layer for attribute information does not exists"); } IFeatureLayer pfl = (IFeatureLayer)layer_working; IFeatureClass featureClass = pfl.FeatureClass; spatialFilter.GeometryField = featureClass.ShapeFieldName; spatialFilter.Geometry = gm; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureCursor featureCursor1 = featureClass.Search(spatialFilter, true); IFeature Feat1 = featureCursor1.NextFeature(); while (Feat1 != null) { map.SelectFeature(layer_working, Feat1); Feat1 = featureCursor1.NextFeature(); } thanks in adv. hi, Please can you post the complete code what suppose to use .. where you getting error.... Thanks and Regards, Venkat Tammineni
... View more
12-09-2010
09:08 PM
|
0
|
0
|
537
|
POST
|
I m working in C++ .. and little bit experience in C#..... I want to start Arc ob.. in C# ..... Hi, You need to learn first .NET...then you can easily work with arcobjects .net... Thanks and Regards, Venkat
... View more
12-09-2010
07:44 PM
|
0
|
0
|
386
|
POST
|
thank you for so much, actually i need it to be written in VBA-Arcobjects not in any other language. have you any idea how to do it in VBA-Arcobjects ? where can i find examples of similar kind of work? thank you regards Jamal Hi, please check below code... Sub test() Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument Dim pPolyFLayer As IFeatureLayer Set pPolyFLayer = pMxDoc.FocusMap.Layer(1) Dim pPointFlayer As IFeatureLayer Set pPointFlayer = pMxDoc.FocusMap.Layer(0) Dim pEditor As IEditor, pUID As New UID pUID.Value = "esricore.Editor" Set pEditor = Application.FindExtensionByCLSID(pUID) If pEditor.EditState = esriStateEditing Then pEditor.StartOperation CountFeatures pPolyFLayer.FeatureClass, pPointFlayer.FeatureClass, _ esriSpatialRelContains, "NAME" pEditor.StopOperation "PolygonDensity" Else MsgBox "no edit session" End If End Sub Sub CountFeatures(pFC1 As IFeatureClass, _ pFC2 As IFeatureClass, _ lSpatialRel As esriSpatialRelEnum, _ strCountFld As String) Dim pFCur As IFeatureCursor Set pFCur = pFC1.Search(Nothing, False) Dim lFld As Long lFld = pFC1.FindField(strCountFld) If lFld = -1 Then MsgBox "field not found: " & strCountFld Exit Sub End If Dim pFeat As IFeature Set pFeat = pFCur.NextFeature Do While Not pFeat Is Nothing Dim pSF As ISpatialFilter Set pSF = New SpatialFilter Set pSF.Geometry = pFeat.ShapeCopy pSF.SpatialRel = lSpatialRel pSF.GeometryField = pFC2.ShapeFieldName pFeat.Value(lFld) = pFC2.FeatureCount(pSF) MsgBox "OID: " & pFeat.OID & ", count: " & pFeat.Value(lFld) pFeat.Store Set pFeat = pFCur.NextFeature Loop End Sub is that your looking for ?... Thanks and Regards, Venkat
... View more
12-09-2010
07:42 PM
|
0
|
0
|
483
|
POST
|
Hi, Please find the code.... using System; using System.Drawing; using System.Runtime.InteropServices; using ESRI.ArcGIS.ADF.BaseClasses; using ESRI.ArcGIS.ADF.CATIDs; using ESRI.ArcGIS.Framework; using ESRI.ArcGIS.ArcMapUI; namespace CountPoints { /// <summary> /// Summary description for InsertPic. /// </summary> [Guid("b311d914-e999-4014-8bcb-2cef2da34b71")] [ClassInterface(ClassInterfaceType.None)] [ProgId("CountPoints.InsertPic")] public sealed class InsertPic : BaseCommand { #region COM Registration Function(s) [ComRegisterFunction()] [ComVisible(false)] static void RegisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryRegistration(registerType); // // TODO: Add any COM registration code here // } [ComUnregisterFunction()] [ComVisible(false)] static void UnregisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryUnregistration(registerType); // // TODO: Add any COM unregistration code here // } #region ArcGIS Component Category Registrar generated code /// <summary> /// Required method for ArcGIS Component Category registration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryRegistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); MxCommands.Register(regKey); } /// <summary> /// Required method for ArcGIS Component Category unregistration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryUnregistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); MxCommands.Unregister(regKey); } #endregion #endregion private IApplication m_application; public InsertPic() { // // TODO: Define values for the public properties // base.m_category = "PageLayout"; //localizable text base.m_caption = "Insert Pic"; //localizable text base.m_message = "Insert Picture into Pagelayout"; //localizable text base.m_toolTip = "Insert Picture into Pagelayout"; //localizable text base.m_name = "Insert_pic"; //unique id, non-localizable (e.g. "MyCategory_ArcMapCommand") try { // // TODO: change bitmap name if necessary // string bitmapResourceName = GetType().Name + ".bmp"; base.m_bitmap = new Bitmap(GetType(), bitmapResourceName); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap"); } } #region Overriden Class Methods /// <summary> /// Occurs when this command is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { if (hook == null) return; m_application = hook as IApplication; //Disable if it is not ArcMap if (hook is IMxApplication) base.m_enabled = true; else base.m_enabled = false; // TODO: Add other initialization code } /// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // TODO: Add InsertPic.OnClick implementation IMxDocument pMxDoc = m_application.Document as IMxDocument; ESRI.ArcGIS.Carto.IPictureElement pPictureElement; pPictureElement = new ESRI.ArcGIS.Carto.JpgPictureElementClass(); pPictureElement.ImportPictureFromFile(@"D:\PROJECTS\MyProject\Images\Excel2.jpg"); ESRI.ArcGIS.Geometry.IEnvelope pEnv = new ESRI.ArcGIS.Geometry.EnvelopeClass(); pEnv.PutCoords(1, 1, 5, 5); ESRI.ArcGIS.Carto.IElement pElement; pElement = pPictureElement as ESRI.ArcGIS.Carto.IElement; pElement.Geometry = pEnv; ESRI.ArcGIS.Carto.IGraphicsContainer pGraphicContainer; pGraphicContainer = pMxDoc.PageLayout as ESRI.ArcGIS.Carto.IGraphicsContainer; pGraphicContainer.AddElement(pElement, 0); ESRI.ArcGIS.Carto.IActiveView pActiveView; pActiveView = pGraphicContainer as ESRI.ArcGIS.Carto.IActiveView; pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGraphics, pElement, pEnv); } #endregion } } I hope this helps you... Thanks and Regards, Venkat
... View more
12-08-2010
11:56 PM
|
0
|
0
|
537
|
POST
|
Hi, Either you have to specify workspace if that one is available with you...or make it null. Something like this.... ESRI.ArcGIS.Geodatabase.IQueryFilter qf = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); qf.WhereClause = "Name='moscow'"; layer.FeatureClass.Select(qf, ESRI.ArcGIS.Geodatabase.esriSelectionType.esriSelectionTypeIDSet, ESRI.ArcGIS.Geodatabase.esriSelectionOption.esriSelectionOptionNormal, null); Thanks and Regards
... View more
12-08-2010
11:22 PM
|
0
|
0
|
356
|
POST
|
I want the code in c# please help.its urgent Can you please explain your task....
... View more
12-08-2010
08:25 PM
|
0
|
0
|
537
|
POST
|
Hi, Please find below code working fine for me...points count will be added into polygon layer ...updated into given filed..... using System; using System.Drawing; using System.Runtime.InteropServices; namespace CountPoints { /// <summary> /// Summary description for CountAllPoints. /// </summary> [Guid("96ac8c8b-1a7c-457d-aa69-dcdcba6034f2")] [ClassInterface(ClassInterfaceType.None)] [ProgId("CountPoints.CountAllPoints")] public sealed class CountAllPoints : ESRI.ArcGIS.ADF.BaseClasses.BaseCommand { #region COM Registration Function(s) [ComRegisterFunction()] [ComVisible(false)] static void RegisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryRegistration(registerType); // // TODO: Add any COM registration code here // } [ComUnregisterFunction()] [ComVisible(false)] static void UnregisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryUnregistration(registerType); // // TODO: Add any COM unregistration code here // } #region ArcGIS Component Category Registrar generated code /// <summary> /// Required method for ArcGIS Component Category registration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryRegistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); ESRI.ArcGIS.ADF.CATIDs.MxCommands.Register(regKey); } /// <summary> /// Required method for ArcGIS Component Category unregistration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryUnregistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); ESRI.ArcGIS.ADF.CATIDs.MxCommands.Unregister(regKey); } #endregion #endregion private ESRI.ArcGIS.Framework.IApplication m_application; public CountAllPoints() { // // TODO: Define values for the public properties // base.m_category = "Spatial Analsis"; //localizable text base.m_caption = "Spatial Analsis"; //localizable text base.m_message = "Counts the point inside the polygon"; //localizable text base.m_toolTip = "Counts the point inside the polygon"; //localizable text base.m_name = "Spatial_Points_Inside_Polygon"; //unique id, non-localizable (e.g. "MyCategory_ArcMapCommand") try { // // TODO: change bitmap name if necessary // string bitmapResourceName = GetType().Name + ".gif"; base.m_bitmap = new Bitmap(GetType(), bitmapResourceName); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap"); } } #region Overriden Class Methods /// <summary> /// Occurs when this command is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { if (hook == null) return; m_application = hook as ESRI.ArcGIS.Framework.IApplication; //Disable if it is not ArcMap if (hook is ESRI.ArcGIS.ArcMapUI.IMxApplication) base.m_enabled = true; else base.m_enabled = false; // TODO: Add other initialization code } /// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // TODO: Add CountAllPoints.OnClick implementation ESRI.ArcGIS.ArcMapUI.IMxDocument pMxDoc = m_application.Document as ESRI.ArcGIS.ArcMapUI.IMxDocument; ESRI.ArcGIS.Carto.IFeatureLayer pPolygonLayer = pMxDoc.FocusMap.get_Layer(1) as ESRI.ArcGIS.Carto.IFeatureLayer; ESRI.ArcGIS.Carto.IFeatureLayer pPointLayer = pMxDoc.ActiveView.FocusMap.get_Layer(0) as ESRI.ArcGIS.Carto.IFeatureLayer; ESRI.ArcGIS.Editor.IEditor pEditor; ESRI.ArcGIS.esriSystem.UID pUID = new ESRI.ArcGIS.esriSystem.UIDClass(); pUID.Value = "esricore.Editor"; pEditor = m_application.FindExtensionByCLSID(pUID) as ESRI.ArcGIS.Editor.IEditor; if(pEditor.EditState == ESRI.ArcGIS.Editor.esriEditState.esriStateEditing ) { pEditor.StartOperation(); GetAllPoitsInsidePolygon(pPolygonLayer.FeatureClass, pPointLayer.FeatureClass, ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelContains, "TVSID");//TVSID is filed name whihc should be in the poly layer pEditor.StopOperation("PolygonDensity"); } else { System.Windows.Forms.MessageBox.Show("Not in edit session"); } } private void GetAllPoitsInsidePolygon(ESRI.ArcGIS.Geodatabase.IFeatureClass pFeatureClass1,ESRI.ArcGIS.Geodatabase.IFeatureClass pFeatClass2,ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum lSpatialRel,String strFeatFld) { ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatCursor = pFeatureClass1.Search(null,false); int lFld=0; lFld = pFeatureClass1.FindField(strFeatFld); if(lFld == -1) { System.Windows.Forms.MessageBox.Show("field not found: " + strFeatFld); return; } ESRI.ArcGIS.Geodatabase.IFeature pFeature = pFeatCursor.NextFeature(); while (pFeature != null) { ESRI.ArcGIS.Geodatabase.ISpatialFilter pSpatialFilter = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass(); pSpatialFilter.Geometry = pFeature.ShapeCopy; pSpatialFilter.SpatialRel = lSpatialRel; pSpatialFilter.GeometryField = pFeatClass2.ShapeFieldName; pFeature.set_Value(lFld,pFeatClass2.FeatureCount(pSpatialFilter)); System.Windows.Forms.MessageBox.Show("OID: " + pFeature.OID + ", count: " + pFeature.get_Value(lFld)); pFeature.Store(); pFeature = pFeatCursor.NextFeature(); } } #endregion } } I hope this helps you.... Thanks and Regards, Venkat Tammineni
... View more
12-08-2010
08:19 PM
|
0
|
0
|
483
|
POST
|
Hi please tell me ,how should I proceed on learning arc objects (C#)...!! Do you have C# knowledge ?
... View more
12-08-2010
07:06 PM
|
0
|
0
|
386
|
POST
|
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:esri="http://www.esri.com/2008/ags" xmlns:s="library://ns.adobe.com/flex/spark" pageTitle="Printing with Flex"> <!-- This sample shows you how to print a map. --> <s:layout> <s:VerticalLayout horizontalAlign="center" paddingBottom="20" paddingLeft="20" paddingRight="20" paddingTop="20"/> </s:layout> <fx:Script> <![CDATA[ import mx.printing.FlexPrintJobScaleType; import mx.printing.FlexPrintJob; import mx.controls.Alert; private function doPrint(myFlexPrintJobScaleType:String):void { // Create an instance of the FlexPrintJob class. var myPrintJob:FlexPrintJob = new FlexPrintJob(); // Start the print job. if (myPrintJob.start()) { try { // hide the zoom slider so it won't be printed myMap.zoomSliderVisible = false; // Add the panel to print. myPrintJob.addObject(myPanel, myFlexPrintJobScaleType); // turn the zoom slider back on myMap.zoomSliderVisible = true; } catch (error:Error) { Alert.show(error.toString()); } // Send the job to the printer. myPrintJob.send(); } } ]]> </fx:Script> <s:HGroup horizontalAlign="center"> <s:Button click="doPrint(FlexPrintJobScaleType.NONE)" label="Print (without scaling)"/> <s:Button click="doPrint(FlexPrintJobScaleType.SHOW_ALL)" label="Print (fit on one page)"/> </s:HGroup> <s:Panel id="myPanel" width="100%" height="100%" title="Print Map"> <esri:Map id="myMap"> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/> </esri:Map> </s:Panel> <mx:Text htmlText="Read more about <u><a href='http://livedocs.adobe.com/flex/3/langref/mx/printing/package-detail.html' target='_blank' >Flex printing</a></u>."/> </s:Application> Check above code ...that might help you.
... View more
12-08-2010
01:25 AM
|
0
|
0
|
998
|
POST
|
Hi, you want to customize only context menu or you want to customize items from the context menu ?
... View more
12-07-2010
09:30 PM
|
0
|
0
|
195
|
POST
|
I know, but it is up to the user of my tool what names he uses. My tool must be able to handle layers with equal names. See...handling same layers name is not an issue...only thing is how user can feel good to use...what he suppose to select if he wants to see the building or something...why he suppose to check all building layers ?
... View more
12-07-2010
09:09 PM
|
0
|
0
|
227
|
POST
|
Hi, Please find the code...working public override void OnClick() { try { IMxDocument pMxDoc = m_application.Document as IMxDocument; IActiveView pActiveView; pActiveView = pMxDoc.PageLayout as IActiveView; IGraphicsContainer pGraphicsContainer; IMapFrame pMapFrame; pGraphicsContainer = pMxDoc.PageLayout as IGraphicsContainer; pMapFrame = pGraphicsContainer.FindFrame(pMxDoc.FocusMap) as IMapFrame; IMapSurroundFrame pMapSurroundFrame; UID pUID = new UIDClass(); IElement pElement; pUID.Value = "esriCarto.Legend"; pMapSurroundFrame = pMapFrame.CreateSurroundFrame(pUID, null); pMapSurroundFrame.MapSurround.Name = "Legend"; pElement = pMapSurroundFrame as IElement; IElement pMainMapElement; IEnvelope pMainEnv; pMainMapElement = pMapFrame as IElement; pMainEnv = pMainMapElement.Geometry.Envelope; IEnvelope pEnv = new EnvelopeClass(); pEnv.PutCoords(pMainEnv.XMax + 1.5, pMainEnv.YMin + 1.5, pMainEnv.XMax - 1.5, pMainEnv.YMax - 1.5); pElement.Geometry = pEnv; pElement.Activate(pActiveView.ScreenDisplay); pGraphicsContainer.AddElement(pElement, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); pActiveView.Refresh(); } catch (Exception exe) { } } Thanks and Regards, Venkat
... View more
12-07-2010
09:04 PM
|
0
|
0
|
144
|
Title | Kudos | Posted |
---|---|---|
1 | 10-09-2017 07:44 AM | |
2 | 01-12-2015 10:36 PM | |
1 | 01-15-2015 09:02 AM | |
2 | 09-29-2014 02:29 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|