Hi all, In a drawing I am working on all text has line spacing type "Exact From Line Top". I would like to change this to "Exact". However, I would like to do it by means of VBA if possible. Could somebody help me with this? Many thanks in advance. Kind Regards, Loukas
Hi all,
In a drawing I am working on all text has line spacing type "Exact From Line Top". I would like to change this to "Exact". However, I would like to do it by means of VBA if possible. Could somebody help me with this?
Many thanks in advance.
Kind Regards,
Loukas
Hi Loukas,
type of line spacing is part of a text style setting. In terms of MicroStation VBA it is TextStyle.NodeLineSpacingType property with values defined by MsdTextNodeLineSpacingType.
Is this information enough for your?
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jan,
Thank you for your reply.
Unfortunately, my knowledge of VBA is not up to scratch and I am struggling to implement this code. I have tried various things but I get errors such as "Object needed". What I have done so far (I have to admit that I did it by using the macro recorder), I used the Select by Attributes in order to pick all the Text Nodes in my drawing. Then what I want to do is to change these selected objects to Line Spacing 2.0 and Line Spacing Type Exact. I achieved that by using the Change Text Attributes command (again with macro recorder). However, before running the code I always have to check whether the active Text Style has Spacing 2.0 and Spacing Type Exact.
Is there any way I can achieve spacing 2.0 and type exact without any manual input at all using VBA? Any help is much appreciated
Thanks,
yes, of course, it is possible. But it cannot be reached by macro recorder, but by writing VBA code and using object MicroStation API and MicroStation classes. I think it is more about a decision if you want to do it by yourself (which means you have to study VBA and MicroStation VBA) or you choose somebody will write the macro for you.
BTW Did you read MicroStation VBA help? Besides classes description there is plenty of examples also.
My preference would be to write it myself but unfortunately with the company asking for it to be done asap, I don't have the luxury of studying first and then doing it. I have already started studying VBA anyway though.
I have gone through the Help files in Microstation but as you would imagine I didn't manage to write to code just by reading the help files.
attached VBA macro search an active design file, finds all text nodes and change Line spacing type = Exact and Line Spacing = 2.0.
I hope it will help you,
Many thanks for the code and sorry for the late reply (too many bank holidays lately in the UK!)
I just tried the code you sent me. It changes the line spacing to 2 and the line spacing type to Exact. However, it moves the second line of text (if it is let's say a two line text) to an area far away from the first line of the text, either above or below from the original position. It leaves the first line of the text at its' original position.
Any ideas why it is doing that?
Just figured the problem out. It was a matter of switching to the correct Units.
Again, many thanks for your help. I really appreciate it.