Hello,
Question with moving old V8i MicroStation Basic to Connect Edition VBA (or macro recorder).
Starting from a DGN that has a rectangular matrix (mesh/ grid?) over the map of the country. In each case (box) of the DGN matrix we have a text element (e.g. 511S1).
The VBA should allow to manually select the text in one box (click), save that text in a variable and then attach the corresponding raster ref file which is the topographical Map matching that specific box.
So the macro should in this example attach raster ref "511S1.tif" (not intercative)., which is the text string captured by the selection + the ".tif" string.
I searched a lot but can not find the trick to save that text content in a var in VBA.
Thank you very very much in advance for your help,
Best regards,
Nicolas Tobbackx
NicolasT said:I searched a lot but can not find the trick to save that text content in a var in VBA
' Locate a text element Dim oText As TextElement ... Dim strMapID As String strMapID = oText.Text & ".tif" Debug.Print "Map ID=" & strMapID
NicolasT said:The VBA should allow to manually select the text
Write a class that Implements ILocateCommandEvents. Some of the examples here show how to use that interface.
Implements ILocateCommandEvents
Regards, Jon Summers LA Solutions
Thank you very much indeed Jon, and Jan :)
Sorry for the delay -doing too many things at the same time - I succeeded in getting my VBA to work. Now it works fine on the text elements I select (Datapoint) on text in my active file. But the text from reference files do not not get selected when clicking on it. While the MicroStation select function works OK, so all refs have locate on.
How can I make the VBA also select text (datapoint) from the reference files. Searching for doc about this seems only to activate one single ref.
Thank you very much in advance for your advice,
Nico
NicolasT said:How can I make the VBA also select text (datapoint) from the reference files
Assuming that you've written a class that Implements ILocateCommandEvents, then you can modify the _Start method. You can see this example (Analyze Arc) in VBA help...
_Start
Private Sub ILocateCommandEvents_Start() Dim lc As LocateCriteria ' Since this command does not modify the original element, ' set the locate criteria to allow read-only elements. Set lc = CommandState.CreateLocateCriteria(False) CommandState.SetLocateCriteria lc ShowCommand "Analyze Arc Example" ShowPrompt "Select an arc" End Sub
The relevant part is LocateCriteria. Reference attachments are read-only, so copy this code to do what you want.
LocateCriteria