+ Reply to Thread
Results 1 to 14 of 14

Thread: Is it possible to start a model directly from an ArcMap-Toolbar?

  1. #1
    MOHAMMED HABBOUB
    Join Date
    Sep 2011
    Posts
    66
    Points
    3
    Answers Provided
    2


    0

    Default Is it possible to start a model directly from an ArcMap-Toolbar?

    Hello,

    Is it possible to start a model (generated from model builder) directly from an ArcMap-Toolbar? I don't want to start the toolbox just for one frequently used tool.
    I have 9.3 edition

    thanks
    MOHAMMED HABBOUB - Infrastructure Engineer

  2. #2
    MOHAMMED HABBOUB
    Join Date
    Sep 2011
    Posts
    66
    Points
    3
    Answers Provided
    2


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    Anyone can help?
    MOHAMMED HABBOUB - Infrastructure Engineer

  3. #3
    Dan Lee

    Join Date
    Oct 2009
    Posts
    583
    Points
    143
    Answers Provided
    27


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    The capability of adding your own toolbar and tools (models, scripts, or system tools) is in ArcGIS 10, but not in 9.3. What you can do is to create your own toolbox and add any of the above tools to it. This video shows how:
    http://webhelp.esri.com/arcgisdeskto...Spatial_10.htm

    Hope that helps.
    Dan (Geoprocessing)

  4. #4
    MOHAMMED HABBOUB
    Join Date
    Sep 2011
    Posts
    66
    Points
    3
    Answers Provided
    2


    1

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    Hi,
    I have wrote this code, but an error appears (see image):

    Option Explicit
    Private Sub UIButtonControl1_Click()
    Public Sub Test()



    Dim pGP As Object

    Set pGP = CreateObject("esriGeoprocessing.GPDispatch.1")



    On Error GoTo EH

    pGP.AddToolbox ("D:\DRASTIC_MODEL.tbx")



    pGP.MyModel



    Exit Sub

    EH:

    MsgBox pGP.GetMessages(), vbOKOnly, "Test"

    End Sub


    End Sub


    reference: http://support.esri.com/en/knowledge...s/detail/31110


    Anyone can help?
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	error.gif‎
Views:	22
Size:	175.0 KB
ID:	14061  
    MOHAMMED HABBOUB - Infrastructure Engineer

  5. #5
    Nobbir Ahmed

    Join Date
    Jun 2010
    Posts
    327
    Points
    124
    Answers Provided
    17


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    You need to have two Sub or all the code in the Click event. Try this:

    First, the Click event method:
    Code:
    Private Sub UIButtonControl1_Click()
        ' Call the Test method
        Test()
    End Sub
    The second method (Test) is the worker method:
    Code:
    Public Sub Test()
        ' Put all code here
        Dim pGP as Object
        ......
        .....
        EH:
        MsgBox pGP.GetMessages(), ......
    End Sub
    Let us know how it goes.

  6. #6
    MOHAMMED HABBOUB
    Join Date
    Sep 2011
    Posts
    66
    Points
    3
    Answers Provided
    2


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    Hi,

    Well, I'm not sure that I did it right..

    In the first method, I did not get it (how could I call test() method?)... see image "FirstMethod"
    In second method, EH error appeared ... see image"Secondmethod"

    I know that I'm beginner in VB codes... but I have to learn

    Thanks in advance
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	FirstMethod.jpg‎
Views:	13
Size:	207.4 KB
ID:	14074   Click image for larger version

Name:	SecondMethod.jpg‎
Views:	16
Size:	262.8 KB
ID:	14075  
    MOHAMMED HABBOUB - Infrastructure Engineer

  7. #7
    Nobbir Ahmed

    Join Date
    Jun 2010
    Posts
    327
    Points
    124
    Answers Provided
    17


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    Your whole code should like this:

    Code:
    Option Explicit
    
    Private Sub UIButtonControl1_Click()
        ' Call the Test method
        Test()
    End Sub
    
    Public Sub Test()
        Dim pGP as Object
        Set pGP = CreateObject("esriGeoprocessing.GPDispatch.1")
    
        On Error GoTo EH
        pGP.AddToolbox ("D:\DRASTIC_MODEL.tbx")
        pGP.MyModel
        MsgBox pGP.GetMessages(), vbOkOnly, "Success"
        Exit Sub
    
    EH:
        MsgBox pGP.GetMessages(), vbOkOnly, "Error"
    
    End Sub
    Let us know what message do you get?

  8. #8
    MOHAMMED HABBOUB
    Join Date
    Sep 2011
    Posts
    66
    Points
    3
    Answers Provided
    2


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    error in "Test()" illustrated in image
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	error.jpg‎
Views:	12
Size:	178.6 KB
ID:	14080  
    MOHAMMED HABBOUB - Infrastructure Engineer

  9. #9
    Nobbir Ahmed

    Join Date
    Jun 2010
    Posts
    327
    Points
    124
    Answers Provided
    17


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    I don't have a VBA compiler right now. If you google with 'how to call a VB sub' you'll get plenty of examples. I guess the call to Test sub should be:

    Code:
    Private Sub UIButtonControl1_Click()
        Test
    End Sub
    Without the braces '(' and ')'.

  10. #10
    MOHAMMED HABBOUB
    Join Date
    Sep 2011
    Posts
    66
    Points
    3
    Answers Provided
    2


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    yes that's right, now both solutions (method 1 and 2) give the same result
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	error.jpg‎
Views:	16
Size:	269.6 KB
ID:	14081  
    MOHAMMED HABBOUB - Infrastructure Engineer

  11. #11
    Nobbir Ahmed

    Join Date
    Jun 2010
    Posts
    327
    Points
    124
    Answers Provided
    17


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    Let's take the issue off the forum. Email me at nahmed@esri.com - we'll post the summary once the issue is resolved. Thanks.

  12. #12
    MOHAMMED HABBOUB
    Join Date
    Sep 2011
    Posts
    66
    Points
    3
    Answers Provided
    2


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    Thanks a lot,
    MOHAMMED HABBOUB - Infrastructure Engineer

  13. #13
    MOHAMMED HABBOUB
    Join Date
    Sep 2011
    Posts
    66
    Points
    3
    Answers Provided
    2


    0
    This post is marked as the answer

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    Hello everybody,

    I found a solution for this problem.. in fact it's another code (see image) and it works

    reference: http://gis.stackexchange.com/questio...l-arcmap-9-3-1
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	Done.jpg‎
Views:	27
Size:	320.5 KB
ID:	14099  

  14. #14
    MOHAMMED HABBOUB
    Join Date
    Sep 2011
    Posts
    66
    Points
    3
    Answers Provided
    2


    0

    Default Re: Is it possible to start a model directly from an ArcMap-Toolbar?

    Thanks a lot, Mr. Nobbir Ahmed
    MOHAMMED HABBOUB - Infrastructure Engineer

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts