Ok, I see many posts on people wanting to convert text into data fields and still contain the text values within the data field. I also see replies that so far this is not possable. I know there are people out there that are way far more advanced with MicroStation programing than me as I am still a beguinner. I would like to post this suggestion & see if anyone can find a way to combine these following codes to obtain the goal everyone is searching for.
I myself have not yet found a way.
*******************************************************************************************************
code #1: This code utilizes the ILocateCommandEvents.....It actually takes a lowercase text & converts it to UPERCASE...
********************************************************************************************************
Module1
Sub tstLCE_Text() CommandState.StartLocate New LCE_Text ShowCommand "CAP Text" ShowPrompt "Select Text to be Capitalized"End Sub
--------------------------------------------------------------------------------------------------------------------------------------
ClassModule name= LCE_Text
Implements ILocateCommandEventsPrivate SelElement As Element
--------------------------------------------------------------------------------------------
Private Sub ILocateCommandEvents_Accept(ByVal Element As Element, Point As Point3d, ByVal View As View) Dim elemText As TextElement Set elemText = Element elemText.Redraw msdDrawingModeErase elemText.Text = UCase(elemText.Text) elemText.Redraw msdDrawingModeNormal elemText.Rewrite ActiveModelReference.UnselectAllElements CommandState.StartDefaultCommand End Sub
Private Sub IlocateCommandEvents_Cleanup()
End Sub
Private Sub IlocateCommandEvents_Dynamics(Point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode)
Private Sub IlocateCommandEvents_LocateFailed() If SelElement Is Nothing = False Then ActiveModelReference.UnselectAllElements Set SelElement = Nothing End If ShowCommand "CAP Text" ShowPrompt "Select Text to be Capitalized" End Sub
Private Sub IlocateCommandEvents_LocateFilter(ByVal Element As Element, Point As Point3d, Accepted As Boolean) Accepted = False If Element.IsTextElement = True Then Set SelElement = Element Accepted = True ActiveModelReference.SelectElement Element, True ShowCommand "CAP Text" ShowPrompt "Click to Confirm" End IfEnd Sub
Private Sub ILocateCommandEvents_LocateReset() CommandState.StartDefaultCommandEnd Sub
Private Sub ILocateCommandEvents_Start()
**************************************************************************************************
code #2: This code is a recording from activating the word processor dialog & inserting Enter Edit DataFields.....
Sub Macro2() Dim startPoint As Point3d Dim point As Point3d, point2 As Point3d Dim lngTemp As Long
Dim modalHandler As New Macro2ModalHandler AddModalDialogEventsHandler modalHandler
' The following statement opens modal dialog "Edit Enter Data Field"
' Start a command CadInputQueue.SendCommand "WORDPROCESSOR EDIT TEXT"
' Coordinates are in master units startPoint.X = 100015.10679819 startPoint.Y = 100013.415608614 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
' Send a message string to an application' Content is defined by the application CadInputQueue.SendMessageToApplication "WORDPROC", "1 selection 13 30"
CadInputQueue.SendMessageToApplication "WORDPROC", "1 changeEDF 17 TEXT TO DATAFIELD"
CadInputQueue.SendMessageToApplication "WORDPROC", "1 selection 15 34"
CadInputQueue.SendMessageToApplication "WORDPROC", "1 moveCaretToPosition 34"
point.X = startPoint.X + 1.68252246532938 point.Y = startPoint.Y point.Z = startPoint.Z CadInputQueue.SendDataPoint point, 1
point.X = startPoint.X + 1.68252246532938 point.Y = startPoint.Y + 0.310530102549819 point.Z = startPoint.Z CadInputQueue.SendDataPoint point, 1
RemoveModalDialogEventsHandler modalHandler CommandState.StartDefaultCommandEnd Sub
-------------------------------------------------------------------------------------------------------------------
Macro2ModalHandler
Implements IModalDialogEvents
---------------------------------------------------------------------------------------------------------------------
Private Sub IModalDialogEvents_OnDialogClosed(ByVal DialogBoxName As String, ByVal DialogResult As MsdDialogBoxResult)
----------------------------------------------------------------------------------------------------------------------
Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult)
If DialogBoxName = "Edit Enter Data Field" Then
' Remove the following line to let the user close the dialog box. DialogResult = msdDialogBoxResultOK
End If ' Edit Enter Data Field
Unknown said:Private Sub ILocateCommandEvents_Accept(ByVal Element As Element, Point As Point3d, ByVal View As View) ... ActiveModelReference.UnselectAllElements CommandState.StartDefaultCommand End Sub
You're mixing MicroStation idioms, which will confuse your user.
Regards, Jon Summers LA Solutions
Thank you all for your input so far, I appreciate all form of help or criticism....
We have a client that wants their drawings to be repaired while doing the engineering on them as well. Some of their other consultants have changed the borders & terminal block info. by using the word processor to edit data fields instead of the data field editor. That caused all the data fields to turn into regular text, so when we received the drawings they want us to change them back into data fields. I want to be able to just click on the text & then it would auto change into data fields while still containing the existing text info. These changes can take some time when there are over 100 individual lines of text per drawing. So if I used the Text Edit Dialog box (Not Word Processor) the text would look like this.....regular text = BLK data field text = <<BLK>>
I hope this clears up what I am trying to accomplish.
Ok, so I still figured it out. I have come close to the final code but I need it to restart after I converted the first text. Here is the code I have so far......
Module1...........................
Sub tstLCE_Text()
CommandState.StartLocate New LCE_Text
ShowCommand "Convert to DF"
ShowPrompt "Select Text to be Capitalized"
Sub Macro3()
Dim startPoint As Point3d
Dim point As Point3d, point2 As Point3d
Dim lngTemp As Long
' Start a command
CadInputQueue.SendCommand "WORDPROCESSOR EDIT TEXT"
CadInputQueue.SendDataPoint point, 1
CommandState.StartDefaultCommand
ClassModule............
LCE_Text
Implements ILocateCommandEvents
Private SelElement As Element
Private Sub ILocateCommandEvents_Accept(ByVal Element As Element, point As Point3d, ByVal View As View)
Dim elemText As TextElement
Set elemText = Element
elemText.Redraw msdDrawingModeErase
elemText.Text = "<<" & (elemText.Text) & ">>"
elemText.Redraw msdDrawingModeNormal
elemText.Rewrite
'activates the text edit command
CadInputQueue.SendKeyin "vba run macro3"
ActiveModelReference.UnselectAllElements
Private Sub IlocateCommandEvents_Dynamics(point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode)
Private Sub IlocateCommandEvents_LocateFailed()
If SelElement Is Nothing = False Then
Set SelElement = Nothing
End If
ShowCommand "CAP Text"
Private Sub IlocateCommandEvents_LocateFilter(ByVal Element As Element, point As Point3d, Accepted As Boolean)
Accepted = False
If Element.IsTextElement = True Then
Set SelElement = Element
Accepted = True
ActiveModelReference.SelectElement Element, True
ShowCommand "Convert"
ShowPrompt "Click to Confirm"
Private Sub ILocateCommandEvents_LocateReset()
Unfortunately this only works if the "text dialog box" is enabled in "Preferences" & NOT the "Word Processor". I would take any suggestions on how to fix this. Thank in advance...
Here is some code illustrating how you can change the default text editor from MicroStation VBA.
Public Const TEXTEDIT_DEFAULT As Long = 0 ' Default dialog editor Public Const TEXTEDIT_COMMANDWINDOW As Long = 2 ' Command window editor Public Const TEXTEDIT_WORDPROCESSOR As Long = 4 ' Wordproc editor Sub TEST_TextEditorGet() Dim sEditorPref As String Select Case TextEditorGet() Case TEXTEDIT_DEFAULT sEditorPref = "Default Dialog Editor" Case TEXTEDIT_COMMANDWINDOW sEditorPref = "Command Window Editor" Case TEXTEDIT_WORDPROCESSOR sEditorPref = "Word Processor Editor" Case Else sEditorPref = "Unknown" End Select Debug.Print "Current text editor is: " + sEditorPref End Sub Public Function TextEditorGet() As Long TextEditorGet = GetCExpressionValue("userPrefsP->textEditorStyle", "USERPREF") ' A.K.A. "savePrefs.textEditorStyle" End FunctionSub TEST_TextEditorSet() 'TextEditorSet (TEXTEDIT_DEFAULT) TextEditorSet (TEXTEDIT_WORDPROCESSOR) End Sub Public Function TextEditorSet(lEditorPref As Long) SetCExpressionValue "userPrefsP->textEditorStyle", lEditorPref, "USERPREF" ' A.K.A. "savePrefs.textEditorStyle" End Function
Thank you for your comments... I have one more question... I know my code may be bulky. Is there another way to produce the same outcome as what I wrote? (See code below).... This code will take any single line text & turn it into EDF text without modifying the justification...I figured out how to get this to let me keep selecting text after the first selection is converted but I think it is more of a cheat. I would like to have a better understanding of how it should be done but all I have is a book on basics & how much time I can spend researching on the internet. Thanks again for your input. All is appreciated.
Module1:
Sub tstLCE_Text() CommandState.StartLocate New LCE_Text ShowCommand "Convert to DataField" ShowPrompt "Select Text to be Converted" End Sub
____________________________________________________
Sub Macro3() Dim startPoint As Point3d Dim point As Point3d, point2 As Point3d Dim lngTemp As Long
' Start a command CadInputQueue.SendCommand "WORDPROCESSOR EDIT TEXT" CadInputQueue.SendDataPoint point, 1 CadInputQueue.SendKeyin "vba run tstLCE_Text" End Sub
_______________________________________________________
Class Module: (LCE_Text):
__________________________________
Private Sub ILocateCommandEvents_Accept(ByVal Element As Element, point As Point3d, ByVal View As View) Dim elemText As TextElement Set elemText = Element elemText.Redraw msdDrawingModeErase elemText.Text = "<<" & (elemText.Text) & ">>" elemText.Redraw msdDrawingModeNormal elemText.Rewrite 'activates the text edit command CadInputQueue.SendKeyin "vba run macro3" ActiveModelReference.UnselectAllElements
____________________________________
_____________________________________
Private Sub IlocateCommandEvents_LocateFailed() If SelElement Is Nothing = False Then ActiveModelReference.UnselectAllElements Set SelElement = Nothing End If ShowCommand "Convert to DataField" ShowPrompt "Select Text to be Converted" End Sub
_______________________________________
Private Sub IlocateCommandEvents_LocateFilter(ByVal Element As Element, point As Point3d, Accepted As Boolean) Accepted = False If Element.IsTextElement = True Then Set SelElement = Element Accepted = True ActiveModelReference.SelectElement Element, True ShowCommand "Convert" ShowPrompt "Click to Confirm" End If End Sub
__________________________________________
Private Sub ILocateCommandEvents_LocateReset() CommandState.StartDefaultCommand End Sub
I need to do this as well. did you fin a way to do it ?
Hi Arian,
please, do not continue in 7 years old discussion!
When you have similar question (but probably for another product version), create a new question. And of course, read and follow the forum best practices.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Arian Morell said:I need to do this as well
In which version (e.g. v10.x.y.z) of MicroStation or other product?