POST
|
Correction to my previous comment, this is Not how I had it Exactly... He removed the MakeFeatureLayer management call, which was important !
... View more
02-15-2018
06:54 AM
|
0
|
0
|
1466
|
POST
|
I'm back to it and have been testing the recommendation from @bixb0012 above. I received a response from ESRI, but I didn't really like mangling the output parameters. I preferred the more direct approach of adding the layers explicitly with the mapping.Layer call. Removing the AddFatureLayer_management call and adding the dataset directly to the Layer call appears to work. def execute(self, parameters, messages): dataset_to_process = # path to feature class mxd = arcpy.mapping.MapDocument('CURRENT') lyr = arcpy.mapping.Layer(dataset_to_process) arcpy.mapping.AddLayer(mxd.activeDataFrame, lyr, 'BOTTOM') del lyr del mxd arcpy.RefreshTOC() return If I experience any issues with his approach, i'll post back... otherwise, i'll consider his answer correct. Cheers!
... View more
02-15-2018
06:51 AM
|
1
|
1
|
764
|
POST
|
MakeFeatureLayer_management does not necessarily add the layer to a data frame. If you're running tools headless (without the ArcMap frontend,) there's no data frame for it to be added to, necessarily. You can use it to create layers in a script that are never seen by the user, to do all sorts of things, perform selections, etc... It's interesting to me that the add layer function worked (correctly or not) 'by name' vs... 'by layer', which isn't documented and should not really work at all... I'm still away from my machine, will get back to it shortly...
... View more
02-09-2018
06:10 AM
|
0
|
0
|
764
|
POST
|
Everyone, i'm on travel and will not be back at it until this Monday. I'll reply with my final resolution then. Please stand by for more.
... View more
02-08-2018
05:54 PM
|
0
|
0
|
764
|
POST
|
I have no clue how they implemented their C/C++/COM stuff, or how they wrapped it up in Python... So, who holds that reference is unknown to me.
... View more
02-06-2018
12:26 PM
|
0
|
0
|
1401
|
POST
|
Nod. Hence why I believe support suggested that I use the output from MakeFeatureLayer.. gar...
... View more
02-06-2018
12:10 PM
|
0
|
9
|
1401
|
POST
|
The whole reference reset thing seems like a hack... but I can see how that code could be doing something relevant under the hood. Yeah, my selection is non-programmatic, specifically by a user in the data view. Then the next geoprocessing tool is suppose to 'pick up on' the selection. I think one of the ESRI devs likely missed something when implementing the AddLayer function for a layer that was created via MakeFeatureLayer... . . mayyyybe someone from support is willing to chime in?
... View more
02-06-2018
12:03 PM
|
0
|
2
|
1401
|
POST
|
Also, turn that 'automatically add' geoprocessing outputs off for this... you shouldn't have to have that on. It's more fun that way, trust me!
... View more
02-06-2018
11:59 AM
|
0
|
0
|
1401
|
POST
|
I appreciate your persistence and patience 🙂 You know how it goes probably, deep in a million problems and just want to get something done. My bad for posting a sample with a typo, that was a noob mistake. Happy to know others can bask in my misfortune now! Just imagine how strange it was to pin this down when it's working for some and not others because some analyst add layers directly from catalog (sometimes) while others use the tool (sometimes) and this will only fail consistently after the first time with the tool, that happens to use THIS code. . . . Oh! And, support did get back to me. There is a bug and they want me to hack around it by allowing MakeFeatureLayer to add the layer, which is a total HACK and reasonably unacceptable in terms of having an API that claims to support an AddLayer function... More to come!
... View more
02-06-2018
11:58 AM
|
0
|
0
|
1401
|
POST
|
James, I use the feature layer that was provided as an input to the tool within my function. I shouldn't have to List and search for it again, if it's given to me Also, I am not using the FIDSet for anything besides a little debug output. You could remove the lines from desc = arcpy.Describe(input_feature_class), all the way down to the 'no selection made' message if you want... same issue will surface. The problem has something to do with the way the layer was added... because any subsequent add of a layer with the same Name will experience the issue. Joe
... View more
02-06-2018
11:25 AM
|
0
|
19
|
1345
|
POST
|
MVP and GISP mean almost nothing to me personally. There are people who make careers out of accumulating thumbs ups, which is what it is... I've been doing this for years and typically do not have unlimited time to invest in forum interaction (reference the old, original esri forums...) There are two people who attempted to provided material value so-far on this issue, you and Joshua, and for that Thanks! Even with the silly typo, it's not difficult to reproduce this issue. If you change that text to new_layer, you'll see 🙂 Yes, I have opened an issue with ESRI support and a working .pyt with both sides of the tool. If there was an attach file option here, i'd use it!!
... View more
02-06-2018
10:29 AM
|
0
|
23
|
1345
|
POST
|
Haaaaaar 🙂 That was a self inflicted post-copy-pasta wound... But still a distraction from the real issue!!
... View more
02-06-2018
09:39 AM
|
0
|
0
|
1345
|
POST
|
Bah, copy/pasta typo... That line should be: arcpy.mapping.AddLayer(mxd.activeDataFrame, new_layer, 'BOTTOM')
... View more
02-06-2018
09:27 AM
|
0
|
2
|
1345
|
Title | Kudos | Posted |
---|---|---|
1 | 02-06-2018 12:48 PM | |
1 | 02-15-2018 06:51 AM | |
1 | 08-29-2013 03:49 AM | |
1 | 02-02-2014 08:50 AM | |
1 | 02-03-2014 11:32 AM |
Online Status |
Offline
|
Date Last Visited |
06-14-2024
05:13 AM
|