Add new Text Elements

4369
10
Jump to solution
05-08-2013 06:55 AM
JamesCrandall
MVP Frequent Contributor
Is it possible to add a new Text Element to a layout view?  I am building a new Python Add-In and this ArcObjects developer is getting frustrated with the amount of limitations I am finding in the arcpy.mapping module.  (unfortunately, my development tools have been limited to python)

Help is appreciated.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MathewCoyle
Frequent Contributor
Currently the arcpy.mapping module contains no where near the functionality you can achieve with ArcObjects. There is no way I know of to create a new text element using arcpy.mapping. You can take an existing element and change the size, position, text, etc.

View solution in original post

0 Kudos
10 Replies
MathewCoyle
Frequent Contributor
Currently the arcpy.mapping module contains no where near the functionality you can achieve with ArcObjects. There is no way I know of to create a new text element using arcpy.mapping. You can take an existing element and change the size, position, text, etc.
0 Kudos
JamesCrandall
MVP Frequent Contributor
Currently the arcpy.mapping module contains no where near the functionality you can achieve with ArcObjects. There is no way I know of to create a new text element using arcpy.mapping. You can take an existing element and change the size, position, text, etc.


Thought so.  Bummer. 

I really hate to read things like "Oh, arcpy.mapping is a wrapper for ArcObjects" --- it lends one to believe that, okay I should be able to access X, but just a little differently. 


    VBA ruled! 


    .NET/COM is and was a lot of work but made me much more valuable as a developer.


    Now I get to instruct the user: "hey, first you need to add a text element.  ONLY then can this tool I am building for you work."


Okay thanks!
0 Kudos
JeffBarrette
Esri Regular Contributor
At 10.1, text and graphic elements can be cloned.  So you can author a single element with the font, color, etc and clone when needed elsewhere.  Arcpy does not allow you to change text color, font and many other properties directly although you can do it by setting the text string to include tags.

Jeff
0 Kudos
JamesCrandall
MVP Frequent Contributor
At 10.1, text and graphic elements can be cloned.  So you can author a single element with the font, color, etc and clone when needed elsewhere.  Arcpy does not allow you to change text color, font and many other properties directly although you can do it by setting the text string to include tags.

Jeff


Thanks for your input, Jeff.

So how exactly would that work?  I read thru some presentations from ESRI developer summit, but somethings are not fully clear.

1. Create an existing .mxd with the Text/Graphic elements I wish to have in the "CURRENT" .mxd document
2. Clone each of these.
3. Add to the the "CURRENT".

Something like that?

If so, how do I actually "add" the elements to the "CURRENT" .mxd?  I didn't see this method (or probably just missed it).
0 Kudos
JeffBarrette
Esri Regular Contributor
Clone() is a method on the text element or graphic element classes.

Check out the second example on the graphic element class.  It builds a dynamic table by cloning graphic lines and text.

http://resources.arcgis.com/en/help/main/10.1/#/GraphicElement/00s300000040000000/

Jeff
0 Kudos
JamesCrandall
MVP Frequent Contributor
Clone() is a method on the text element or graphic element classes.

Check out the second example on the graphic element class.  It builds a dynamic table by cloning graphic lines and text.

http://resources.arcgis.com/en/help/main/10.1/#/GraphicElement/00s300000040000000/

Jeff


Jeff,

I took a look at the example but I'm not understanding how this can help.  Now, I can setup an .mxd with all of the elements I need, and yes i can clone them, but how am I supposed to use these in the "CURRENT" mxd document?  That is, I still cannot add any graphic or text element to a map document.  (or can I and I am missing something from the example?)

To be clear: just how can the Clone() method help me to add TextElements to a totally vanilla (aka, "CURRENT") .mxd?

Thanks!
James
0 Kudos
JeffBarrette
Esri Regular Contributor
All "CURRENT" means is that your code is referencing the document that is currently loaded into the ArcMap application.  This means the code is being run from either the Python window or from a script tool from within ArcMap.

The document that is open should have all your extra stuff, often times tucked away off the page.  Your code can call it when/if needed.

Jeff
0 Kudos
JamesCrandall
MVP Frequent Contributor
All "CURRENT" means is that your code is referencing the document that is currently loaded into the ArcMap application.  This means the code is being run from either the Python window or from a script tool from within ArcMap.

The document that is open should have all your extra stuff, often times tucked away off the page.  Your code can call it when/if needed.

Jeff


Yes, I understand.  The problem I am running into is the Python Add-In I am developing must be agnostic to any specific .mxd document.  I just need the tool to place a text element onto the Layout, especially if it is just an "Untitled.mxd" / vanilla .mxd that has nothing loaded and was just opened.

Thanks again!
j
0 Kudos
markdenil
Occasional Contributor III
There is a way to access ArcObjects from python.

There is a Stack Exchange thread titled: How do I access ArcObjects from Python?
http://gis.stackexchange.com/questions/80/how-do-i-access-arcobjects-from-python
that gives some leads on this.

It IS, however, both exasperating and annoying to keep hearing things along the lines of
"python scripting is not intended to do things like <fill in simple task here>".
0 Kudos