+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Forum Newbie
    Using
    AutoCAD LT 2002
    Join Date
    Oct 2008
    Posts
    5

    Default Change %% in autocad

    Registered forum members do not see this ad.

    Hey guys, i have searched this forum in hope for something to help me.
    What's my problem :
    I have many drawings each day (100-500) and i have to load them into a database. But the database gives errors if it finds %% in the drawing.
    How can i make a simple script to auto search and replace %%C into Ø , %%D into º and %%p into ±

    I'm searching for 3 days now and no result.
    And something else, how can i add to the batch to auto delete any layout he finds in the drawing and to center the layout?
    this would help me VERY VERY much with my tasks every day becouse it tend to repeat...and it's a time killer thing.

    I know that I should use Lisp, i fould that Lisp is installed on my machine but i dont know the syntax of doing such things...

    Thanks in advance !!!

  2. #2
    Forum Deity
    Using
    Civil 3D 2008
    Join Date
    Sep 2006
    Location
    Pittsburgh, PA, USA
    Posts
    3,581

    Default

    I don't know if this will work for but try Find/Replace...

    From Help

    Special Unicode Characters
    (Quick Reference)
    When entering text, you can create special characters, including the degree symbol, plus/minus tolerance symbol, and the diameter symbol, by entering the following Unicode character strings:

    \U+00B0 Degrees symbol (°)

    \U+00B1 Tolerance symbol (±)

    \U+2205 Diameter symbol ()

    See Unicode Font Descriptions in the Customization Guide.
    Last edited by lpseifert; 8th Oct 2008 at 11:17 pm.

  3. #3
    Forum Newbie
    Using
    AutoCAD LT 2002
    Join Date
    Oct 2008
    Posts
    5

    Default

    Yes i know, but how do I make this into a command so I can include into an existing batch script?
    I dont need a new script to do that, i can add this to a Save-as acad 2000 script and while the script will save as acad , it will change the %% also.
    Many thanks for the quick response!

  4. #4
    Forum Newbie
    Using
    AutoCAD LT 2002
    Join Date
    Oct 2008
    Posts
    5

    Default

    So , in autocad exists a find/replace command?
    just a line of command to find a certain thing and a second command to replace the thing?

  5. #5
    Senior Member borgunit's Avatar
    Using
    Mechanical 2006
    Join Date
    May 2007
    Location
    Ohio USA
    Posts
    287

    Default

    Here is a VB version

    Code:
    Public Function MText_Unformat(ByVal sTxt As String) As String
    '------------------------------------------------------------------------------
    'Remove formatting strings
    '
    'Value Examples:
    ' \A Sets the alignment value; valid values: 0, 1, 2 (bottom, center, top)
    ' \Cvalue; Changes to the specified color
    ' \Hvalue; Changes to the specified text height
    ' \Hvaluex; Changes to multiple of mtext object's property
    ' \L...\l Turns underline on and off
    ' \O...\o Turns overline on and off
    ' \P Ends paragraph/Carriage return
    ' \Qangle; Changes obliquing angle
    ' \S...^...; Stacks the subsequent text at the \ or ^ symbol
    ' \Tvalue; Adjusts the space between characters
    ' \Wvalue; Changes width factor to produce wide text
    ' \~ Inserts a nonbreaking space
    ' \\ Inserts a backslash
    ' \{...\} Inserts an opening and closing brace
    ' \File name; Changes to the specified font file
    '
    '------------------------------------------------------------------------------
    Dim P1 As Integer
    Dim P2 As Integer
    Dim P3 As Integer
    Dim iStart As Integer
    Dim sComp As String
    Dim sReplace As String
    Dim sLittle As String
    '''''''''''''''''''''''''''''''''''''''
    Debug.Print sTxt
    '------------------------------------------------------------------------------
    'Remove alignment codes
    '------------------------------------------------------------------------------
    Select Case Left(sTxt, 4)
    Case "\A0;", "\A1;", "\A2;"
        sTxt = Mid(sTxt, P1 + 5)
    End Select
    iStart = 1
    '------------------------------------------------------------------------------
    'Replace octal code values with strings
    '------------------------------------------------------------------------------
    Do
        P1 = InStr(sTxt, "%%")
        If P1 = 0 Then
            Exit Do
        Else
            Select Case Mid(sTxt, P1 + 2, 1)
            Case "P"
                sTxt = Replace(sTxt, "%%P", "+or-")
            Case "D"
                sTxt = Replace(sTxt, "%%D", " deg")
            End Select
        End If
    Loop
    
    Do
        P1 = InStr(iStart, sTxt, "\", vbTextCompare)
        If P1 = 0 Then Exit Do
        sComp = Mid(sTxt, P1, 2)
        Select Case sComp
        Case "\p"
            P2 = InStr(1, sTxt, ";")
            sTxt = Mid(sTxt, P2 + 1)
        Case "\A", "\C", "\f", "\F", "\H", "\Q", "\T", "\W"
            P2 = InStr(P1 + 2, sTxt, ";", vbTextCompare)
            P3 = InStr(P1 + 2, sTxt, sComp, vbTextCompare)
            If P3 = 0 Then
                sTxt = Left(sTxt, P1 - 1) & Mid(sTxt, P2 + 1)
            End If
            Do While P3 > 0
                P2 = InStr(P3, sTxt, ";", vbTextCompare)
                sTxt = Left(sTxt, P3 - 1) & Mid(sTxt, P2 + 1)
                'Debug.Print sTxt, sComp
                P3 = InStr(1, sTxt, sComp, vbTextCompare)
            Loop
                'sTxt = Left(sTxt, P3 - 1) & mid(sTxt, P3 + 1)
        Case "\L", "\O"
            sLittle = LCase(sComp)
            P2 = InStr(P1 + 2, sTxt, sLittle, vbTextCompare)
            If P2 = 0 Then
                sTxt = Left(sTxt, P1 - 1) & Mid(sTxt, P1 + 2)
            Else
                sTxt = Left(sTxt, P1 - 1) & Mid(sTxt, P1 + 2, P2 - (P1 + 2)) & Mid(sTxt, P2 + 2)
            End If
        Case "\S"
            P2 = InStr(P1 + 2, sTxt, ";", vbTextCompare)
            P3 = InStr(P1 + 2, sTxt, "/", vbTextCompare)
            If P3 = 0 Or P3 > P2 Then
                P3 = InStr(P1 + 2, sTxt, "#", vbTextCompare)
            End If
            If P3 = 0 Or P3 > P2 Then
                P3 = InStr(P1 + 2, sTxt, "^", vbTextCompare)
            End If
            sTxt = Left(sTxt, P1 - 1) & Mid(sTxt, P1 + 2, P3 - (P1 + 2)) _
                    & "/" & Mid(sTxt, P3 + 1, (P2) - (P3 + 1)) & Mid(sTxt, P2 + 1)
                    
        Case "\U" 'Replace symbols with text
            sLittle = Mid(sTxt, P1 + 3, 4)
            Debug.Print sLittle
            Select Case sLittle
            Case "2248"
                sReplace = "ALMOST EQUAL"
            Case "2220"
                sReplace = "ANGLE"
            Case "2104"
                sReplace = "CENTER LINE"
            Case "0394"
                sReplace = "DELTA"
            Case "0278"
                sReplace = "ELECTRIC PHASE"
            Case "E101"
                sReplace = "FLOW LINE"
            Case "2261"
                sReplace = "IDENTITY"
            Case "E200"
                sReplace = "INITIAL LENGTH"
            Case "E102"
                sReplace = "MONUMENT LINE"
            Case "2260"
                sReplace = "NOT EQUAL"
            Case "2126"
                sReplace = "OHM"
            Case "03A9"
                sReplace = "OMEGA"
            Case "214A"
                sReplace = "PROPERTY LINE"
            Case "2082"
                sReplace = "SUBSCRIPT2"
            Case "00B2"
                sReplace = "SQUARED"
            Case "00B3"
                sReplace = "CUBED"
            End Select
            sTxt = Replace(sTxt, "\U+" & sLittle, sReplace)
        Case "\~"
            sTxt = Replace(sTxt, "\~", " ")
        Case "\\"
            iStart = P1 + 2
            sTxt = Replace(sTxt, "\\", "\")
            GoTo Selectagain
        Case "\P"
            iStart = P1 + 1
            GoTo Selectagain
        Case Else
            Exit Do
        End Select
    Selectagain:
    Loop
    '------------------------------------------------------------------------------
    'Replace \P with vbCrLf
    '------------------------------------------------------------------------------
    Do
        P1 = InStr(1, sTxt, "\P", vbTextCompare)
        If P1 = 0 Then
            Exit Do
        Else
            sTxt = Left(sTxt, P1 - 1) & vbCrLf & Mid(sTxt, P1 + 2)
        End If
    Loop
    For iStart = 0 To 1
        If iStart = 0 Then
            sComp = "}"
        Else
            sComp = "{"
        End If
        P2 = InStr(1, sTxt, sComp)
        
        Do While P2 > 0
            sTxt = Left(sTxt, P2 - 1) & Mid(sTxt, P2 + 1)
            P2 = InStr(1, sTxt, sComp)
        Loop
    Next iStart
    
    MText_Unformat = sTxt
     
    End Function
    AutoCAD Mechanical 2006
    XP PRO SP3
    http://mechcad-insider.blogspot.com/

  6. #6
    Senior Member cpriedel's Avatar
    Using
    AutoCAD 2010
    Join Date
    Sep 2007
    Location
    From Germany to Seattle
    Posts
    155

    Default

    Just type FIND in the command line.

  7. #7
    Senior Member borgunit's Avatar
    Using
    Mechanical 2006
    Join Date
    May 2007
    Location
    Ohio USA
    Posts
    287

    Default

    Look for reptext.lsp

    http://www.74mph.com/lisp.asp
    AutoCAD Mechanical 2006
    XP PRO SP3
    http://mechcad-insider.blogspot.com/

  8. #8
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,786

    Default

    Registered forum members do not see this ad.

    I like zypa would be interested if anyone knows how to pass the "Find" Command the two lines it needs to work, I have asked this before I want to use it in a script.

Similar Threads

  1. When I change the color the dimensions change!
    By Mark Costantino in forum AutoCAD Drawing Management & Output
    Replies: 7
    Last Post: 12th Oct 2009, 05:55 pm
  2. How to change AutoCAD Language
    By Safwah in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 30th Jul 2007, 12:26 am
  3. change units in autocad 2005
    By winglj in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 17th Jan 2006, 07:15 pm
  4. Change background display colour in AutoCAD
    By millsy1990 in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 30th Oct 2005, 03:35 pm
  5. How do I change from imperial to metric on Autocad 2006?
    By zack in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 21st Oct 2005, 01:40 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts