Subscribe to this thread
Home - General / All posts - How to script the Transform Toolbar
Eric123458 post(s)
#10-Jul-15 21:33

I am trying to buffer a road network (line drawing) with the following code:

Sub Main

Document.ComponentSet("Roads Master 2").Open

Set ui = Application.UserInterface

ui.InvokeCommand "DrawingTransformBuffers"

Set dlg = ui.ModalDialog

dlg.ControlSet("EditTransformTarget").Text = "[All Objects in Roads Master 2]"

dlg.ControlSet("EditTransformOperation").Text = "[Buffers]"

dlg.ControlSet("EditTransformSource").Value = 3

dlg.ControlSet("EditTransformApply").Value = TRUE

dlg.Accept

End Sub

The error message states that Set dlg = ui.ModalDialog is incorrect. I used Set dlg = ui.Toolbars instead and then it states that the following line is incorrect. Is there another word I should use in stead of ControlSet ?

I can't find any manual with syntax or keywords anywhere to learn the language. There is also no dropdown suggestions when I code. I that available for manifold?

Thanks!

atomek

422 post(s)
#13-Jul-15 12:30

Put this function at the end of your code (behind End Sub):

Function transform3(scope,transformation,source)

 Set ui = Application.UserInterface

 With ui.toolbars("Transform").ControlSet

 .item("EditTransformTarget").Text = scope

 .item("EditTransformOperation").Text = transformation

 .item("EditTransformSource").Text = source

 .item("EditTransformApply").Push

 End With

End Function

And in your code call it with:

transform3("[All Objects in Roads Master 2]","Buffers","3")

Eric123458 post(s)
#22-Jul-15 01:20

Hi,

Thank you. That takes care of the error I get stating that the Set dlg = ui.ModalDialog is incorrect

But now I get an error message that the Function transform3(scope,transformation,source) has a syntax error, but don't see why.

This is what I have:

Sub Main

Document.ComponentSet("Roads Master 2").Open

Set ui = Application.UserInterface

ui.InvokeCommand "DrawingTransformBuffers"

Set dlg = ui.ModalDialog

dlg.ControlSet("EditTransformTarget").Text = "[All Objects]"

dlg.ControlSet("EditTransformOperation").Text = "Buffers"

dlg.ControlSet("EditTransformSource").Value = "3"

dlg.ControlSet("EditTransformApply").Value = "TRUE"

dlg.Accept

transform3 "[All Objects in Roads Master 2]","Buffers","3"

Function transform3(scope,transformation,source)

Set ui = Application.UserInterface

With ui.toolbars("Transform").ControlSet

.item("EditTransformTarget").Text = scope

.item("EditTransformOperation").Text = transformation

.item("EditTransformSource").Text = source

.item("EditTransformApply").Push

End With

End Function

End Sub

atomek

422 post(s)
#22-Jul-15 16:34

Function has to be declared after you end your sub so just take the whole function at put it AFTER End Sub, like I wrote in my post above ;) Besides I don't know what you're trying to achieve with DrawingTransformBuffers, I haven't heard of it (it's not in my Drawing menu). I'd recommend you replace the whole thing you're using with script below:

Sub Main

 Set ui = Application.UserInterface

 Document.ComponentSet("Roads Master 2").Open

 transform3 "[All Objects in Roads Master 2]","Buffers","3"

 ui.invokecommand("EditSelectNone")

End Sub

 

Function transform3(scope,transformation,source)

 Set ui = Application.UserInterface

 With ui.toolbars("Transform").ControlSet

 .item("EditTransformTarget").Text = scope

 .item("EditTransformOperation").Text = transformation

 .item("EditTransformSource").Text = source

 .item("EditTransformApply").Push

 End With

End Function

Eric123458 post(s)
#22-Jul-15 17:15

Thanks! That works perfectly!

I got the DrawingTransformBuffers from the InvokeCommand list that you can get from Manifold. (manifold.exe /clist:file.txt)

It's basically a huge list of commands that are available for user interface scripting using the InvokeCommand method of the UserInterface object into a text file.

I don't really know exactly what that means or what I'm doing to be honest. I'm trying to understand how to create scripts that can control the user interface, but finding it hard to find a source that really explains how that works. So I'm just trying out templates that I found and adjusting the code to do what I want it to do.

For instance, how do you know to use the .item or .item(EditTransformApply).Push

How can I find out what .Push or .item means or what other options there are instead of .item or .Push ?

Is this standard VB scripting language?

Sorry, I am trying to find a good starting point to learn instead of piecing things together.

Thanks again!!

Eric123458 post(s)
#22-Jul-15 17:17

For instance, to perform a spatial overlay, the following works perfectly and I tried to re-write it to control the transform toolbar which as you know didn't work well.

Sub Main

Document.ComponentSet("Delineated Catchment Area Rough Map").Open

Set ui = Application.UserInterface

ui.InvokeCommand "MapSpatialOverlay"

Set dlg = ui.ModalDialog

dlg.ControlSet("ComboBoxSource").Text = "[All Objects in CDP Surface Centroids Drawing Cropped]"

dlg.ControlSet("ComboBoxTarget").Text = "[All Objects in Delineated Catchment Area Rough]"

dlg.ControlSet("ComboBoxMethod").Text = "Points to containing areas"

dlg.Accept

End Sub

atomek

422 post(s)
#23-Jul-15 12:03

.push is just "push the button" (I think it's standard VB, just like .text and other properties of different types of controls in forms).

.item means an item from ControlSet. You can also refer to them with integers (e.g. item(0), item(1) etc.) and loop through them with a msgbox to see them all but easier way is to grab a panel/toolbar out of it's dock (click and hold the little "handle" of transform toolbar and drag it to middle of your screen), right click it's title bar and click "List controls..."

See screens in this topic

http://www.georeference.org/doc/user_interface_scripting.htm

Eric123458 post(s)
#27-Nov-15 08:07

Thank you! That was super helpful!

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.