Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Autocad internal spell check - VB.net

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
MikeEvansUK
529 Views, 3 Replies

Autocad internal spell check - VB.net

I have created an application to spell check labels (as there is currently no avaliable spell check solution) but I currently use the Word spell checker instead of internal.

 

I have an issue with this current method. It starts word and runs the check fine however it opens a new document every time and I have to close it manually as well as a few other issues described below.

 

See code below. My question is simple really. Can I use the internal spell check instead or do I really need to use word?

 

If I have to use word.

 

When the spell check window it oonly appears in the background and I have to switch to it, can I force the visibility to front?

 

When I have finished the document closes but the word application stays open and when closed states that the .dot file has been changed etc, and I have to then answer y/n to save changes in dialogues etc. How can I omit / prevent this?

 

Code:

 

    Public Sub spellme(ByRef testext As String)

        Dim wordApp As New Word.Application

        wordApp.Visible = False

        Dim doc As Word.Document = wordApp.Documents.Add()

        Dim range As Word.Range

        range = doc.Range()

        range.Text = testext

        doc.Activate()

        doc.CheckSpelling()

        Dim chars() As Char = {CType(vbCr, Char), CType(vbLf, Char)}

        testext = doc.Range().Text.Trim(chars)

        doc.Close(SaveChanges:=False)

        wordApp.Quit()
    End Sub

 

Any help or pointers would be greatly appriciated.

 

Mike

Mike Evans

Civil3D 2022 English
Windows 7 Professional 64-bit
Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz (8 CPUs), ~4.0GHz With 32768MB RAM, AMD FirePro V4900, Dedicated Memory: 984 MB, Shared Memory: 814 MB

3 REPLIES 3
Message 2 of 4
MikeEvansUK
in reply to: MikeEvansUK

I have worked out the problem with closing etc.

 

This now works well using word apart from the text containing /p etc in the text strings obtained.

 

Still my question regarding the use of internal checker stands.

 

Mike Evans

Civil3D 2022 English
Windows 7 Professional 64-bit
Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz (8 CPUs), ~4.0GHz With 32768MB RAM, AMD FirePro V4900, Dedicated Memory: 984 MB, Shared Memory: 814 MB

Message 3 of 4
MikeEvansUK
in reply to: MikeEvansUK

Oh Dear.

 

Well it works well however it breaks all the labels it modifies..

 

Where there is a dynamic link to the civil object eg. <Name> when it replaces the whole text string with what has been changed during the spell check it breaks the dynamic link for the <Name>.

 

Back to the drawing board with this bit unless somehow there is a way to search the "Olabel.GetTextComponentOverride(Olabelid)" string and not pass the <name> etc over for spelling and then only update the data changed ignoring the <> entries. I think this may not be achievable / easy which is probably why we don't have spell check functionality in labels in the first place.

 

Ho Hum.

 

M.

 

Mike Evans

Civil3D 2022 English
Windows 7 Professional 64-bit
Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz (8 CPUs), ~4.0GHz With 32768MB RAM, AMD FirePro V4900, Dedicated Memory: 984 MB, Shared Memory: 814 MB

Message 4 of 4
MikeEvansUK
in reply to: MikeEvansUK

The answer to this was simpler than I thought.

 

The note label needs a separate sub component added for the notes to be held in. This enable you to search within the text string to find text not containing the <[ characters which will be a dynamic component and check this instead thus leaving the dynamic components alone and not breaking them.

 

                                    Dim stext As String = Olabel.GetTextComponentOverride(Olabelid)
                                    Dim Slong1 As Char = "<["
                                    '    Dim Slong2 As Char = ">"
                                    If Not stext.Contains(Slong1) Then
                                        spellme(Olabel.GetTextComponentOverride(Olabelid))
                                        Olabel.SetTextComponentOverride(Olabelid, TextRes)
                                    Else
                                    End If

 

Im sure there would be a method to edit text ignoring the <[ ]> strings alone is there but I cant find it (with my simple knowledge).

 

However the Word spell check is still painful to use in this way. An internal one would be of benefit.

 

Mike Evans

Civil3D 2022 English
Windows 7 Professional 64-bit
Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz (8 CPUs), ~4.0GHz With 32768MB RAM, AMD FirePro V4900, Dedicated Memory: 984 MB, Shared Memory: 814 MB

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report