#1 Thu 06 November 2008 15:11
Arcgis 9.2 - Emboutonner un modèle
Hello,
Vu sur la liste ESRI-L, une astuce pour mettre un modèle dans un bouton, que j'ai traduit au mieux possible.
1. Tout d'abord, créer un UIButton control via la barre de personnalisation.
2. Y écrire le code suivant via l'éditeur VBA (entre Private Sub UIButtonControl1_Click() et End Sub)
Code:
Private Sub UIButtonControl1_Click()
'Vérifier qu'il y a des références vers
'ESRI GeoprocessingUI Object Library et la
'ESRI Geoprocessing Object Library en allant
' dans Tools/References de l'éditeur VBA.
Dim pUID As New UID
pUID = "esriGeoprocessingUI.ArcToolboxExtension"
Dim pATBExt As IArcToolboxExtension
Set pATBExt = Application.FindExtensionByCLSID(pUID)
Dim pAtb As IArcToolbox
Set pAtb = pATBExt.ArcToolbox
Dim pTool As IGPTool
'* Cas 1 : Utiliser la ligne suivante pour un modèle perso et mettre l'autre en commentaire.
'* Remplacer "MonModele" par le nom du modèle perso.
'* ========================================
Set pTool = pAtb.GetToolbyNameString("MonModele")
'* Cas 2 : Utiliser la ligne suivante pour un modèle existant et mettre l'autre en commentaire.
'* Remplacer "buffer_analysis" par le nom du modèle de la Toolbox.
'* ================================
Set pTool = pAtb.GetToolbyNameString("buffer_analysis")
Dim pCommand As IGPToolCommandHelper
Set pCommand = New GPToolCommandHelper
pCommand.SetTool pTool
pCommand.Invoke Nothing
End Sub2.1 : Si c'est un modèle perso : Utiliser la ligne suivante pour un modèle existant et mettre l'autre en commentaire.
Code:
Set pTool = pAtb.GetToolbyNameString("MonModele")...avec "MonModele" par le nom de votre modèle.
2.2 Si c'est un modèle existant (de la toolbox) : Utiliser la ligne suivante pour un modèle existant et mettre l'autre en commentaire.
Code:
Set pTool = pAtb.GetToolbyNameString("buffer_analysis")...en remplaçant par le nom correct du modèle.
Robin
Ps : Message original :
-----Message d'origine-----
De : ARCVIEW-L [ARCVIEW-L@atlantis.esri.com] De la part de Bret Whiteley
Envoyé : jeudi 6 novembre 2008 01:01
À : ARCVIEW-L@atlantis.esri.com
Objet : [ARCVIEW-L] SUM - ModelBuilder Button create
Thanks to everyone who responded to my question about creating a button for
a model developed with Model-Builder. For those of you that emailed me
directly about this solution, I hope the below instructions are clear!
The process is very simple, and below is a summary of links to do this
yourself.
Firstly, Create a new UI BUtton Control through a toolbar customization:
http://webhelp.esri.com/arcgisdesktop/9 … I_Controls
Then, insert the code provided here in the VBA editor window - opens
directly for you if you follow the instructions above:
http://support.esri.com/index.cfm?fa=kn … mp;d=27277
Switch out "mymodel" with the NAME of your model - instructions are clear
here.
And Ta DA - it works!
Hors ligne


