POST
|
Hi, we've got an in-house gis server. I bring in a layer but can't see it in Arcmap. When I go into the table of contents and uncheck "Enable Cache View Mode" then I can see it. I suppose I have to either do something to set up the cache, or else disable the cache view mode. I would like to do that programmatically. This doesn't seem to work: Dim pEnumLayer As IEnumLayer pEnumLayer = cmap.Layers pEnumLayer.Reset() Dim player As ILayer player = pEnumLayer.Next Do While Not player Is Nothing player.cached = false Msgbox(str(player.cached)) 'for some reason this is returning "4" player = pEnumLayer.Next Loop When this code is run the layer remains with "Enable Cache View Mode" checked.
... View more
10-05-2015
01:15 PM
|
0
|
1
|
2345
|
POST
|
This sort of works....I think I'm on the right track.... Dim pApp As IApplication = My.ArcMap.Application Dim pDoc As IMxDocument = My.ArcMap.Document Dim pGC As IGraphicsContainer = pDoc.PageLayout Dim pMaps As IMaps = pDoc.Maps Dim gcs As IGraphicsContainerSelect = pGC pGC.Reset() Dim pelt As IElement pelt = pGC.Next Dim pEltProp As IElementProperties Do While Not pelt Is Nothing pEltProp = pelt MsgBox(pEltProp.Name) If pEltProp.Name = "Inset" Then gcs.SelectElement(pelt) pGC.SendToBack(gcs.SelectedElements) End If pelt = pGC.Next Loop pDoc.ActiveView.Refresh() pDoc.UpdateContents() MsgBox("Done")
... View more
09-21-2015
11:55 AM
|
0
|
0
|
188
|
POST
|
I've got two different raster layers in different frames. The frames are at different scales. It doesn't seem to matter whether the one raster is listed first or second - it always draws on top. But I'd like to put it on the bottom - of course do this programmatically. I've fooled around with things like this: If pAV.IsMapActivated Then pDoc.ActiveView = aMap pGC.AddElement(qMapElement, 1) pGC.AddElement(pMapElement, 3) Else pAV.GraphicsContainer.AddElement(qMapElement, 1) pAV.GraphicsContainer.AddElement(pMapElement, 3) End If But they don't seem to help.....
... View more
09-21-2015
08:45 AM
|
0
|
1
|
2468
|
POST
|
Hi, I tried drawing a circle but this seems to be not quite a circle: Dim pCircleArc As IConstructCircularArc pCircleArc = New CircularArc pCircleArc.ConstructCircle(pOrigin,radius,True) Dim pPolygon As IPolygonpPolygon = New Polygon pPolygon.SpatialReference = pSpRef Dim pSegmentCollection As ISegmentCollection pSegmentCollection = pPolygon pSegmentCollection.AddSegment(pCircleArc) Dim pElement As IElementpElement = New PolygonElement pElement.Geometry = pPolygon Dim pFSElem As IFillShapeElement pFSElem = pElementpFSElem.Symbol = pSFSym Dim pGraphicsContainer As IGraphicsContainer pGraphicsContainer = bmap pGraphicsContainer.AddElement(pElement, -1) I thought to try another approach: Dim pMap As IMap pMap = pDoc.FocusMap Dim pSpRef As ISpatialReference pSpRef = pMap.SpatialReference Dim pPt As IPoint = New Point pPt.X = 0 pPt.Y = 0 pPt.SpatialReference = pSpRef Dim f As IFeature = New Feature f.Shape.SpatialReference = pSpRef f.Shape = pPt Dim topop As ESRI.ArcGIS.Geometry.ITopologicalOperator topop = f.shape Dim elt As ESRI.ArcGIS.Carto.PolygonElement elt = New PolygonElement elt.Geometry = topop.butter(24) Dim gc As IGraphicsContainer = pMap gc.AddElement(elt,0) The error I get is "All geometries involved in this operation must have the same spatial reference."
... View more
08-14-2015
09:29 AM
|
0
|
1
|
2292
|
POST
|
I think it is not but my boss doesn't believe me. Here's some standard code for making a PDF: Public Function createPDF() Dim pActiveView As IActiveView Dim pPixelBoundsEnv As IEnvelope = New Envelope Dim exportRECT As tagRECT = New tagRECT Dim iOutputResolution As Integer Dim iScreenResolution As Integer Dim hDC As Long Dim pMxDoc As IMxDocument = My.ArcMap.Application.Document Dim px1 As IExportPDF = New ExportPDF Dim px2 As IExportPDF2 = New ExportPDF Dim px3 As IExportPDF3 = New ExportPDF Dim pExport As IExport = New ExportPDF pExport.ExportFileName = "output.pdf" iScreenResolution = 96 iOutputResolution = 600 'Can some layers be at 300 dpi and others at 600 dpi? pExport.Resolution = iOutputResolution With exportRECT .left = 0 .top = 0 .right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution) .bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution) End With pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom) pExport.PixelBounds = pPixelBoundsEnv hDC = pExport.StartExporting pActiveView.Output(hdc,pExport.Resolution,exportRECT,Nothing, Nothing) pExport.FinishExporting() pExport.Cleanup() createPDF = 1 End Function -------------- Perhaps the purpose can be accomplished with px1.Compressed (I assume you would want px1.Compressed = true) px1.ImageCompression = (Adaptive, Deflate, JPEG, LZW, None, RLE) JPEG is lossy....Obviously with None you get no compression. LZW is lossless...not sure about Adaptive/Deflate/RLE px3.JPEGCompressionQuality - how much loss are you willing to tolerate in exchange for smaller file size? Now any of these would affect your layers equally, no?
... View more
04-15-2015
07:52 AM
|
0
|
0
|
2354
|
POST
|
Is it possible to refer to the Application/document in an add-in? I've successfully attached a dockable window to a button - now what do I do? It doesn't seem to like: Dim pMxDoc As IMxDocument = new MxDocument nor can you do: Dim pMxDoc As IMxDocument = m_application.Document or maybe you can but how do you set m_application in a dockable window? ANSWER: Add the lines in bold Private m_pApp As ESRI.ArcGIS.Framework.IApplication Public Sub New(ByVal hook As Object) ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. Me.Hook = hook m_pApp = hook End Sub ..... then down in your button_click do: Dim pMxDocument As IMxDocument = m_pApp.Document Thanks!
... View more
05-08-2013
09:04 AM
|
0
|
2
|
588
|
POST
|
My data is in lat/lon but I'd like my scalebar in miles. A rough estimate is good enough. I figure that if I take the latitudes of my extent, a degree of latitude is fairly constant. But it appears that no matter how I scale the data, the scalebar is ~2 inches long. Is it hard-coded that way? Here is a bare-bones version of my code: Dim pAV As IActiveView = pMxDocument.FocusMap Dim qEnvelope = pAV.Extent Dim yhi As Double = qEnvelope.YMax Dim ylo As Double = qEnvelope.YMin Dim ys As Double = (yhi - ylo) * 111195 / 1609 'we could quibble about this conversion Dim zs As Double = ys / 7.5 'map is landscape - runs from 8.0 to 0.5. Dim xs As Double = 1 + 120 / zs 'want 120 mile scale bar, starting at 1 inch. Dim envelope As ESRI.ArcGIS.Geometry.IEnvelope = New ESRI.ArcGIS.Geometry.EnvelopeClass envelope.PutCoords(1, 1, xs, 1.5) ' Specify the location and size of the scalebar Dim uid As ESRI.ArcGIS.esriSystem.IUID = New ESRI.ArcGIS.esriSystem.UIDClass uid.Value = "esriCarto.AlternatingScaleBar" ' Create a Surround. Set the geometry of the MapSurroundFrame to give it a location ' Activate it and add it to the PageLayout's graphics container Dim graphicsContainer As IGraphicsContainer = TryCast(pPageLayout, IGraphicsContainer) 'Carto: Dynamic Cast Dim activeView As IActiveView = TryCast(pPageLayout, IActiveView) ' Carto: Dynamic Cast Dim frameElement As IFrameElement = graphicsContainer.FindFrame(pMap) Dim mapFrame As IMapFrame = TryCast(frameElement, IMapFrame) ' Dynamic Cast Dim mapSurroundFrame As IMapSurroundFrame = mapFrame.CreateSurroundFrame(TryCast(uid, UID), Nothing) ' Dynamic Cast Dim mapSurround As IMapSurround = mapSurroundFrame.MapSurround Dim markerScaleBar As IScaleBar = (CType(mapSurround, IScaleBar)) ' Explicit Cast markerScaleBar.LabelPosition = ESRI.ArcGIS.Carto.esriVertPosEnum.esriBottom markerScaleBar.UseMapSettings() With markerScaleBar .Units = esriUnits.esriMiles .UnitLabel = "Miles" .UnitLabelGap = 6 'points .UnitLabelPosition = esriScaleBarPos.esriScaleBarBelow .UnitLabelSymbol = pUnitsTextSymbol .BarHeight = 5 'points .BarColor = pColor .Division = 30 'miles .Divisions = 4 ' 4 divisions + 1 before zero = 5 .Subdivisions = 2 ' 2 subdiv. shown => one subdiv. marks b/w each division mark .DivisionsBeforeZero = 0 .LabelSymbol = pLabelTextSymbol .LabelGap = 6 'points .LabelFrequency = esriScaleBarFrequency.esriScaleBarDivisions 'esriScaleBarDivisions ' place label on each division .NumberFormat = pNumericFormat .ResizeHint = esriScaleBarResizeHint.esriScaleBarAutoDivisionAndDivisions End With Dim element As ESRI.ArcGIS.Carto.IElement = TryCast(mapSurroundFrame, ESRI.ArcGIS.Carto.IElement) ' Dynamic Cast element.Geometry = envelope element.Activate(activeView.ScreenDisplay) graphicsContainer.AddElement(element, 0)
... View more
03-26-2013
11:42 AM
|
0
|
0
|
349
|
POST
|
It appears I need ESRI.ArcMap.Editor and ESRI.ArcMap.EditorExt as well.
... View more
03-26-2013
10:56 AM
|
0
|
0
|
145
|
POST
|
A workaround I found was: Dim pPage As IPage pPage = pMxDocument.PageLayout.Page pPage.PutCustomSize(11, 8.5)
... View more
03-26-2013
10:54 AM
|
0
|
0
|
620
|
POST
|
As some have pointed out, there are some things that cannot be done in a Windows Application (go into VB.net and create "Windows Application. You can launch ArcMap and load a shapefile but not color it.) So you need a Class Library. Is there some way to attach a form to a class library? I need some user input. I tried using the form in the Windows Application, then writing a shapefile in the Windows Application then reading it back in in the Class Library. That seems to not work.
... View more
03-22-2013
01:25 PM
|
0
|
1
|
425
|
POST
|
I figured it out...sort of.... Use seriesprops.LabelField - this puts the value of the bar and number of observations on the bar's mark also (not sure if that's a bug or a feature).
... View more
03-22-2013
01:20 PM
|
0
|
0
|
203
|
POST
|
I've fought with it all day...perhaps it is not possible. Other question: how can I get the x-axis as character labels instead of numbers? Are my labels too wide? Dim pdatagraph As IDataGraphT = New DataGraphTClass Dim seriesprops As ISeriesProperties = pdatagraph.AddSeries("bar:vertical") seriesprops.SourceData = pTable seriesprops.SetField(0, "YrMo") seriesprops.SetField(1, "Number") Instead of getting 2012_09 (or even 12_09) for my bar labels, I'm getting numbers....1 for the 1st bar, 2 for the 2nd, etc.
... View more
03-21-2013
12:23 PM
|
0
|
0
|
203
|
POST
|
I don't know if it's possible....it is in regular ArcMap. But I have my doubts it is possible in ArcObjects. ==================================================================== Dim pdatagraph As IDataGraphT = New DataGraphTClass Dim seriesprops As ISeriesProperties = pdatagraph.AddSeries("bar:vertical") seriesprops.SourceData = pTable seriesprops.SetField(0, "YrMo") seriesprops.SetField(1, "Number") seriesprops = pdatagraph.AddSeries("line:vertical") seriesprops.SourceData = pTable seriesprops.SetField(1, "Prod") pdatagraph.GeneralProperties.Show3D = True 'This gets me 3D bars and a 3D line. pdatagraph.Update(Nothing) pdatagraph.ExportToFile("f:\states\graph.jpg") ============================================================== I'll try it again tomorrow.
... View more
03-20-2013
02:10 PM
|
0
|
2
|
443
|
POST
|
Is there a way to get rid of the dotted line? I'm trying to get a landscape layout but there's that leftover portrait dotted line. I don't know what it's called. Apparently, it's not the MapFrame. See dotline.jpg below. Dim doc As IDocument = New MxDocument Dim pMxDocument As IMxDocument = doc m_application = doc.Parent m_application.Visible = True m_appHWnd = m_application.hWnd pMxDocument.ActiveView = pMxDocument.PageLayout pMxDocument.PageLayout.Page.Orientation = 2 Dim GC As IGraphicsContainer = TryCast(pMxDocument.PageLayout, IGraphicsContainer) Dim pElement As IElement = GC.FindFrame(pMxDocument.FocusMap) Dim pMapFrame As IMapFrame = GC.FindFrame(pMxDocument.FocusMap) pMapFrame.RemoveAllLocatorRectangles() GC.DeleteElement(pMapFrame) GC.DeleteAllElements() Dim pEnvelope As IEnvelope = New Envelope pEnvelope.PutCoords(1, 1, 10, 7.5) pElement.Geometry = pEnvelope GC.AddElement(pElement, 0) pMxDocument.UpdateContents() pMxDocument.ActiveView.Refresh()
... View more
03-08-2013
09:02 AM
|
0
|
3
|
975
|
POST
|
Ewan Middleton's solution in VBA seems to not work in VB.net. http://forums.esri.com/Thread.asp?c=93&f=992&t=57798 It gets hung up on ITableFrame. Is there an Imports statement I need to use?
... View more
02-25-2013
10:17 AM
|
0
|
2
|
396
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|