|
POST
|
Well, tried to give it a test, but I can't get past the sandbox security..... R_
... View more
06-24-2013
06:09 PM
|
0
|
0
|
1360
|
|
POST
|
Don't think the App Builder will let you configure that (not sure though). However, in the xml you attached, you should be able to change this line to get what you are after: <layers onlythese="true"> That way, it will only list the layers/fields you have listed in the confg file. R_
... View more
06-24-2013
05:50 PM
|
0
|
0
|
1367
|
|
POST
|
Thanks I am passing the parms through a GP tool. I will try hard coding to see if I can get this to work. Any suggestion on where to search to learn more about debugging why a parameter being passed via a GP tool isn't working correctly? I rarely use tools/models from within ArcMap other than to write my initial python code for me, so probably not the best to answer this question. However, the few that I do run through ArcMap/Toolbox, I right-click on the model script itself, select properties, and parameters. this is where you set the parameters that get passed to arcpy when run. Can hard code, browse button, etc. Another way to pass parameters is as arguments. C:\pythonpath\python.exe scriptfile.py arg1 arg2 arg3 (which would be parameter(0), (1), etc). However, I normally just hard code it in the python script, as it is either static, OR, python tools can iterate/parse/filter/etc. to get the paramaters I need. R_
... View more
06-24-2013
10:36 AM
|
0
|
0
|
1058
|
|
POST
|
Thanks Robert, and sorry for the late response, been away, and now dragged in a different direction. I'll look into the utility class and innerhtml, but really have not had the time I need to fully learn the in's and outs of the viewer itself in order to incorporate, but am getting by. Now, or course, I've been dragged different direction, so time is even more limited. Not sure how to incorportate the java class to fire on/instead of a popup (on one layer only in my config), but is fairly easy in the popuprendererskin using externalinterface (Not the best results/format, but it works) (really like the FRinfowindow format, but don't like how the window content "moves" with the map and the window doesn't (or vice versa.)) At least I'm only calling it once now :rolleyes: so think I will have to live with it for now, maybe get a chance to dive in/figure out the innerhtml stuff later. Thanks again for your help, R_
... View more
06-24-2013
09:22 AM
|
0
|
0
|
1213
|
|
POST
|
It is not getting your parameters, are you passing them along with the command line. If you are not running from a GP tool, you need to either pass the parameters as arguments (Python D:\scriptfile.py d:\myfolder myData OutPut NewSource) or code the paths (folderPath=r"C:\arcgisserver\local_data\"). I normally just put the path to my data in the script and run it. R_
... View more
06-20-2013
02:36 PM
|
0
|
0
|
2336
|
|
POST
|
import arcpy, datetime, os
try:
#Read input parameters from GP dialog
folderPath = arcpy.GetParameterAsText(0)
dataSource = arcpy.GetParameterAsText(1)
output = arcpy.GetParameterAsText(3)
newSource = arcpy.GetParameterAsText(2)
print folderPath
print dataSource
print output
print newSource
#Loop through ech MXD file
mCnt = 0
for filename in os.listdir(folderPath):
fullpath = os.path.join(folderPath, filename)
if os.path.isfile(fullpath):
if filename.lower().endswith(".mxd"):
#Reference MXD
mxd = arcpy.mapping.MapDocument(fullpath)
#Determine if the data source exists within the data frames/map document
#If exist then update the datasource - TH Testing 06/05/2013
sCnt = 0
for df in arcpy.mapping.ListDataFrames(mxd):
layerList = []
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
if lyr.supports("dataSource"):
if lyr.dataSource == dataSource:
lyr.findAndReplaceWorkspacePath("dateSource", "newSource") #TH Testing
mxd.save() #TH Testing
mCnt = 1
sCnt = sCnt + 1
))
Are you sure your variables are getting set correctly? What happens if you add the changes above in blue? R_
... View more
06-20-2013
01:36 PM
|
0
|
0
|
2336
|
|
POST
|
Don't know if it's possible either, but the XSLT Transformation can change "some" aspects of the metadata. Good at removing items (such as thumbnails, geoprocessing history, etc.) from the metadata. http://resources.arcgis.com/en/help/main/10.1/index.html#//001200000017000000 and here is example of using it in python to modify metadata on all FC's (in and outside of feature datasets) withing a database. http://support.esri.com/en/knowledgebase/techarticles/detail/41026 (of course, this one invokes the remove_gp_history_xslt instead of remove thumbnails, but simple to change) I'm not around a computer that I can look into it more to even see if the xslt can be used to actually "add" a thumbnail or just remove them. If it can, could possibly use arcpy.mapping to iterate through them all and export the right size/type image for each FC, then add them with the xslt transform. Just a thought, In any case, if you ever get tired of multiple pages of Geoprocessing history in your metadata, maybe this post will come in handy after all,:cool: R_
... View more
06-13-2013
08:22 PM
|
0
|
0
|
1471
|
|
POST
|
Turns out there were a couple issues here. First, my script was firing the launch function three times and is sending the URL with window.open to a named window. Using a named window makes it either open a new window if it doesn't exist, or, if window with that name exists, open the new URL in that window. So, on XP with IE8, all three were being sent to the named window, so the end result was just one window with my info. However, it appears that IE8 on windoze 7 does not honor the named window, and opens a new one for each externalinterface call. So, now I get a single window for each click. Better than three I guess, but would be nice if I could figure out how to make it honor the named window (short of upgrading to IE9). R_
... View more
06-13-2013
04:23 PM
|
0
|
0
|
1213
|
|
POST
|
Thank you both. Unfortunately, I won't be back in the office until Monday, so I will not be able to try out your suggestions until then. In the meantime, I can explain the purposes of this script. Text in bold indicates instructions that exist within the current script, as seen on the OP. Iterate through features within IlCounties layer, and do the following for each feature: Zoom to feature Select all features not equal to feature within IlCounties Export selection as new layer, add to Detail Map dataframe Update new layer to incorporate symbology of Export_Output_21 Add new layer to a second existing dataframe (named Locator Map) Replace MXD title element to IlCounties feature name Export as PDF I'm mostly just seeking help for the instructions in bold at the moment. I'll answer your questions and suggestions directly come Monday. Thank you! Now that I read your post more carefully, I can make what you are "asking" for much simpler. How about this:
import arcpy
mxDoc = arcpy.mapping.MapDocument(r"X:/GisResources/Mxd Map Templates/HighUnemploymentCensusTracts_Template.mxd")
out_pdf = r"X:/GisResources/NewPDF.pdf")
ExportToPDF (mxDoc, out_pdf,resolution=266)
Since "Iterate through features within IlCounties layer, and do the following for each feature" and then "Select all features not equal to feature within IlCounties" if you are selecting for all features that are not equal to the same features you are comparing it to, you will always get zero results, so the rest of the code is not needed. :cool: Still a little confused about what you are after I guess. Also, what is the end result/purpose of this? My "similar" scripts, I just put a definition query on my layer(s) (same layer in both dataframes), then export to pdf. Most the time, there would be no need to actually make a new layer, then add to the mxd unless your end result is actually to get the "new" FC created. It almost sounds like you are just after a pdf with a map of all features minus one (without the current one). In this case, I would just iterate through the OID's, set a definition query to OID <> iterOID (on a copy of the IlCounties layer in both df, with symbology applied) update thet text, then dump to PDF This way, no need to create, add, update layers/and or symbology. Symbology would be set, definition query would determine features displayed. OID <> iterOID as a definition query would display ALL features in IlCounties that do not match the currently "selected" feature. I realize this post was initially about applying symbology, but, if you were to define your final objectives, there may be a much easier/faster way to accomplish it. R_ R_
... View more
06-13-2013
02:30 PM
|
0
|
0
|
2462
|
|
POST
|
Well, without the time to dive into this, this is the way I would approach it as I am doing something very similar and this method works for me. Also, I'm not back until monday either. gotta love 4-10s. Thank you both. Unfortunately, I won't be back in the office until Monday, so I will not be able to try out your suggestions until then. In the meantime, I can explain the purposes of this script. Text in bold indicates instructions that exist within the current script, as seen on the OP. Iterate through features within IlCounties layer, and do the following for each feature: the da.walk will do this for you. for dirpath, dirnames, filenames in arcpy.da.Walk(datatype="FeatureClass",type="All"): ## would restrict this "All" to the feature/table type you are after for filename in filenames: Rest of the code would go here since you want it for each feature in the FC.... Zoom to feature cntyLayer = r'path\to\IlCounties" feature class ### would hard code this one since it is fixed, and we iterate through the others. df = arcpy.mapping.ListDataFrames(mxd, "Detail Map")[0] df2 = arcpy.mapping.ListDataFrames(mxd, "Locator Map")[0] # Just as well set both df's while here lyr = arcpy.mapping.ListLayers(mxd, "IlCounties", df)[0] df.extent = lyr.getSelectedExtent(True) Select all features not equal to feature within IlCounties Use SelectLayerByLocation with ARE_IDENTICAL_TO for overlap type and NEW_SELECTION for selection type. Use SelectLayerByLocation with SWITCH_SELECTION as selection type ### These two will select features that are not equal to the other features Export selection as new layer, add to Detail Map dataframe Use CopyFeatures to export to new FGDB FC # this will only copy/export the selected features then AddLayer to add the new FC to the df. AddLayer(df,new_FC) Update new layer to incorporate symbology of Export_Output_21 use UpdateLayer for this Add new layer to a second existing dataframe (named Locator Map) add layer again AddLayer(df2,new_FC) ## of course, you will have to update symobology again if needed. Replace MXD title element to IlCounties feature name legend = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "title")[0] legend.text = filename Export as PDF ExportToPDF (mxd, out_pdf,resolution=266) I'm mostly just seeking help for the instructions in bold at the moment. I'll answer your questions and suggestions directly come Monday. Thank you! Now that I spelled it all out, easy to put together. should be something like this (you will need to fill in the blanks) cntyLayer = r'path\to\IlCounties' arcpy.MakeFeatureLayer_management(cntyLayer, "IlCounties_lyr") for dirpath, dirnames, filenames in arcpy.da.Walk(datatype="FeatureClass",type="All"): for filename in filenames: df = arcpy.mapping.ListDataFrames(mxd, "Detail Map")[0] df2 = arcpy.mapping.ListDataFrames(mxd, "Locator Map")[0] # Just as well set both df's while here lyr = arcpy.mapping.ListLayers(mxd, "IlCounties", df)[0] df.extent = lyr.getSelectedExtent(True) arcpy.MakeFeatureLayer_management(filename, str(filename) + "_lyr") SelectLayerByLocation(str(filename) + "_lyr", "ARE_IDENTICAL_TO", "IlCounties_lyr", #, NEW_SELECTION) SelectLayerByLocation(str(filename) + "_lyr", "ARE_IDENTICAL_TO", "IlCounties_lyr", #, SWITCH_SELECTION) CopyFeatures AddLayer(df,new_FC) UpdateLayer AddLayer(df2,new_FC) UpdateLayer legend = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "title")[0] legend.text = filename ExportToPDF (mxd, out_pdf,resolution=266) R_
... View more
06-13-2013
02:13 PM
|
0
|
0
|
2462
|
|
POST
|
Ok, now I feel like an idiot. Since it was working fine on XP machines, I didn't think to trace the launch function. Now that I have, I see it is firing it three times. Since I am window.opening a named window, it is supposed to open the new links in the same window each time. On xp, I guess that is happening fast enough you only see the last "refresh/launch" in the single window. not sure why on windoze 7 it opens in three, but once I figure out why it is firing my launch function multiple times, I can test that out. Thanks again for pointing me in the right direction, R_
... View more
06-13-2013
12:39 PM
|
0
|
0
|
1213
|
|
POST
|
Yep, that did it. Guess will all the options available, just pick one that works.:cool: R_
... View more
06-13-2013
12:26 PM
|
0
|
0
|
3284
|
|
POST
|
One of the first things you need to know about python is that indentation is everything. That is how it keeps track of your if blocks, etc. That is why Lucas's re-write works for him. R_
... View more
06-13-2013
12:24 PM
|
0
|
0
|
796
|
|
POST
|
Interesting, I will have to check it out. When you say "popup window", is that a new browser window from externalinterface call as I get a message about blocked popup that I need to enable (that I don't get with my external call). With my external interface call, it just opens a new browser window. If clicked again (for a different site), it updates the same window with the new website. On windoze 7, IE 8, each feature I click opens 3 new windows. Click three of them, you get nine windows, etc. This is my code (fired from the popuprendererskin)
private var feats:String = "scrollbars=1,width=450,height=400,resizable=Yes,location=Yes,toolbar=No"; // settings for the popup weather window
private function launch(urlRequest:String):void
{
ExternalInterface.call("window.open", urlRequest, "hms" , feats);
} Have narrowed it down to where it acts this way on windoze 7 32 and 64 bit with IE 8. IE9 and it doesn't do it. Too bad our IT folks won't update to IE 9... R_
... View more
06-13-2013
11:59 AM
|
0
|
0
|
1213
|
|
POST
|
ionara, Don't have time to dive into this at the moment, but it could be because the datetime module has no attribute "today" so d1 = datetime.today() will error out and not assign the variable no matter what imports I try in the IDE. Not where I can look it up at the moment, but you should look into the datetime attributes and options. believe something like
d1 = = date.today()
But don't remember exactly offhand. R_
... View more
06-13-2013
11:52 AM
|
0
|
0
|
3284
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-14-2026 04:00 PM | |
| 1 | 09-14-2022 07:53 AM | |
| 1 | 09-14-2022 08:23 AM | |
| 1 | 05-21-2026 08:53 AM | |
| 1 | 05-14-2026 04:28 PM |
| Online Status |
Online
|
| Date Last Visited |
Wednesday
|