This question is spawned off from the http://communities.bentley.com/Products/MicroStation/MicroStation_-_all_pre-V8_versions/f/142/t/38062.aspx question of text ranges and view dependent versus independent. Additionally it may provide a sample to the previous question in this vba forum.
Now to the question. How to set the textnodeelement to dependent\independent if the property is read only? I can record a macro using the Selectby Attributes and it will let me change the property but the following code is cleaner but will not work on the text nodes (it does on just text). Just curious and learning.
Sub scanTextDep() Dim oElEnum As ElementEnumerator Dim oElScan As ElementScanCriteria Dim oele As Element Dim userTextDep As Boolean
' True makes all Dependent text independent ' False makes all Independent text dependent userTextDep = False
Set oElScan = New ElementScanCriteria oElScan.ExcludeAllTypes oElScan.IncludeType (msdElementTypeText) oElScan.IncludeType (msdElementTypeTextNode) On Error Resume Next Set oElEnum = ActiveModelReference.Scan(oElScan) While oElEnum.MoveNext Set oele = oElEnum.Current If oele.IsTextElement Or oele.IsTextNodeElement Then oele.AsTextElement.IsViewIndependent = userTextDep oele.AsTextNodeElement.IsViewIndependent = userTextDep ' error here on node property End If oele.Redraw msdDrawingModeNormal oele.Rewrite Wend End Sub
Here is the recorded macro that works.
Sub Macro1() Dim startPoint As Point3d Dim point As Point3d, point2 As Point3d Dim lngTemp As Long
MsgBox ("This will make all text view dependent") ' Start a command CadInputQueue.SendCommand "MDL SILENTLOAD SELECTBY dialog"
CadInputQueue.SendCommand "DIALOG SELECTBY "
' Set a variable associated with a dialog box SetCExpressionValue "selectorGlobals.typemask[0]", 5009, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[1]", -1223, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[2]", -30, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[3]", -1, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[4]", -1, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[5]", -65, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[6]", -257, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[7]", -1, "SELECTBY"
SetCExpressionValue "selectorGlobals.typemask[0]", 5073, "SELECTBY"
SetCExpressionValue "selectorGlobals.viewdependentButton", -1, "SELECTBY"
SetCExpressionValue "selectorGlobals.viewdependent", 1, "SELECTBY"
CadInputQueue.SendCommand "SELECTBY EXECUTE "
Dim modalHandler As New Macro1ModalHandler AddModalDialogEventsHandler modalHandler
' The following statement opens modal dialog "Alert"
CadInputQueue.SendCommand "MODIFY TEXT "
SetCExpressionValue "tcb->msToolSettings.changeText.viewind", 1, "MODIFY"
point.X = startPoint.X + 7.350986 point.Y = startPoint.Y - 16.868578 point.Z = startPoint.Z CadInputQueue.SendDataPoint point, 1
CadInputQueue.SendCommand "MDL UNLOAD SELECTBY"
RemoveModalDialogEventsHandler modalHandler CommandState.StartDefaultCommand End Sub