POST
|
i am a little confused are you just looking for code to pring the current date in .NET? you can pull what you need from here:
'Add Date
pPoint = New Point
If strLayoutType = "Landscape" Then
pPoint.PutCoords(10.35, 0.25)
Else
pPoint.PutCoords(7.85, 0.25)
End If
pAV = pMxDoc.PageLayout
pTextElement = New TextElement
pElement = pTextElement
pElement.Geometry = pPoint
Dim strDate As String = DateTime.Now.Month.ToString & "/" & DateTime.Now.Day.ToString & "/" & DateTime.Now.Year.ToString
myFont.Name = "Arial"
myFont.Size = 6
myTextSymbol.Font = myFont
myTextSymbol.HorizontalAlignment = ESRI.ArcGIS.Display.esriTextHorizontalAlignment.esriTHALeft
pTextElement.Text = strDate
pTextElement.Symbol = myTextSymbol
AddElement(pTextElement, pPoint, "Date")
do you still want to use VBA in 10? here is my same basic code that works in VBA in 10:
'Add Date
Set pPoint = New Point
If strLayoutType = "Landscape" Then
pPoint.PutCoords 9.9, 0.3
Else
pPoint.PutCoords 7.4, 0.3
End If
Set pAV = pMxDoc.PageLayout
Set pTextElement = New TextElement
Set pElement = pTextElement
pElement.Geometry = pPoint
strDate = Date
myFont.Name = "Arial"
myFont.size = 12
myTextSymbol.Font = myFont
myTextSymbol.HorizontalAlignment = esriTHALeft
pTextElement.Text = strDate
pTextElement.Symbol = myTextSymbol
AddElement pTextElement, pPoint, "Date"
so what you are using should work. hope that helps...
... View more
06-04-2012
06:17 AM
|
0
|
0
|
354
|
POST
|
hmmm, i can't get it to replicate the problem again this morning... probably user error. thanks again for your help, and the tip on proper sql query code indentation. max
... View more
03-16-2012
04:35 AM
|
0
|
0
|
138
|
POST
|
so i am liking query layers a lot so far in playing with them! my current question regards how keep the order i specify for the fields. here is a query i am working with as an example: SELECT sde2.sde.STREETCL_ARC.OBJECTID, sde2.sde.STREETCL_ARC.Shape, sde2.sde.STREETCL_ARC.SEG_ID, LTRIM(sde2.sde.STREETCL_ARC.PRE_DIR +' ' + sde2.sde.STREETCL_ARC.ST_NAME +' ' + sde2.sde.STREETCL_ARC.ST_TYPE) AS STREETNAME, sde2.sde.STREETCL_ARC.ST_CODE, sde2.sde.STREETCL_ARC.ONEWAY, sde2.sde.STREETCL_ARC.CLASS, sde2.sde.BIKE_NETWORK_TBL_NEW.TYPE FROM sde2.sde.STREETCL_ARC RIGHT OUTER JOIN sde2.sde.BIKE_NETWORK_TBL_NEW ON sde2.sde.STREETCL_ARC.seg_id = sde2.sde.BIKE_NETWORK_TBL_NEW.SEG_ID this makes a nice query layer with all the info i want HOWEVER if you notice i concatinate the field STREETNAME from a few fields. whenever the query layer is displayed this field shows up last. is there anyway to preserve the order i specify above (keep STREETNAME as the 4th column between SEG_ID and ST_CODE)? thanks, max
... View more
03-15-2012
10:37 AM
|
0
|
2
|
469
|
POST
|
so i am looking to replicate the "find unmatched query wizard" from microsoft access in python. basically i have 2 tables and i want to output all the records from the one table that do not match the records of the other table based on a common ID. in theory it seems simple enough but i can't figure out how to do it. any help would be greatly appreciated! thanks, max
... View more
08-11-2011
10:32 AM
|
0
|
3
|
5646
|
POST
|
have you tried steppping through your code to see the line it crashes on? if you haven't already done it; i suggest putting a breakpoint into your code very early (before it bombs) and then use the "step into" tool to go through line by line and figuring out specifically where it is breaking.
... View more
06-06-2011
11:11 AM
|
0
|
0
|
394
|
POST
|
so the legend never moves no matter what the putcoords are? my code for a creating/placing a legend (using putcoords to place it) is pretty long but i can post it up if it will help.
... View more
04-18-2011
11:08 AM
|
0
|
0
|
294
|
POST
|
one trick you can use to avoid custom symbology is to just change your selection color to the desired "custom" color and then just the selected polygon boundary to highlight your particular area of interest.
... View more
04-01-2011
07:24 AM
|
0
|
0
|
1706
|
POST
|
So I need the map position as well... i think i am not understanding what you are trying to do but; those coordinates should be the upper left corner of the map...
... View more
02-25-2011
02:48 AM
|
0
|
0
|
361
|
POST
|
try: My.ArcMap.Document.ActiveView.Extent.XMin My.ArcMap.Document.ActiveView.Extent.YMax
... View more
02-24-2011
08:15 AM
|
0
|
0
|
361
|
POST
|
jeff, that is a great tutorial! even though i am using .net most of the setup techniques you show are idenitcal between both languages. max
... View more
02-16-2011
07:38 AM
|
0
|
0
|
478
|
POST
|
not exactly what you need but you can probably modify it to make it work for you. here is some code that selects featureas and exports the table selection to a text file...
Private Sub MakeHighwayDistrictBoundaryLists()
'finds unique values from pData.Field value in Polygon Layer
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
Set pPointLayer = pDoc.FocusMap.Layer(0)
Set pPolyLayer = pDoc.FocusMap.Layer(10)
'Set Polygon Layer name for labelling output table
strLName = pPolyLayer.Name
strPolyVariable = "DISTRICT"
MakeList
End Sub
Private Sub MakeList()
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
Dim pMap As IMap
Set pMap = pDoc.FocusMap
Dim pData As IDataStatistics
Dim pCursor As ICursor
Dim pEnumVar As IEnumVariantSimple
Dim pTable As ITable
Set pTable = pPolyLayer
Set pCursor = pTable.Search(Nothing, False)
Set pData = New DataStatistics
pData.Field = strPolyVariable
Set pData.Cursor = pCursor
Set pEnumVar = pData.UniqueValues
Value = pEnumVar.Next
Dim DiagCollection As New Collection
Dim Inst
Do Until IsEmpty(Value)
If Value = " " Then
Value = pEnumVar.Next
Else
'Selects Polygon form pPolyLayer that match the variable Value
Dim pSelectedPoly As IFeatureSelection
Set pSelectedPoly = pPolyLayer 'QI
Dim strQuery As String
If strPolyVariable = "ZIPCODE" Or strPolyVariable = "SANAREA" Or strPolyVariable = "DISTRICT" Then
strQuery = strPolyVariable & " = " & Value
Else
strQuery = strPolyVariable & " = " & "'" & Value & "'"
End If
'Set Polygon Layer field value labelling output table; getting rid of losts of stuff for outputting a valid fieldname every time
strFName = Replace(Replace(Replace(Replace(Value, "Weekly Bag Service + ", ""), " ", "_"), ",", "_and"), "/", "_")
Dim pFilter As IQueryFilter
Set pFilter = New QueryFilter
pFilter.WhereClause = strQuery
pSelectedPoly.SelectFeatures pFilter, esriSelectionResultNew, False
'select all features in pPointLayer that intersect the selected features in pPolyLayer (selected using pSelectedPoly)
Dim pFCur As IFeatureCursor
Set pFCur = pPointLayer.FeatureClass.Search(Nothing, False)
Dim pFSel2 As IFeatureSelection
Set pFSel2 = pPointLayer
'get the selection set for layer 1 and the ids for the selected features
Dim pSelectionSet As ISelectionSet
Dim pFSel1 As IFeatureSelection
Set pFSel1 = pPolyLayer
Set pSelectionSet = pFSel1.SelectionSet
Dim pEnumIDs As IEnumIDs
Set pEnumIDs = pSelectionSet.IDs
Dim pGeoCollection As IGeometryCollection
Set pGeoCollection = New GeometryBag
Dim i As Long
For i = 1 To pSelectionSet.Count
pGeoCollection.AddGeometry pPolyLayer.FeatureClass.GetFeature(pEnumIDs.Next).Shape
Next i
Dim pSpatialFilter As ISpatialFilter
Set pSpatialFilter = New SpatialFilter
With pSpatialFilter
Set .Geometry = pGeoCollection
.GeometryField = "Shape"
.SpatialRel = esriSpatialRelContains
End With
pFSel2.SelectFeatures pSpatialFilter, esriSelectionResultNew, False
Dim pSelectionSet2 As ISelectionSet
Dim pFSelect2 As IFeatureSelection
Set pFSelect2 = pPointLayer
Set pSelectionSet2 = pFSelect2.SelectionSet
If pSelectionSet2.Count > 0 Then
ExportSelSetFeatureLayertoTable
End If
End If
Value = pEnumVar.Next
Loop
End Sub
Public Sub ExportSelSetFeatureLayertoTable()
Dim pDoc As IMxDocument
Dim pMap As IMap
Set pDoc = ThisDocument
Set pMap = pDoc.FocusMap
' Get the selected layer
Dim pTable As ITable
Dim pFLayer As IFeatureLayer
Dim pSelItem As IUnknown
Set pSelItem = pDoc.SelectedItem
If pSelItem Is Nothing Then
MsgBox "Please select a feature feature layer."
Exit Sub
ElseIf TypeOf pSelItem Is IFeatureLayer Then
Set pFLayer = pSelItem
Set pTable = pFLayer.FeatureClass
Else
MsgBox "Please select a feature feature layer."
Exit Sub
End If
'Confirm layer to be used with user
' Get the dataset name for the input table
Dim pDataset As IDataset
Dim pDSName As IDatasetName
Set pDataset = pTable
Set pDSName = pDataset.FullName
' Get the output dataset name ready. In this
' case we are creating a text file in c:\temp
Dim pWkSpFactory As IWorkspaceFactory
Dim pWkSp As IWorkspace
Dim pWkSpDS As IDataset
Dim pWkSpName As IWorkspaceName
Dim pOutDSName As IDatasetName
Dim lblnValidFile As Boolean
Dim strFileName As String, strFileLocation As String
strFileName = strLName & strFName & ".txt"
strFileLocation = "V:\temp\"
Set pWkSpFactory = New TextFileWorkspaceFactory
Set pWkSp = pWkSpFactory.OpenFromFile(strFileLocation, 0)
Set pWkSpDS = pWkSp
Set pWkSpName = pWkSpDS.FullName
Set pOutDSName = New TableName
pOutDSName.Name = strFileName
Set pOutDSName.WorkspaceName = pWkSpName
Dim pQueryFilter As IQueryFilter
Set pQueryFilter = New QueryFilter
Dim strField1 As String, strField2 As String, strField3 As String, strField4 As String, strField5 As String, strField6 As String, strField7 As String
strField1 = "NAME"
strField2 = "PHONE"
strField3 = "ADDRESS"
strField4 = "CITY"
strField5 = "STATE"
strField6 = "ZIP"
strField7 = "COUNTY"
'Checking table for required fields
Dim colTableFields As New Collection
colTableFields.Add strField1
colTableFields.Add strField2
colTableFields.Add strField3
colTableFields.Add strField4
colTableFields.Add strField5
colTableFields.Add strField6
colTableFields.Add strField7
Dim strcolTableFields As Variant, chkFieldExists As Long, strProblemMessage As String
For Each strcolTableFields In colTableFields
chkFieldExists = pTable.FindField(strcolTableFields)
If chkFieldExists = -1 Then
strProblemMessage = strProblemMessage & "Missing field in " & pDataset.Name & ": " & strcolTableFields & vbCrLf
End If
Next
If strProblemMessage <> "" Then
MsgBox "Problem with fields. " & vbCrLf & strProblemMessage
'End
' Stop
Exit Sub
End If
Dim strSubFields As String
'Once residential and commercial is implemented, strField7 should not be exported
strSubFields = strField1 & ", " & strField2 & ", " & strField3 & ", " & strField4 & ", " & strField5 & ", " & strField6 & ", " & strField7
pQueryFilter.SubFields = strSubFields
Dim pFeatureSel As IFeatureSelection
Set pFeatureSel = pFLayer
Dim pSelSet As ISelectionSet2
Set pSelSet = pFeatureSel.SelectionSet
' Export selected set of records to text file
Dim pExpOp As IExportOperation
Set pExpOp = New ExportOperation
pExpOp.ExportTable pDSName, pQueryFilter, pSelSet, pOutDSName, Application.hWnd
'Not required can comment out after debugging
' add the table to map
Dim pName As IName
Dim pNewTable
Dim pStTab As IStandaloneTable
Dim pStTabColl As IStandaloneTableCollection
Set pName = pOutDSName
Set pNewTable = pName.Open
Set pStTab = New StandaloneTable
Set pStTab.Table = pNewTable
Set pStTabColl = pMap
pStTabColl.AddStandaloneTable pStTab
pDoc.UpdateContents
End Sub
... View more
02-07-2011
06:06 AM
|
0
|
0
|
226
|
POST
|
Brian, thanks for your suggestions. luckily yesterday i was able to borrow one of our developers and painfully introduce him into how ArcGIS does vb.net anyhow after playing with it for most of the day we came up with a routine that will load the data into the combobox only once (which was tricky and required boolean to keep the code from running repeatedly) and then fire the other subroutine when a value was chosen. the sake of anyone lse trying this, i will post the initial code we finally came up with... but honestly i am not sure if this is the best wat of doing it.
Public Class CrewChiefSelect2
Inherits ESRI.ArcGIS.Desktop.AddIns.ComboBox
Private IsUpdate As Boolean = True
Private ListValue As String = String.Empty
Public Sub New()
End Sub
Protected Overrides Sub OnSelChange(ByVal cookie As Integer)
MyBase.OnSelChange(cookie)
ListValue = Me.Value
If Not (ListValue = String.Empty) Then
Update(ListValue)
End If
End Sub
Protected Overrides Sub OnUpdate()
Enabled = My.ArcMap.Application IsNot Nothing
If IsUpdate Then
LoadData()
IsUpdate = False
End If
End Sub
these call other subroutines, the one for the initial population of the dropdown LoadData, and then the Update subroutine that fires when a value is chosen from the dropdown. i can't believe it should require all this when it was so simple in VBA with just two routines one for the document open and the other for the selection change but hey at least it works. if anyone has a simpler way to get this done i would love to hear it. thanks, max
... View more
02-03-2011
03:00 AM
|
0
|
0
|
467
|
POST
|
hey everyone, i did recently get my first simple button module to work (sort of) with dotnet but now i am on to trying to get some other projects converted over from VBA... i am now trying to convert one of my old projects which uses a drop-down from VBA to .net and i must be missing something? here is the main chunk of the code (with a few of the subroutines left out since they don't seem relevant)
Imports ESRI.ArcGIS.ArcMapUI
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Catalog
Imports ESRI.ArcGIS.DataSourcesGDB
Imports ESRI.ArcGIS.DataSourcesFile
Imports ESRI.ArcGIS.DataSourcesRaster
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.SystemUI
Imports ESRI.ArcGIS.esriSystem
Public Class CrewChiefSelect
Inherits ESRI.ArcGIS.Desktop.AddIns.ComboBox
Public Sub New()
'Set Active Data Frame to "Main"
SetActiveDataFrame()
'Populates CrewChief combo box with values from CrewChief layer and sorts them
Dim pMxDoc As IMxDocument
pMxDoc = My.ArcMap.Document
Dim pMap As IMap
pMap = pMxDoc.FocusMap
Dim pLayer3 As IFeatureLayer
Dim pData As IDataStatistics
Dim pCursor As ICursor
Dim pEnumVar As IEnumVariantSimple
Dim value As Object
Dim pTable As ITable
Me.Clear()
'Pull information for dropdown box
pLayer3 = pMap.Layer(2)
pTable = pLayer3
pCursor = pTable.Search(Nothing, False)
Dim pRow As IRow
pData = New DataStatistics
'Dim DISDAYCC As String
pRow = pCursor.NextRow
pData = pRow.Value(6)
'pData.Field("DISDAYCC")
pData.Cursor = pCursor
pEnumVar = pData.UniqueValues
value = pEnumVar.Next
Dim DiagCollection As New Collection
'Dim Inst
Do Until IsNothing(value)
If value = " " Then
value = pEnumVar.Next
Else
DiagCollection.Add(CStr(value))
End If
value = pEnumVar.Next
Loop
'DiagCollection = SortCollection(DiagCollection)
For Each Item In DiagCollection
Me.Add(Item)
Next
End Sub
Protected Sub Update(ByVal newIndex As Long)
Enabled = My.ArcMap.Application IsNot Nothing
ClearAll()
AddLayers()
Dim pMxDoc As IMxDocument
pMxDoc = My.ArcMap.Document
Dim pMap As IMap
pMap = pMxDoc.FocusMap
Dim pLayout As IPageLayout
pLayout = pMxDoc.PageLayout
Dim pActiveView As IActiveView
pActiveView = pMap
'Query for selecting points in CrewChief boundary
Dim strQuery As String
strQuery = """DISDAYCC""" & " = " & "'" & Me.Value & "'"
'Set pLayer to 2nd CrewChief polygon Layer
Dim pLayer As IFeatureSelection
pLayer = pMap.Layer(2)
'Set pLayer2 to 1st CrewChief District polygon Layer
Dim pLayer2 As IFeatureLayerDefinition
pLayer2 = pMap.Layer(1)
'Selects queried polygon from CrewChief layer
Dim pFilter As IQueryFilter
pFilter = New QueryFilter
pFilter.WhereClause = strQuery
pLayer.SelectFeatures(pFilter, esriSelectionResultEnum.esriSelectionResultNew, False)
'
' Dim pBlueColor As IRgbColor
' Set pBlueColor = New RgbColor
' pBlueColor.RGB = RGB(0, 112, 225)
'
' Set pLayer.SelectionColor = pBlueColor
'Definition Query to Select CrewChief (Definition query to only display selected CrewChief boundary in the first crewchief layer so it thicker than other CrewChief boundaries)
pLayer2.DefinitionExpression = strQuery
'Selects queried Crewchief to zoom to the level of that selected CrewChief boundary
Dim pLayer3 As IFeatureLayer
pLayer3 = pMap.Layer(2)
Dim pFSel As IFeatureSelection
pFSel = pLayer3
Dim pSelSet As ISelectionSet
pSelSet = pFSel.SelectionSet
Dim pEnumGeom As IEnumGeometry
Dim pEnumGeomBind As IEnumGeometryBind
pEnumGeom = New EnumFeatureGeometry
pEnumGeomBind = pEnumGeom
pEnumGeomBind.BindGeometrySource(Nothing, pSelSet)
Dim pGeomFactory As IGeometryFactory
pGeomFactory = New GeometryEnvironment
Dim pGeom As IGeometry
pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom)
'Makes an envelope for selected features to determine proper page layout orientation
Dim pEnvelope As IEnvelope
pEnvelope = pGeom.Envelope
pEnvelope.XMax = pEnvelope.XMax + 100
pEnvelope.XMin = pEnvelope.XMin - 100
pEnvelope.YMax = pEnvelope.YMax + 100
pEnvelope.YMin = pEnvelope.YMin - 100
pMxDoc.ActiveView = pMap
pMxDoc.ActiveView.Extent = pEnvelope
'Determine the envelope ratio (for setting layout)
Dim intEnvelopeHeight As Long
intEnvelopeHeight = pEnvelope.YMax - pEnvelope.YMin
Dim intEnvelopeWidth As Long
intEnvelopeWidth = pEnvelope.XMax - pEnvelope.XMin
If intEnvelopeHeight > intEnvelopeWidth Then
strLayoutType = "Portrait"
ElseIf intEnvelopeHeight < intEnvelopeWidth Then
strLayoutType = "Landscape"
Else
strLayoutType = "Portrait"
End If
'Clear slection after zoom level is established
pMap.ClearSelection()
AddDataFrame()
AddTitle()
CreateAndAddNewMap()
InsertLogo()
ClearSelection()
End Sub
the code shows no errors when i debug it but when i add the drop-down into the arcmap project with the data it should reference it is grayed out... any help is much appreciated! thanks, max
... View more
02-01-2011
08:43 AM
|
0
|
5
|
3845
|
POST
|
thanks Jeff, But unfortunately that is not it... I have it on the least secure one. In looking around further, i did find this directory: C:\Documents and Settings\steinbm1\My Documents\ArcGIS\AddIns\Desktop10.0 there are a few folders in there that look have names like this: {b2112169-d8da-41c0-a979-7b34437506b8} within that folder is a file like this: arcmapaddin3.esriaddin for each of these files/folders in the directory a corresponding add-in is in my ArcMap add-in manager. unfortunately it just does not seem to make these directories regularly anymore when i create the add-ins through visual studio? in playing with it for most of the day yesterday i was able to get it to create another couple add-ins which did show up here (and therefore get put into the add-in manager) but it just doesn't seem to happen consistently anymore? any ideas on how to fix this would be great. thanks, max
... View more
01-27-2011
03:00 AM
|
0
|
0
|
137
|
POST
|
i have been playing with the add-in manager and visual studio and i am pretty sure i may have broken something. now when i create a new project in visual studio using the desktop add-in template the project no longer automatically shows up in the add-in manager in ArcMap. Is there a way to manually add the project so it shows up in the add-in manager or is there a way to "reset" something so that my desktop add-ins created in visual studio will automatically show up again? thanks, max
... View more
01-26-2011
03:26 AM
|
0
|
3
|
313
|
Title | Kudos | Posted |
---|---|---|
1 | 05-26-2016 09:06 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|