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
Thank you Jan, I figured it out meanwhile. Many thanks for your contribution. : best regards, 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...
Implements ILocateCommandEvents
_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
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
Hi Nicolas,
NicolasT said:The VBA should allow to manually select the text in one box (click)
if the grid looks ike a regular matrix and both borders and texts can be easily indetified (a combination of level / color is not shared with any other element), it's even not necessary to select the text. Macro can be written in such way any click into a particular grid would be enough. But of course it requires some extra code to find surrounding grid borders and text inside. When grid is XY oriented (not rotated or slanted), it's not very complicated.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
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.