Obtaining the name of the current data driven page via VB.NET?

960
8
12-12-2011 02:27 AM
MeToo
by
New Contributor
Another "Should be easy, but I am stuck" question...

How can I obtain the name of the current data driven page in ArcMap 10.0 using VB.NET?

The name is important, for ex., to get to the other record values associated with the current data driven page using IPrintAndExport.PageRow(IActiveView, PageName).

Thanks,
Dennis
0 Kudos
8 Replies
MeToo
by
New Contributor
I am still working on this, but here it goes:

As an SDK programmer, there is no way of obtaining the name of the current data driven page (DDP) in ArcGIS 10.0.

Thanks to the Esri 10.1 development team, a PageNameField property is now available in ArcGIS 10.1 Beta 1 and Beta 2. But unfortunately it's only available through ArcPy and Python.

The property value can theoretically be obtained in .NET by calling an Python/ArcPy script that would look like this (not yet tested):

[INDENT]#ReturnCurrentDDP_PageName.py
import arcpy
import mapping
mxd = mapping.MapDocument("CURRENT")
pageName= str(mxd.dataDrivenPages.pageRow(mxd.datadrivenpages.pageNameField.Name)) [/INDENT]

The "Leveraging ArcPy in a .NET application" help topic (http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000m0s000000) explains how to run a Python script from .NET and how to catch its returned value (the DDP page name in my case). Again, I have not yet fully implemented this.

Now, if you need access to other DDP dialog property values, you may be out of luck again! Several of those properties are not exposed in any SDK at this time.

This is the case for example for the source of the page number. This is the field that the <dyn type="page" property="number"/> dynamic text points to. [BTW, paradoxally, the page number field can actually be any text field, not just a numerical field and therefore can be used to display any textual information. It's different from the CurrentPageID.]

I have asked Esri to add at least a PageNumberField property to its ArcPy datadrivenpages class in the final release of ArcGIS 10.1. You may want to do the same. It's more likely going to happen if it's in high demand.

Personally, I was and still am very surprised that one can't create or modify data driven pages directly from ArcObjects and that one has to go through Python and ArcPy (http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//0038000000tt000000). I hope it's just a temporary 10.0 and 10.1 thing because it is more cumbersome and less reliable. Plus not all ArcObjects programmers are Python programmers...

Please note that ArcObjects offers means of publishing data through its IPrintAndExport and IPrintAndExportPageOptions interfaces. AO also offers a few very powerful and friendly members such as the IPrintAndExport:PageRow.

Despite the current limitations (due to their "young age"?), DDP and dynamic text are awesome!

My point here is that they could be even more powerful if programmers were given access to the Data Driven Page Dialog property values and in their SDK of choice. I hope and think it will just be a matter of time.

Still awake? 🙂 Comments, suggestions?
0 Kudos
MeToo
by
New Contributor
Back to this issue...

I am having a hard time passing a value from a python/ArcPy script back to VB.NET.

Any example on how to do this would be greatly appreciated.

Thanks,
Dennis
0 Kudos
MeToo
by
New Contributor
Wow, what a nightmare this has been! Way more complicated and slower that it should be, and the documentation is all over the place, if present at all.

While the "Leveraging ArcPy in a .NET application" help topic explains how to run a Python script from .NET and how to catch its returned value [Post-scriptum: actually it doesn't explain how to return a value!] , it is misleading and I expect useless to most people. It should be updated to better reflect the fact that it runs a Python script out-of-process, meaning that it must load the Python processor, arcpy, etc. each time it is called. This procedure takes about 15 seconds on my PC each time I need to run a 7-line Python script! I think this may have been the only way to call a Python script prior to ArcGIS 9.3.1.

A better and more current solution consists of taking advantage of the in-process functionality available to ArcToolbox tools. So, a custom toolbox must be created and tied to the Python script; the "Run in process" box checked, etc. The script must then be run using AO's IGeoProcessor.Execute() call on the script within the toolbox. The latter should return a value using arcpy.AddMessage() that should be captured in an AO's IGeoProcessorResult. The return value will include text that describes the "run" (the text that typically appears in a tool's process window) and, if successful, the useful information. The IGeoProcessorResult information must then be parsed to obtain the meaningful value (the name of the current data driven page in my example above).

It still takes about 5 seconds to run, which is very slow but significantly better than the 15. Another advantage of this procedure is that the script can be embedded in the toolbox and the latter password-protected.

All this because ArcObjects is missing a few data driven page properties and methods!

On the downside too, it's getting really complicated to package, digitally sign and update functionality that now includes (in my case) a COM component, an esriaddin, a toolbox, etc. All with their packaging idiosyncrasies.

My 2 cents...
0 Kudos
HelfriedBrunner
New Contributor
Thank you very much for your thread!
I now have the same problem as mentioned in your posting #1 and no solution without python.
0 Kudos
MeToo
by
New Contributor
Helfried:

I was told back in August/Sept. by Esri that this particular property would be added to ArcObjects in ArcGIS 10.1. I haven't checked it in the latest beta yet so I don't know if it's there.

Dennis
0 Kudos
VickiMartinez
New Contributor II
As far as I can tell there is still no way to access the page name of the current data driven page via ArcObjects 10.1 (i.e. no equivalent to the DataDrivenPages class in arcPy).  Is this true, or have I missed some documentation somewhere?  I also have a similar problem as the original post, but need to use C#. 

Thanks for any insight you might have.
0 Kudos
MeToo
by
New Contributor
Hi:

I had to focus on something else so haven't checked ArcGIS 10.1, but still need this functionality.

I would recommend contacting Esri Tech Support.

Good luck & please update this page with what you find out.

Thanks,
Denis
0 Kudos
VickiMartinez
New Contributor II
So we spoke to ESRI tech support and they said: "as of 10.1 DDP can only be accessed via ArcPy.  There are no current plans to add the equivalent functionality in ArcObjects in the future." 

Apparently, there is already an ArcObjects enhancement request for this issue.  So, I guess if you are interested in seeing this functionality, go to the Customer Care area and add your vote to see if it will be considered.

Sorry I don't have better news.
0 Kudos