|
POST
|
I am using this code to add a feature from GeoDatabase dataset to an open MXD file import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Temp\Streets.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
targetGroupLayer = arcpy.mapping.ListLayers(mxd, "Main", df)[0]
addLayer = arcpy.mapping.Layer(r"C:\Data\NetMap.gdb\Streets\OneWay")
arcpy.mapping.AddLayerToGroup(df, targetGroupLayer, addLayer, "BOTTOM") This is somehow adding the `OneWay` feature class to the `Main` Group Layer at `Streets.mxd` but I have to close the map and reopen it to see the data there. I tried to refresh the TOC and Active view like (As it work in IDE inside the Current Map) arcpy.RefreshActiveView()
arcpy.RefreshTOC() but it is not doing anything with stand-alone script and MXD. Can you please let me know if there is a way to do this?
... View more
05-18-2017
02:23 PM
|
0
|
4
|
2072
|
|
POST
|
Here is the latest: import arcpy
arcpy.env.workspace = r"E:/Utility/Sample/Montgomery.gdb/Water/Flag_Trace"
# Local variables:
G_N = "E:/Utility/Sample/Montgomery.gdb/Water/Water_Net"
Flag = "E:/Utility/Sample/Montgomery.gdb/Water/Flag"
traceOut = "traceOut_Net"
# Process: Trace Geometric Network
arcpy.TraceGeometricNetwork_management(G_N, traceOut, Flag, "TRACE_UPSTREAM", "", "", "", "", "", "NO_TRACE_ENDS", "", "", "", "AS_IS", "", "", "", "AS_IS")
glyr = arcpy.mapping.Layer(traceOut)
# Extract the layer based on a search string
tlyr = [lyr for lyr in arcpy.mapping.ListLayers(glyr)
if "net" in str(lyr).lower()][0]
# copy out to a feature class
tfeat = "Flag_Trace"
arcpy.CopyFeatures_management(tlyr, tfeat)
print "Trace Done"
... View more
05-18-2017
01:07 PM
|
0
|
1
|
2752
|
|
POST
|
Thanks for reply but what exactly do you men by setting? "I did not set in the code sample" something like trace_feat = "E:/Utility/Sample/Montgomery.gdb/Water/trace_feat.shp
... View more
05-18-2017
11:39 AM
|
0
|
5
|
2752
|
|
POST
|
Thanks Curtis' I updated the code as: import arcpy
arcpy.env.workspace = r"E:/Utility/Sample/Montgomery.gdb"
# Local variables:
G_N = "E:/Utility/Sample/Montgomery.gdb/Water/Water_Net"
Flag = "E:/Utility/Sample/Flag.shp"
traceOut = "traceOut_Net"
# Process: Trace Geometric Network
arcpy.TraceGeometricNetwork_management(G_N, traceOut, Flag, "TRACE_UPSTREAM", "", "", "", "", "", "NO_TRACE_ENDS", "", "", "", "AS_IS", "", "", "", "AS_IS")
glyr = arcpy.mapping.Layer(traceOut)
# Extract the layer based on a search string
tlyr = [lyr for lyr in arcpy.mapping.ListLayers(glyr)
if "net" in str(lyr).lower()][0]
# copy out to a feature class
arcpy.CopyFeatures_management(tlyr, tfeat)
print "Trace Done" but I am getting error on arcpy.CopyFeatures_management(tlyr, tfeat)
can you please let me know what is tfeat ?
... View more
05-18-2017
10:04 AM
|
0
|
7
|
2752
|
|
POST
|
I am able to run Geometric Network Trace by using following ArcPy script but I also need to add Trace result into the map. Can you please let me know how I can add the result(graphic/geometry) to the map. import arcpy
arcpy.env.workspace = r"E:/Utility/Sample/Montgomery.gdb"
# Local variables:
G_N = "E:/Utility/Sample/Montgomery.gdb/Water/Water_Net"
Flag = "E:/Utility/Sample/Flag.shp"
traceOut = "traceOut_Net"
# Process: Trace Geometric Network
arcpy.TraceGeometricNetwork_management(G_N, traceOut, Flag, "TRACE_UPSTREAM", "", "", "", "", "", "NO_TRACE_ENDS", "", "", "", "AS_IS", "", "", "", "AS_IS")
print "Trace Done"
... View more
05-18-2017
09:36 AM
|
0
|
9
|
3978
|
|
POST
|
Can you please let me know how we can set current map to Full Extent using ArcPy? import arcpy
import arcpy.mapping
# Set the Map to be Full Extent
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.Set-To-Full_Extent like what the is doing on main toolbar in the ArcMap?
... View more
04-20-2017
11:07 AM
|
0
|
7
|
4236
|
|
POST
|
Trying to Query an ESRI MapService through ArcGIS Runtime .NET SDK 10.2.7 (Using this sample) private async void QueryButton_Click(object sender, RoutedEventArgs e)
{
try
{
await RunQuery();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
}
private async Task RunQuery()
{
try
{
QueryTask queryTask = new QueryTask(
new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"));
Query query = new Query(StateNameTextBox.Text);
query.OutFields.Add("STATE_NAME");
var result = await queryTask.ExecuteAsync(query);
itemListView.ItemsSource = result.FeatureSet.Features.OrderBy(g => g.Attributes["STATE_NAME"]);
}
catch (TaskCanceledException) { }
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
}
} but in result I am getting Esri.ArcGISRuntime.Layers.Graphic instead of the name of the states! Can you please let me know why this is happening and how can I fix it?
... View more
03-31-2017
03:39 PM
|
0
|
1
|
1351
|
|
POST
|
I have already installed ArcGIS 10.4 - Desktop Single Use on my machine and authorized the license. Now I would like to Create a simple application using ArcObjects .NET 10.4 SDK. Do I need to get an extra license to do this?
... View more
03-29-2017
10:35 AM
|
0
|
0
|
1073
|
|
POST
|
Hi Neil, I didn't try to run the code on any other IDLE as the Example one of the Geometric Network at the same page is working perfectly. The only difference between this example and first one is the Example 2 is using Filter Weight called Friction_Factor with a weight filter of 1 to 10.
... View more
03-22-2017
10:15 AM
|
0
|
0
|
979
|
|
POST
|
I am trying to run this ArcPy example from ESRI TraceGeometricNetwork example 2 # Import arcpy module
import arcpy
# Local variables:
Water_Net = "C:/GeometricNetworks/Montgomery.gdb/Water/Water_Net"
Flags = "C:/GeometricNetworks/Montgomery.gdb/Water/Flags"
Water_Net_2 = "Water_Net"
# Process: Trace Geometric Network
arcpy.TraceGeometricNetwork_management(Water_Net, Water_Net_2, Flags, "FIND_PATH", "", "", "Friction_Factor", "Friction_Factor", "", "NO_TRACE_ENDS", "", "", "", "AS_IS", "Friction_Factor", "Friction_Factor", "1-10", "AS_IS") but I am getting this error on running the code Message File Name Line Position
Traceback
__call__ C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py 196
syncreq C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py 71
sync_request C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py 431
serve C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py 379
_recv C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py 337
recv C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\channel.py 50
read C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\stream.py 166
exceptions.EOFError: [Errno 10054] An existing connection was forcibly closed by the remote host Can you please let me know what is happening? and How I can fix this?
... View more
03-22-2017
08:39 AM
|
0
|
2
|
1421
|
|
POST
|
I have a Transformer feature in a Geometric Network which has a field called `PhaseDesig` and it has five types of unique attributes [0, 1, 2,4,7] like this image I used this code to generate Geometric Network arcpy.CreateGeometricNetwork_management(Electric, "Electric_Net",
"Power SIMPLE_JUNCTION YES;\
Fuses SIMPLE_JUNCTION NO; \
Transformer SIMPLE_JUNCTION NO; \
Conductor SIMPLE_EDGE NO;",
"0.5",
"PhaseDesig Bitgate #",
"Transformer PhaseDesig PhaseDesig; \
Fuses PhaseDesig PhaseDesig",
"",
"PRESERVE_ENABLED") but this only added Can you please let me know how I can apply all 5 binary weights into the bitgate of each field. Thanks
... View more
03-16-2017
02:14 PM
|
0
|
0
|
1349
|
|
POST
|
Thanks Alex but this is generating error on line two import kivy kivy.require('1.0.6') Invalid Syntax
... View more
03-16-2017
08:56 AM
|
0
|
0
|
1385
|
|
POST
|
I am running Kivy and Python properly when it is only Kivy as import kivy
kivy.require('1.0.6')
from kivy.app import App
from kivy.uix.label import Label but when I add ArcGIS Python library called ArcPy like below import arcpy
import kivy
kivy.require('1.0.6')
from kivy.app import App
from kivy.uix.label import Label I am getting following error: Message File Name Line Position Traceback 5 C:\Python27\ArcGIS10.4\lib\site-packages\kivy\app.py 327 C:\Python27\ArcGIS10.4\lib\site-packages\kivy\uix\widget.py 219 C:\Python27\ArcGIS10.4\lib\site-packages\kivy\graphics__init__.py 89 init kivy.graphics.instructions (kivy\graphics\instructions.c:14640) kivy\graphics\vbo.pxd 7 init kivy.graphics.vbo (kivy\graphics\vbo.c:5482) kivy\graphics\compiler.pxd 1 init kivy.graphics.compiler (kivy\graphics\compiler.c:2983) kivy\graphics\shader.pxd 5 init kivy.graphics.shader (kivy\graphics\shader.c:11990) kivy\graphics\texture.pxd 3 init kivy.graphics.texture (kivy\graphics\texture.c:31800) kivy\graphics\fbo.pxd 5 init kivy.graphics.fbo (kivy\graphics\fbo.c:7683) kivy\graphics\fbo.pyx 84 ImportError: DLL load failed: The specified procedure could not be found. can you please let me know why this is happening and how I can fix it?
... View more
03-16-2017
08:45 AM
|
0
|
3
|
2163
|
|
POST
|
Using ESRI Tutorial Data for Utility Network Tracing (Montgomery.gdb) which is a File Geodatabase and following Arcpy script I am not getting any erro on running the script to find the path between two points in Flag (point) layer # Import arcpy module
import arcpy
# Local variables:
gnVersionFDS_Net = "E:/Montgomery.gdb/Water/Water_Net"
Flags = "E:/Montgomery.gdb/Water/Flags"
gnVersionFDS_1 = "gnVersionFDS_1_Net"
# Process: Trace Geometric Network
arcpy.TraceGeometricNetwork_management(gnVersionFDS_Net, gnVersionFDS_1, Flags, "FIND_PATH", "", "", "", "", "", "NO_TRACE_ENDS", "", "", "", "AS_IS", "", "", "", "AS_IS")
print "The Proccess Done" I added the Flag layer manually to the Dataset and it has two points as again, I am not getting any error but I am not seeing any layer and path to be generated or added to somewhere. Can you please let me know what I am doing wrong or how can I make this rum properly?
... View more
03-15-2017
10:33 AM
|
0
|
0
|
1296
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-25-2017 08:32 AM | |
| 1 | 07-04-2017 01:47 PM | |
| 1 | 08-15-2017 02:44 PM | |
| 1 | 05-19-2017 02:36 PM | |
| 1 | 02-09-2017 12:37 PM |
| Online Status |
Offline
|
| Date Last Visited |
12-31-2020
08:22 PM
|