Select to view content in your preferred language

VBA Arcobject Code to VBScript

3222
5
06-03-2010 07:22 AM
BalajiViswanathan
Deactivated User
Hi,

We have developed a tool in VBA, which creates a triangle (Closed polyline) for each point in a shapefile at a specified angle with reference to the adjacent point. We created a Userform with required parameters and the tool is working fine in VBA environment.

My objective is to get the same tool in the Toolbox, for which i need to convert my VBA userform code to VBScript.

VBA code:

Dim pWS As IWorkspaceFactory
Set pWS = New ShapefileWorkspaceFactory

Dim pFWS As IFeatureWorkspace
Set pFWS = pWS.OpenFromFile("C:\", 0)

How do i convert similar VBA code into VBScript using Arcobject libraries?

Guide me on this.....


Regards,
Balaji Viswanathan.
0 Kudos
5 Replies
AlexanderGray
Honored Contributor
I don't think you can convert this.  If you need to write a tool in vbscript to put in the toolbox, you would use the geoprocessing framework or api.  The ArcGIS help (not developer help) has a lot of information (mostly python) on how to use the GP object and how to use GP cursors and geometries.

You can write arcobjects api code and put it into the toolbox but you would need to write a dll that implements IGPFunction and IGPFunctionFactory.  You cannot do that in VBScript. 

The function you describe seems possible to do within the GP api but you need to re-write the code against that API.
0 Kudos
BalajiViswanathan
Deactivated User
Thanks for your suggestion.

Then, how about implementing the Arcobjects interfaces (same VBA code) in PythonScript and adding it to a toolbox?
Is this feasible?


Regards,
Balaji Viswanathan.
0 Kudos
AlexanderGray
Honored Contributor
The only way I know of creating an ArcObjects tool in the toolbox is to make it a DLL and implement IGPFunction.  In Python you would use the Geoprocessing API which is a different API than ArcObjects.  I don't know about using ArcObjects in python.  The problem I could forsee is how to convert com objects from the ArcObjects API to gp objects.  I have only seen arcobjects being used as a compiled code.
0 Kudos
BalajiViswanathan
Deactivated User
Hi,

Thanks for your reply.

Even i m new to Programming arcobjects in python.
It would be great if you provide me a simple vb/vb.net code using Arcobjects interfaces (like IWorkspacefactory, IFeatureWorkspace), which implements IGPFunctionfactory, which will help me to make similar changes to my code, compile it as DLL and add the object to ESRI Geoprocessing Function Factory catogory, so that i need not spend much time converting my code to python.


Regards,
Balaji.
0 Kudos
JamesCrandall
MVP Alum
Hi,

Thanks for your reply.

Even i m new to Programming arcobjects in python.
It would be great if you provide me a simple vb/vb.net code using Arcobjects interfaces (like IWorkspacefactory, IFeatureWorkspace), which implements IGPFunctionfactory, which will help me to make similar changes to my code, compile it as DLL and add the object to ESRI Geoprocessing Function Factory catogory, so that i need not spend much time converting my code to python.


Regards,
Balaji.



See if this helps:

http://resources.arcgis.com/content/kbase?fa=articleShow&d=31110


I've not done ANY of this type of integration with Python/Geoprocesseor, so I'm not going to be a good source.  But just doing a quick search at the EDN site shows quite a bit of discussion on this topic.  It seems the logical approach is to build your GP tools, add them to the ToolBox, then execute/access these custom GPtools from the IGpDispatch interface.

Good luck!
0 Kudos