|
POST
|
I am using 10.1 sp1. Protected Overrides Sub OnClick() Implements ESRI.ArcGIS.SystemUI.ICommand.OnClick
Dim pMxDoc As IMxDocument = TryCast(My.ArcMap.Application.Document, IMxDocument)
Dim enumFeatureSetup As IEnumFeatureSetup
Dim shape As String
If pMxDoc Is Nothing Then
Return
End If
Dim pMap As IMap = pMxDoc.FocusMap
Dim pEF As IEnumFeature = pMap.FeatureSelection
enumFeatureSetup = pEF
enumFeatureSetup.AllFields = True
Dim pFeat As IFeature = pEF.Next
If pFeat Is Nothing Then
Exit Sub
End If
Dim fields As IFields
fields = pFeat.Fields
Dim fieldCount As Integer = 0
Dim field, ffield As IField
Dim IDvalue, Lvalue, Mvalue, Rvalue As String
Dim Ovalue As Integer
Dim StrArray() As String = {"speedsigns", "intersections", "unpaved", "rumble", "paved", "medians", "lanes", "lighting", "location"}
Do While pFeat IsNot Nothing
If Array.IndexOf(StrArray, pFeat.Class.AliasName) = -1 Then
Do Until fieldCount = fields.FieldCount
field = pFeat.Fields.Field(fieldCount)
If field.Name = "RandomID" Then
IDvalue = pFeat.Value(fieldCount)
ElseIf field.Name = "Lighting" Then
Lvalue = pFeat.Value(fieldCount)
ElseIf field.Name = "RumbleStri" Then
Rvalue = pFeat.Value(fieldCount)
ElseIf field.Name = "Median" Then
Mvalue = pFeat.Value(fieldCount)
ElseIf field.Name = "OBJECTID" Then
Ovalue = pFeat.Value(fieldCount)
End If
fieldCount += 1
Loop
Exit Do
End If
pFeat = pEF.Next
Loop
pEF = pMap.FeatureSelection
enumFeatureSetup = pEF
enumFeatureSetup.AllFields = True
pFeat = pEF.Next
Dim commandItem As ICommandItem
Dim commandBars As ICommandBars
commandBars = My.ArcMap.Application.Document.CommandBars
commandItem = commandBars.Find(My.ThisAddIn.IDs.ArcGISAddin1, True, False)
Dim workspacePath As String = ArcMapAddin1.ArcGISAddin3.val
Dim workspaceFactory As IWorkspaceFactory
Dim workspace As IWorkspace
Try
workspaceFactory = DirectCast(Activator.CreateInstance(Type.GetTypeFromProgID("esriDataSourcesGDB.AccessWorkspaceFactory")), IWorkspaceFactory)
workspace = workspaceFactory.OpenFromFile(workspacePath, My.ArcMap.Application.hWnd)
Catch ex As Exception
MsgBox("Database Not Found")
Exit Sub
End Try
Dim rset As String = "hold"
Dim fieldcount2 As Integer
pFeat = pEF.Next
shape = ArcMapAddin1.ArcGISAddin1.val
Dim outputSignDetailTable As ITable
Dim tableBuffer As IRowBuffer
Dim row As IRow
Dim feature As IRowBuffer
Dim pEF2 As IEnumFeature = pMap.FeatureSelection
Dim enumFeatureSetup2 As IEnumFeatureSetup
enumFeatureSetup2 = pEF2
enumFeatureSetup2.AllFields = True
Dim pFeat2 As IFeature = pEF2.Next
Dim speedsigns As Integer = 0
Dim intersections As Integer = 0
Dim unpaved As Integer = 0
Dim rumble As Integer = 0
Dim paved As Integer = 0
Dim medians As Integer = 0
Dim lanes As Integer = 0
Dim lighting As Integer = 0
Dim location As Integer = 0
Do While pFeat2 IsNot Nothing
If pFeat2.Class.AliasName = "speedsigns" Then
speedsigns += 1
ElseIf pFeat2.Class.AliasName = "intersections" Then
intersections += 1
ElseIf pFeat2.Class.AliasName = "unpaved" Then
unpaved += 1
ElseIf pFeat2.Class.AliasName = "rumble" Then
rumble += 1
ElseIf pFeat2.Class.AliasName = "paved" Then
paved += 1
ElseIf pFeat2.Class.AliasName = "medians" Then
medians += 1
ElseIf pFeat2.Class.AliasName = "lanes" Then
lanes += 1
ElseIf pFeat2.Class.AliasName = "lighting" Then
lighting += 1
ElseIf pFeat2.Class.AliasName = "location" Then
location += 1
End If
pFeat2 = pEF2.Next()
Loop
Dim iii As Integer
pEF = pMap.FeatureSelection
enumFeatureSetup = pEF
enumFeatureSetup.AllFields = True
pFeat = pEF.Next
pFeat = pEF.Next
Dim tableInsertCursor As ICursor
Dim newOID As Object
Do While pFeat IsNot Nothing
If shape = pFeat.Class.AliasName Then
outputSignDetailTable = DirectCast(workspace, IFeatureWorkspace).OpenTable(shape)
tableBuffer = outputSignDetailTable.CreateRowBuffer()
row = CType(tableBuffer, IRow)
feature = tableBuffer
tableInsertCursor = outputSignDetailTable.InsertRow(True)
feature.Value(0) = IDvalue
feature.Value(1) = Ovalue
fieldcount2 = 1
Do Until fieldcount2 = pFeat.Fields.FieldCount
iii = 0
Do While iii < outputSignDetailTable.Fields.FieldCount
ffield = outputSignDetailTable.Fields.Field(iii)
If ffield.AliasName = pFeat.Fields.Field(fieldcount2).AliasName Then
feature.Value(iii) = pFeat.Value(fieldcount2)
Exit Do
End If
iii += 1
Loop
fieldcount2 += 1
Loop
If shape = "rumble" Then
fieldcount2 += 1
If rset = "hold" Then
If MsgBox("Are these rumble strips a set?", vbYesNo) = vbYes Then
rset = "yes"
iii = 0
Do While iii < outputSignDetailTable.Fields.FieldCount
ffield = outputSignDetailTable.Fields.Field(iii)
If ffield.AliasName = "Set" Then
feature.Value(iii) = "SET"
Exit Do
End If
iii += 1
Loop
Else
rset = "no"
End If
ElseIf rset = "yes" Then
iii = 0
Do While iii < outputSignDetailTable.Fields.FieldCount
ffield = outputSignDetailTable.Fields.Field(iii)
If ffield.AliasName = "Set" Then
feature.Value(iii) = "SET"
Exit Do
End If
iii += 1
Loop
End If
End If
If shape <> "location" Then
commandItem = commandBars.Find(My.ThisAddIn.IDs.Process2, True, False)
If commandItem.Caption = "Ambiguity On" Then
iii = 0
Do While iii < outputSignDetailTable.Fields.FieldCount
ffield = outputSignDetailTable.Fields.Field(iii)
If ffield.AliasName = "Ambiguity" Then
feature.Value(iii) = "AMBIG"
Exit Do
End If
iii += 1
Loop
End If
End If
commandItem = commandBars.Find(My.ThisAddIn.IDs.Process3, True, False)
If commandItem.Caption = "Double Check On" Then
iii = 0
Do While iii < outputSignDetailTable.Fields.FieldCount
ffield = outputSignDetailTable.Fields.Field(iii)
If ffield.AliasName = "Check" Then
feature.Value(iii) = "CHECK"
Exit Do
End If
iii += 1
Loop
tableInsertCursor.InsertRow(feature)
Else
tableInsertCursor.InsertRow(feature)
End If
End If
pFeat = pEF.Next()
Loop
End Sub Josh, Are you sure you can add your own OBJECTID values, I thought it was generated automatically?
... View more
01-30-2013
04:51 AM
|
0
|
0
|
2028
|
|
POST
|
I gave this a try on ArcGIS 10 SP5 and it worked ok... The table was an Oracle table accessed through SDE. In the original code, I noticed a space between the "DS" and ".FullName", probably just a copy/paste issue... When converting VBA code from 9.3 mxds to 10, originally, I noticed that many of my references where pooched. I had to go to tools, references and remove the missing ones, then it worked ok. It seems VBA stops loading references as soon a it gets to a missing one, so if the one you need is after that in the list, it doesn't work. Dim mxd As IMxDocument
Set mxd = ThisDocument
Dim map As IMap
Set map = mxd.FocusMap
Dim tabcoll As ITableCollection
Set tabcoll = map
Dim tabl As ITable
Set tabl = tabcoll.Table(0)
Dim DS As IDataset
Set DS = tabl
Dim TableName As IName
Set TableName = DS.FullName
Dim dsName As IDatasetName
Set dsName = TableName
Debug.Print dsName.Name Thanks for the suggestion, I've checked the references but nothing is missing. Here is the code im using ' Loop through the codepoint layer
Set pDataset = pdatasets.Next
Do While Not (pDataset Is Nothing)
' MsgBox (pDataset.Name)
Select Case pDataset.Type
Case esriDTFeatureClass
Select Case pDataset.BrowseName
Case "OS_VECTOR.OS_CODEPOINT"
Set pName = pDataset.FullName ===========FAILS HERE ==============
Set m_pCodePointClass = pName.Open
'Set pFCcodepoint = pName.Open
'MsgBox (pFCcodepoint.ShapeType)
End Select
End Select
Set pDataset = pdatasets.Next
Loop I've tried your code and it does work, so I'm confused.
... View more
11-20-2012
07:05 AM
|
0
|
0
|
1029
|
|
POST
|
Just trying out some of our old VBA code ArcGIS 10 and getting a type mismatch error where I should NOT be getting one. Here is the code: Dim DS as IDataSet Set DS = MyTable Dim TableName As IName Set TableName = DS .FullName The error is thrown at "Set TableName = DS.FullName" Where TableName is IName and DS.FullName is IName. This should not throw a Type Mismatch error but it is, and only in ArcGIS 10; all other previous versions work. Is there any solution to this, as im having the same problem.
... View more
11-20-2012
01:18 AM
|
0
|
0
|
1029
|
|
POST
|
You can't use 'sdemon' to kill Direct Connect connections -- the process lives elsewhere (which is waht the error message indicates). - V Hi Vince, I was hoping to kill the ArcSDE connections rather than the Direct Connections (I don't think we have DC's, all connections that we use go through ArcSDE). I'm puzzled as it has only recently been telling me that there are no users connected.
... View more
11-06-2012
12:23 AM
|
0
|
0
|
544
|
|
POST
|
Hi all, I am having some problems with ArcSDE at the moment, when i try the following syntax sdemon -o info -I users -i 5158 -s servername I get the following message There are no ArcSDE users logged in. I have then looked in the SDE.PROCESS_INFORMATION table and can see the users who are logged, in but when I try to kill a user using the SDE_ID, i get the following message Process ID does not correspond to an SDE server The same thing happened last week and we restarted the database and SDE service and it fixed it, but the problem is back again. We are using ArcSDE 9.2 (we are planning on upgrading next month).. Has anyone got any ideas why this might be happening? Thanks
... View more
11-05-2012
04:18 AM
|
0
|
3
|
652
|
|
POST
|
FYI: 10.1 clients are not able to connect to pre-9.3 ArcSDE geodatabases: Client and geodatabase compatibility The workflow you describe is not possible. Mine does.....:confused:
... View more
10-05-2012
06:47 AM
|
0
|
0
|
851
|
|
POST
|
Is it possible to make H3Viewer the default help, when I hit F1 within VS2010? Edit - Never mind, found the option in H3.
... View more
09-27-2012
01:45 AM
|
0
|
0
|
452
|
|
POST
|
Hi, I have just installed ArcGIS Desktop 10.1, and am trying to create a new toolbar, from the notes I have from the training course I went on, it says to Add new Item (Selecting Desktop Addin's) Click Add Choose Add-in Command Bars... My problem is that the Add-in Command bars option is not there, I can only see Add-in Components s. See attached picture. Anyone got any ideas on this? Thanks
... View more
09-25-2012
07:29 AM
|
0
|
5
|
3283
|
|
POST
|
Hi all, Does anyone have a working example of using the IBufferConstruction and IbufferConstructionProperties interface, I am attempting to create multiple buffers from a point that is clicked on the map but am getting nowhere. am using ArcGIS 9.3.1 and VBA Thanks Halil
... View more
07-24-2012
06:21 AM
|
0
|
0
|
1467
|
|
POST
|
I was having the same problem, I'm glad I found this post.
... View more
03-21-2012
06:09 AM
|
0
|
0
|
1403
|
|
POST
|
Halil, Looking at your sample code I believe the sample you have found is specific to MS Access. If you want to open a website using VBA in ArcMap 9.3 use this code instead: Dim iE As Object
Set iE = CreateObject("InternetExplorer.Application")
iE.navigate "www.rivex.co.uk"
iE.Visible = True Duncan Perfect, thanks Duncan.
... View more
02-12-2012
11:43 PM
|
0
|
0
|
441
|
|
POST
|
I know this is an old thread, but I am having the exact same problem, I have tried the code above this post, but I still get the automation error message. any ideas?
... View more
02-07-2012
04:49 AM
|
0
|
0
|
726
|
|
POST
|
Hi all, In my application i have a text box which is populated with a weblink, I have found some code which "should" allow me to click on it and open the link, but I get the following error "438: Object doesn't support this property of method". Is it not possible to use hyperlinks? This is the code i am using for that text box. Private Sub txtDeveloperWebsite_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) Dim strDevWebsite As String On Error GoTo Error_OLEUnbound1 ' Set reference to hyperlink address. strDevWebsite = txtDeveloperWebsite.Text ' Follow hyperlink address. Application.FollowHyperlink strDevWebsite, , True Exit_OLEUnbound1: Exit Sub Error_OLEUnbound1: MsgBox Err & ": " & Err.Description Resume Exit_OLEUnbound1 End Sub I'm using ArcGIS 9.3.1 Thanks
... View more
02-06-2012
03:02 AM
|
0
|
2
|
859
|
|
POST
|
Hi Vince, i know about "sdelayer", what I was hoping for was UserA has read/ write / edit metadata on layer1 and then compare that layer with layer2 in essence. Halil
... View more
10-03-2011
01:52 PM
|
0
|
0
|
420
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-01-2023 03:44 AM | |
| 2 | 07-01-2020 02:30 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-03-2025
02:39 AM
|