Hi everyone, I using Microstation v8i, make a vba marco to change textstyle for textnode, allthings ok but linespacing is not change, I had an issue when try change linespacing for textnode using vba but it's not work, please help me:
Tn as textnodeElement
Te as textelement
Ss as elementenumerator
(...somecode here...)
Set ss=textnodes.getsubelements
Do while ss.movenext
Set te=ss.current
Te.linespacing=0.5
Te.rewrite
Loop
Tn.rewrite
Tn.redraw
End sub
When i try this, textnode linespacing was not change,
Hi,
the property .LineSpacing is readonly and can be applied to Textnodes.One approach could be to use the PropertyHandler class.This code example may help:
Sub linespaceTest() Dim ee As elementEnumerator Dim oPh As PropertyHandler Set ee = ActiveModelReference.GraphicalElementCache.Scan Do While ee.MoveNext If ee.Current.IsTextNodeElement Then Set oPh = CreatePropertyHandler(ee.Current) ' Dim s() As String ' s = oPh.GetAccessStrings If oPh.SelectByAccessString("LineSpacing") Then oPh.setValue (0.5) End If End If Loop End Sub
The two lines commented out are helpful to know which accessstrings are available for each element.
I hope this helps?
Best regards,Artur
Answer Verified By: Thinh Dai hiep
To change the line spacing for TextNodes in VBA, you can use the Bentley MicroStation API to access and change the required properties.
Thanks you, it's usefully !!
When I set: Set oPh = CreatePropertyHandler(ee.Current)
the Object oPh was not have any instance
Thinh Dai hiep said:the Object oPh was not have any instance
Can you check and share details what element (type, accessibility...) the ee.Current is?
When CreatePropertyHandler returns Nothing, usually the reason is that the element is not graphical (visible and editable by a user).
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point