this is a code from VBA...since ESRI now abandoned VBA I need it in python!

1075
10
06-05-2013 05:18 AM
DanielAmrine
Occasional Contributor
Attached is .py of the code converted to Python syntax....

however i need to call in arcpy and then change some more of the syntax to fit the current python language...I'm new to this and i was not very good with VBA....but we need this functionality in our workflow!! So any help is much appreciated!
Tags (2)
10 Replies
MathewCoyle
Frequent Contributor
VBA still works in ArcGIS... for now.

Also, you should describe your work flow and how you will be using this code as it is not at all apparent from your code alone.
0 Kudos
DanielAmrine
Occasional Contributor
VBA still works in ArcGIS... for now.

Also, you should describe your work flow and how you will be using this code as it is not at all apparent from your code alone.


1.) How does VBA still work? I know 10.0 still supports it but you need the VBA extension. (A pain to get the authorization code)...
10.1 and beyond no longer supports VBA...supposedly.

2.) It's a complicated process....essentially we need to build rectangles along a polyline that overlap. this code allows you to set this dimensions of the rectangle/overlap then starts from the origin point in the polyine and uses the closest vertices (to the set dimensions) to angle and draw the rectangle.

3.) The original VBA code was meant to a be a macro that ran inside a map document referencing the first two layers in the mxd. My goal is to have this be a script tool with a polyline input parameter and polygon input parameter to add the rectangles to.

Dan
0 Kudos
MathewCoyle
Frequent Contributor
VBA is supported in the same manner in 10.1 as in 10.0. I'd imagine it is the same for 10.2 though I haven't used it yet.

How you describe your process seems simple enough, you shouldn't have too much trouble converting this to arcpy.
0 Kudos
RichardFairhurst
MVP Honored Contributor
VBA is supported in the same manner in 10.1 as in 10.0. I'd imagine it is the same for 10.2 though I haven't used it yet.


My understanding is that at 10.1 you can only read and run VBA code, but you cannot edit or create new VBA code.  At 10.2 it should be gone if ESRI follows through with the game plan they laid out over 3 years ago.  VBA is deprecated because Microsoft abandoned it and won't sell any more licenses.  ESRI is using up licenses they purchased years ago (probably when they partnered with Microsoft for a time).
0 Kudos
DanielAmrine
Occasional Contributor
How you describe your process seems simple enough, you shouldn't have too much trouble converting this to arcpy.


If I was more proficient at arcpy and python i would agree with you...with that said I would like to ask if I'm running the script from a tool inside a toolbox do i need to import the arcpy, is that always the first step, and then do i need to import other engines...shuch as sys, or os?

Thanks,
Dan
0 Kudos
MathewCoyle
Frequent Contributor
Try going through this tutorial, it covers most of the basics.

http://training.esri.com/gateway/index.cfm?fa=catalog.webCourseDetail&courseID=1868

You can search for other python seminars/courses in the training catalogue.
0 Kudos
RhettZufelt
MVP Frequent Contributor
My understanding is that at 10.1 you can only read and run VBA code, but you cannot edit or create new VBA code.  At 10.2 it should be gone if ESRI follows through with the game plan they laid out over 3 years ago.  VBA is deprecated because Microsoft abandoned it and won't sell any more licenses.  ESRI is using up licenses they purchased years ago (probably when they partnered with Microsoft for a time).


This is not true.  I am able to create and run VBA code in my 10.1 project.  The big difference is that you can no longer store VBA in the Normal.mxt and must be stored in the project itself.  (which really sucks as I have some VBA that I like to have available by default.)

R_
0 Kudos
MarcoBoeringa
MVP Regular Contributor
My understanding is that at 10.1 you can only read and run VBA code, but you cannot edit or create new VBA code.  At 10.2 it should be gone if ESRI follows through with the game plan they laid out over 3 years ago.  VBA is deprecated because Microsoft abandoned it and won't sell any more licenses.  ESRI is using up licenses they purchased years ago (probably when they partnered with Microsoft for a time).


That plan certainly has changed.

The recently modified deprecation plans for ArcGIS now even explicitly list extension for VBA in 10.2 as the last release.

http://downloads2.esri.com/support/TechArticles/W26496_W25918_DEPRECATION_PLAN_FOR_ARCGIS_101_and_10...

"ArcGIS 10.2 will be the last major release including Microsoft Visual Basic for Applications (VBA) compatibility."

"[Correction February 15, 2013] Support for Microsoft VBA has been extended to ArcGIS 10.2"
0 Kudos
ChrisSnyder
Regular Contributor III
Per your original question, your code will require substatial rewrites to make it work via Python... slapping an import arcpy on the top ain't gonna cut it...

It does look somewhat complicated, but the programatic flow is basically already there.

This one would take a while to rewrite though, and is probably not as simple as some might think. For example, as far as I know there is no .rotate method property for geometry objects in Python (but I bet ESRI whats to make one!), so you would have to write the code to do that.
0 Kudos