|
POST
|
I only tested from the embedded ArcCatalog (is there still a standalone version?), so you may be correct. Although you could also just shorten the string to evaluate to just "arc" and it would pickup both "ArcMap" or "ArcCatalog" I guess.
if not "Arc" in sys.executable:
... View more
08-06-2014
01:21 PM
|
0
|
0
|
5547
|
|
POST
|
Yes, Python Add-in's is what I have had experince with and comparing them to an ArcObjects COM component built with .NET/C# -- they are wildly different in capabilities. Go ahead and try to build an installed COM/ArcObjects component developed in Visual Studio and attempt to replicate that component in PythonWin
... View more
08-06-2014
08:13 AM
|
2
|
0
|
2573
|
|
POST
|
Add-ins *can* be great for *some* development needs. However, they are also quite limited in comparison to a customization that is fully exposed to ArcObjects. If your implementation requires fully functional UI components and presentation forms with lots of elements (text boxes, drop-down lists, crystal reports, etc..) you will have a tough time getting those migrated to a python add-in. If you have to rely soley upon Python Add-In and need the UI functionality, you will need to build Geoprocessing tools/scripts, which of course also provide limited UI components. The idea is to build these with user interaction processes and components and just launch them from the Add-In:
pythonaddins.GPToolDialog('C:\MyCustomToolbox.tbx', 'MyTool')
Finally, manipulating map elements can also be quite limited. For example, try adding and altering text elements on a Layout view. Seemingly simple tasks/processes easily handled with ArcObjects customized tools written in VB/C# become very convoluted and difficult to replicate with an Add-In.
... View more
08-06-2014
06:13 AM
|
2
|
1
|
2573
|
|
POST
|
As an alternative you could also trap the sys.executable source to check where to expect parameters to come from. I think it would something like this (using Shaun's code exampe):
import arcpy
import sys
def main(input_fc=None, output_fc=None):
# your main script body goes here
# executed as a script
if __name__ == '__main__':
if not "ArcMap" in sys.executable:
# we were passed command line parameters, execute in a script context
input_fc=sys.argv[1]
output_fc=sys.argv[2]
else:
# if we don't have args passed on the command line, assume a toolbox context
input_fc=arcpy.GetParametersAsText(0)
output_fc=arcpy.GetParametersAsText(1)
# call the main function with our parameters
main(input_fc, output_fc)
If you were to run this from an Geoprocessing Toolbox it would evaluate as 'else' and ust arcpy.GetParameter but would evaluate as "if" from another source. Edit: I don't see any option to format the code anywhere in this ridiculous updated "forum". Edit 2: I had to hop over tags, blogs, rss feeds, streams, and a bunch of other things that aboslutely should not be found in a tech forum and located a "how to" on formatting code blocks. The level of obscurity built into this "forum" is simply absurd.
... View more
08-05-2014
11:05 AM
|
1
|
2
|
5547
|
|
POST
|
I wonder if something about the data source (basemap or other) has been changed, possibly even just a field was dropped or altered, that has caused an issue. Have the user open it in a different browser (FireFox, Chrome, etc..) and see if that offers relief.
... View more
08-04-2014
06:00 AM
|
1
|
1
|
1953
|
|
POST
|
Thanks but I really am unintersted in model builder and need to implement this into a Python Add-In. Here's what I came up with that works just fine:
ptarrL = arcpy.Array()
ptarrR = arcpy.Array()
for l in listoflayers:
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == str(l):
print "layer: " + str(lyr.name)
with arcpy.da.SearchCursor(lyr, ["SHAPE@"]) as lyrCur:
for row in lyrCur:
xL, yL = row[0].firstPoint.X, row[0].firstPoint.Y
xR, yR = row[0].lastPoint.X, row[0].lastPoint.Y
ptarrL.add(arcpy.Point(xL, yL))
ptarrR.add(arcpy.Point(xR, yR))
with arcpy.da.InsertCursor(lyr, ["SHAPE@"]) as inscur:
polyline = arcpy.Polyline(ptarrL)
inscur.insertRow([polyline])
with arcpy.da.InsertCursor(lyr, ["SHAPE@"]) as inscur:
polyline = arcpy.Polyline(ptarrR)
inscur.insertRow([polyline])
del inscur, lyrCur
... View more
07-22-2014
10:47 AM
|
0
|
0
|
2372
|
|
POST
|
Yes, I would like to create the green line you see between each feature. 1. Yes, always stacked one above the other. 2. Doesn't matter really. The next step would simply run this polyline FC thru a ToPolygon conversion. 3. Each "set" of polylines is a single feature class. The 3 polylines you see in the image is 1 FC. Thanks!
... View more
07-22-2014
09:01 AM
|
0
|
0
|
2372
|
|
POST
|
Not sure how best to word this. I am looking for arcpy solutions/ideas on connecting the endpoints of stacked polyine features together in order to build it into a polygon feature class. This task done manually is quite simple: just add a new polyline(s) from one start point to the startpoint of the polyline below it and continue this until an entire "side" of the stacked polylines are connected. Then it's just a matter of doing this same thing to the other "side" on the endpoints of each polyline feature. See:
... View more
07-22-2014
08:11 AM
|
0
|
4
|
6397
|
|
POST
|
Print statements will display in ArcMap's Python window for Add-In tools. Not sure if that helps.
... View more
07-09-2014
12:11 PM
|
0
|
0
|
13635
|
|
POST
|
I wouldn't be so quick to label this place a "Forum".
... View more
07-09-2014
08:17 AM
|
1
|
0
|
1997
|
|
POST
|
Hi Elaeanor! So IOW's, there is no logical "Python forum". I have to search, filter, tag, content, blog rather than just go to a forum specific to python? When I arrived to the new forum my eyes immediately looked for "Python". Didn't yours? Yes, I am a "GIS Developer" but I would expect a bit more granularity about what it is I am developing.
... View more
07-08-2014
12:57 PM
|
0
|
0
|
1997
|
|
POST
|
Thanks Christina! But can I ask: why should I need to review documents and training guides to figure out a discussion forum?
... View more
07-08-2014
08:43 AM
|
4
|
1
|
1997
|
|
POST
|
That was the best format of all the board layouts! I LOVED how you could collapse all of the sections and only keep what you wanted to view. Unfortunately, I was referencing the forums that were there yesterday, not 2010. Thanks!
... View more
07-08-2014
08:40 AM
|
1
|
0
|
3295
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-17-2020 10:47 AM | |
| 1 | 10-25-2022 11:46 AM | |
| 1 | 08-08-2022 01:40 PM | |
| 1 | 02-15-2019 08:21 AM | |
| 2 | 08-14-2023 07:14 AM |
| Online Status |
Offline
|
| Date Last Visited |
01-22-2025
02:28 PM
|