Not sure what you are trying to do with this code. You loop through the layers in an MXD and check if the name equals "CNNDB". If that's the case you try to set a variable "addlayer". I don't think you should try to create a layer from a layer object.

Next you try to add the layer to the dataframe (where the layer already exists), although the code does not run that far. And you intent to export the map to PDF. Is the loop through your layer really useful?

I see you are trying to create a new MXD through python by just accessing a non existing mxd file in a just created folder. That will not work. See the blog post below with an example of using ArcObjects inside Python for that purpose.

Is this your full code? Do you have any try/except clauses in there that might be hiding earlier exceptions?

I can't see how you would even get to `arcpy.mapping.AddLayer(newdf,addlayer,"AUTO ARRANGE")` as the `addlayer = arcpy.mapping.Layer(lyr)` would raise an exception anyway as `lyr` is a layer object, not a string.

Also, the AddLayer method will raise an exception as "AUTO ARRANGE" is an invalid value, it must be one of ['TOP', 'AUTO_ARRANGE', 'BOTTOM'] Note the "_" underscore in "AUTO_ARRANGE".

This is untested and I have not fully vetted this, but I think you can try to reference the path name instead of trying to add the layer from another .mxd. You can use arcpy.Describe to get the fully qualified path of the layer:

Is it possible that making a conventional toolbox (*.tbx) would have been a simpler approach? I am just wondering why you have opted for this level of complexity when the tasks to perform seem relatively simple? I am a curious as to what routes people take (ie ArcObjects, versus Addins vs tbx's versus standalone applications)

but for the"convert labels to annotation", is there a simple way to ingrate it into a python script ? (because that's what makes me lose time, imagine I have more than 500 shapefiles to create and then convert all the labels to annotation to export all of them to CAD).

That's why I was asking you to understand the "add layer" , to after activate the labels and then convert into annotation, all of this in the same python script.

I just whipped this together, and it doesn't fully meet your requirments but it does the first half of your task. You will need to get the rest implemented (from converting to anno onwards). Also, I ran into little problems that mostly got solved by NOT using .shp files and just setup File Geodatabases --- which is not a bad plan anyway. Especially dealing with rasters for some reason, processing them outside of .gdb's is kwirky.