The Wiki Blog

Last modified by superadmin on 2008/11/26 06:11

Oct 29 2015

Increase Numeric Part of Text in Microstation

Not long ago a posted my general approach for Replacing Text in Microstation.

I updated that macro and it now is able to increasing  the numeric part of any text in Microstation. The text could be plain text, a textnode or text encapsulated in a cell.

If you are interested in this macro, just contact me.

Here is a short description of what I did.

It demonstrates how easy it is to extend the macro with new replacing functions.

1) Write the vba code to increase the numeric part of a text in vba. To achieve that I searched the web for an appropriate example and came up with this. I modified it to meet the specs of the macro. Especially the return values for the new text and the status must the put in the global variable M_NEWTEXT and M_RETURN.

1) Write a piece of code that does it.

Public Function IncreaseNumericPartByOne() As Boolean

    Dim iCount As Integer, numberStart As Integer, numberEnd As Integer

    Dim sText As String, strNeg As String, strDec As String


    Dim vVal As String
    Dim increaseBy As Double
     
    increaseBy = 1
    sText = M_THETEXT

    strNeg = "-"

    strDec = "."


    numberStart = 0
    numberEnd = 0

    For iCount = 1 To Len(sText)

       vVal = Mid(sText, iCount, 1)
       If IsNumeric(vVal) Or (vVal = strNeg And numberStart = 0) Or vVal = strDec Then
         If numberStart = 0 Then
           'FIRST NUMBER CHAR
           numberStart = iCount
         End If
         numberEnd = iCount
       Else
         If numberStart = 0 Then
          'Number not yet started
         Else
          'Enb of Number reached
          Exit For
         End If
       End If
    Next iCount
   
    If numberStart = 0 Then
     'SORRY NO NUMBER - SET GLOBAL VARIABLE
     M_RETURN = False
    Else
     If numberEnd = 0 Then
      numberEnd = Len(sText)
     
     End If
     'BANG: A NUMBER - SET GLOBAL VARIABLES
     M_NEWTEXT = Left(sText, numberStart - 1) + CStr(CDbl(Mid(sText, numberStart, numberEnd - numberStart + 1)) + increaseBy) + Right(sText, Len(sText) - numberEnd)
     M_RETURN = True
    End If
    IncreaseNumericPartByOne = M_RETURN

End Function

2) Populate your code to make it available through the interface by just adding a line in the InitTextReplaceFunctions.

Public Function InitTextReplaceFunctions()
 Set M_TEXTREPLACEFUNCTIONS = New Collection


 M_TEXTREPLACEFUNCTIONS.Add "IncreaseByOneIfNumeric"
 M_TEXTREPLACEFUNCTIONS.Add "IncreaseNumericPartByOne"
 'your stuff
End Function

Done.

Oct 23 2015

Replacing Text in Microstation using any formula

This is an VBA approach to create a powerful tool that allows you to replace text in your dgn-files. 

It replaces text regardless if it is in a simple text element, a text node or a cell.

The cool thing is that you can use any text replace function you can think of.

You just write a small piece of VBA Code that does the text manipulation.

This is manageable, even for newbies. And you will find a lot of example code in the web.

Here is an example:

Assume you just want to increase every text that is a number by the amount of one. That is: [newtext] = [oldtext]+1

1) Write a piece of code that does it.

Public Function IncreaseByOneIfNumeric() As Boolean
 'Check if it is a number
 If IsNumeric(M_THETEXT) Then
   'set a new value by increasing the old one
   M_NEWTEXT = CStr(CDbl(M_THETEXT) + 1)
   'say that the change should change the element
   M_RETURN = True
 Else
   M_RETURN = False
 End If
End Function

2) Run the tool.

textreplace_screen_1.png

Done.

If you are interested in this tool just contact me.

Its free.

Edit: Please find another example in this blogpost: Increase Numeric Part of Text in Microstation

Sep 17 2015

Subreports in BIRT

BIRT is not able to include subreports the way most other reporting tools do. That makes it hard to reuse reportdesigns. Here is a little workaround to allow BIRT to make use of subreports:

1) Design your subreport and put it in your servers report dir. 

2) Create a text field in the your master report. Enter the location of the subreport. (As you would enter in the __report URL Parameter)

3) Add a "onCreate" Script portion:


importPackage( Packages.java.io );
importPackage( Packages.java.net );

var url = reportContext.getHttpServletRequest( ).getRequestURL().toString();
var viewerurl=url.substring(0, url.length() - reportContext.getHttpServletRequest( ).getRequestURI().length()) + reportContext.getHttpServletRequest( ).getContextPath() + "/";
url=viewerurl+"preview?__format=HTML&__report="+this.text;
var instream = new BufferedReader(new InputStreamReader(new URL(url).openStream()));

var completeHTML = "";
var lineHTML = "";


while((lineHTML = instream.readLine()) != null) {
    completeHTML+=lineHTML;
 }
instream.close();
this.text = completeHTML;

 

If you have questions, please contact me.

Jul 03 2015

Copy Message Text to Clipboard

Sometimes you may want to copy the MessageCenter text into the clipboard.

This is very complicated as you have to open the MessageCenter and do some very strange mouse clicks.

Use this little vba to do it by hitting a function key or even automate it completely, so the clipboard will be refreshed every 1/2 second with the newest MessageCenter text.

How to use:

a) Load or Autoload the vba.

b) keyin vba run Clipboard.CopyLastMessageToClipBoard to copy the message into the clipbard

c) keyin vba run Clipboard.HookClipboardToMessageCenter to automate copying.

Download it here.

Have fun.

Jun 30 2015

Microstation VBA - Change Text Fonts in Cells

Use this macro to find all instances of a certain named cell and replace the font property for texts in the cell.


Sub ChangeFontInCells()

    Dim cellname As String
    Dim oldfontname As String
    Dim newfontname As String
   
    cellname = "Textzelle"
    oldfontname = "Arial"
    newfontname = "Bodoni MT"
   
    ActiveModelReference.UnselectAllElements
    Dim scanfor As ElementScanCriteria
    Dim enu As ElementEnumerator
    Set scanfor = New ElementScanCriteria
    scanfor.ExcludeAllTypes
    scanfor.IncludeType msdElementTypeCellHeader
   
    scanfor.IncludeOnlyCell cellname
   
    Set enu = ActiveModelReference.Scan(scanfor)
    Do While enu.MoveNext
        Dim cel As CellElement
        Dim cellpart As Element
        Dim textelement As textelement
        Dim cellenu As ElementEnumerator
        Set cellenu = enu.Current.AsCellElement.GetSubElements
        Do While cellenu.MoveNext
          Set cellpart = cellenu.Current
          If cellpart.IsTextElement Then
            Set textelement = cellpart.AsTextElement
            If textelement.TextStyle.Font.Name = oldfontname Then
               Dim nf As Font
               Set nf = ActiveDesignFile.Fonts.Find(msdFontTypeWindowsTrueType, newfontname)
               If nf Is Nothing Then
                    Set nf = ActiveDesignFile.Fonts.Find(msdFontTypeMicroStation, newfontname)
               End If
               If Not (nf Is Nothing) Then
                Set textelement.TextStyle.Font = nf
                textelement.Rewrite
               End If
            End If
          End If
        Loop
       
    Loop
End Sub

Dec 27 2014

Microstation VBA - Replace Text in Cells

Use this vba code to replace texts in cell elements.

 Dim search_text As String
 Dim replace_text As String

Private Function ReplaceTextInCell(el As Element) As Boolean

 Dim cel As CellElement
 Dim ret As Boolean
 Dim tel As TextElement
 ret = False
    Set cel = el
    cel.ResetElementEnumeration
    Do While cel.MoveToNextElement(True)
        Dim eleTemp As Element
        Set eleTemp = cel.CopyCurrentElement
        If eleTemp.IsTextElement Then
            Set tel = eleTemp
            If tel.Text = search_text Then
                tel.Text = replace_text
                ret = True
                cel.ReplaceCurrentElement tel
            End If
        End If
    Loop
    ReplaceTextInCell = ret
End Function

Public Sub ReplaceAllTextsInModel()


 'USE THIS TO SET THE REPLACEMENT BY CONFIGURATION VARIABLE
 'search_text = ActiveWorkspace.ExpandConfigurationVariable("SEARCH_TEXT")
 'replace_text = ActiveWorkspace.ExpandConfigurationVariable("REPLACE_TEXT")
 search_text = "Test"
 replace_text = "Blubber"
 Dim e As ElementEnumerator
 Dim es As ElementScanCriteria
 Dim el As Element
 Set es = New ElementScanCriteria

 Set e = ActiveModelReference.Scan(es)
 Do While e.MoveNext
    Set el = e.Current
    If (el.IsCellElement) Then
        If ReplaceTextInCell(el) Then
          el.Rewrite
        End If
    End If
 Loop
End Sub

If you have further questions than contact me.

Jan 01 2014

Microstation and NAS

Do you need a tool to import NAS data (ALKIS data format) into Microstation? Then you should consider to use spatialgateway. Its allows you to read and to write NAS data.
 

Dec 29 2013

spatialgateway ready

logo_spatialgateway_150.png We are glad to announce spatialgateway ready for trial and purchasing.
spatialgateway allows you to read and write almost every geo data format into your  Microtation dgn.
spatialgateway is driven only by a xml file.
Just a short feature list:

  • faster than Bentley Map when using Oracle
  • Build Live-Backgrounds that read only the geodata for the view area
  • Formats: Oracle, shp, ArcSDE, NAS, GML, .... 
  • Attribute mapping
  • Database attributes as ECObjects, Links, Tags, Labels

Please visit the web page to read more.... 

Dec 03 2013

Issue in Bentley Map SS3

I got an issue in Bentley Map SS3 (German Version).
If you try to update any feature against an oracle spatial database, Bentley Map raises the following error.

screenshot.png

To solve it, you have to manually add the following registry keys into your registry.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Westeuropäische Normalzeit]
"Display"="(GMT+01:00) Amsterdam, Berlin, Bern, Rom, Stockholm, Wien"
"Dlt"="Westeuropäische Sommerzeit"
"Std"="Westeuropäische Normalzeit"
"MapID"="2,3"
"Index"=dword:0000006e
"TZI"=hex:c4,ff,ff,ff,00,00,00,00,c4,ff,ff,ff,00,00,0a,00,00,00,05,00,03,00,00,\
  00,00,00,00,00,00,00,03,00,00,00,05,00,02,00,00,00,00,00,00,00

Jul 14 2013

Rasterguard for Microstation

Are you anoyed by unintended raster modifications in Microstation V8i?

rasterguard is protecting your raster data against any modification of the raster position. All other modifications are possible. You dont have to lock and unlock your raster any more. Autoload rasterguard in every Microstation session and your hassle is gone.

You can download rasterguard as a free tool. Please send a feedback, if you are satisfied with the tool. 

Tags:
Created by superadmin on 2005/01/28 16:50
    
microTest - A Microstation Test Framework
centauron - geosoftware & consulting