Hi all! I am running into issues while running a VBA macro that I have written, to scan the file for a text node and change it's text attributes like font, height, width and line spacing. My main problem is when I send a key-in to set 0.8 as value for line spacing, Microstation is automatically adjusting the line spacing value to something else rather than what I have specified in the VBA code. Doing some research, I got to know that the line spacing value is a multiplier of the text height. I am trying to run this macro in a batch process to do the same thing in a bunch of files and it is working in some files where it takes 0.8 as the multiplier and sets the actual line spacing distance to 3ft (since I have set the text height to 3.75ft) but in some cases Microstation is setting 0.8ft as the actual distance and is modifying my line spacing value to 0.2133. Did anyone run into a similar issue using Microstation VBA? Any suggestions on how to tackle this issue is deeply appreciated. I am attaching my code for the VBA below for reference. Thanks in advance.
Code:
Sub Bmrtest() Dim startPoint As Point3d Dim point As Point3d, point2 As Point3d Dim lngTemp As Long Dim oMessage As CadInputMessage
' Send a keyin that can be a command string CadInputQueue.SendKeyin "MDL SILENTLOAD SELECTBY dialog"
CadInputQueue.SendKeyin "DIALOG SELECTBY "
' Start a command CadInputQueue.SendCommand "SELECTBY LEVEL G-ANNO-TEXT"
CadInputQueue.SendCommand "SELECTBY LEVEL G-ANNO-TEXT"
' Set a variable associated with a dialog box SetCExpressionValue "selectorGlobals.typemask[0]", 5073, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[1]", -1224, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[2]", -30, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[3]", -1, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[4]", -1, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[5]", -8257, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[6]", -257, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[7]", -1, "SELECTBY"
CadInputQueue.SendKeyin "SELECTBY EXECUTE "
CadInputQueue.SendKeyin "MODIFY TEXT "
SetCExpressionValue "tcb->msToolSettings.changeText.textstyle", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.general.useFence", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.font", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.height", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.width", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.linespace", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.linespacetype", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.interchar", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.slant", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.linelength", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.underline", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.vertical", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.viewind", 0, "MODIFY" SetCExpressionValue "tcb->msToolSettings.changeText.just", 0, "MODIFY"
SetCExpressionValue "tcb->msToolSettings.changeText.height", 1, "MODIFY" CadInputQueue.SendKeyin "th=3.75" SetCExpressionValue "tcb->msToolSettings.changeText.width", 1, "MODIFY" CadInputQueue.SendKeyin "tw=3.75" SetCExpressionValue "tcb->msToolSettings.changeText.font", 1, "MODIFY" CadInputQueue.SendKeyin "ft=513"
SetCExpressionValue "tcb->msToolSettings.changeText.linespace", 1, "MODIFY" CadInputQueue.SendKeyin "ls=0.8" SetCExpressionValue "tcb->msToolSettings.changeText.just", 1, "MODIFY" CadInputQueue.SendKeyin "active tnj cc"
' Coordinates are in master units startPoint.X = 0 startPoint.Y = 0 startPoint.Z = 0
' Send a data point to the current command point.X = startPoint.X point.Y = startPoint.Y point.Z = startPoint.Z CadInputQueue.SendDataPoint point, 1
CommandState.StartDefaultCommandEnd Sub
This link has some suggestions
Additional resourcesMVBA FAQTextExamples.mvba - C:\ProgramData\Bentley\MicroStation CONNECT Edition\Configuration\WorkSpaces\Example\WorkSets\MetroStation\Standards\Macros\