+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Jun 2005
    Location
    Newcastle Upon Tyne
    Posts
    312

    Default match proporties of dim text overide value

    Registered forum members do not see this ad.

    Hi,

    I hope someone can help me.

    I have the code below that works

    basicaly it stores the dim text overide value and the fills the value of the next dim selected.

    However i was hoping to condense it a bit. Instead of select dim, enter, select next dim, enter i was hoping for select dim, selct next dim and then enter?

    so i would have to change the selection set to allow only one selection and then onto the next bit of code, is this possible??


    Code:
    Public MyDmTxtOvrdeStr As String
    
    Sub MatchDimTextOverideValueP1()
    
    'allows selecting dim on screen
    'stores the dim text overide value
    
    'Dim MyDmTxtOvrdeStr As String
    Dim MyDim As AcadDimension
    Dim MyoEnt As AcadEntity
    Dim MyObjSS As AcadSelectionSet
    
        On Error Resume Next
        ThisDrawing.SelectionSets("SelectDim").Delete
        If Err Then Err.Clear
        With ThisDrawing.Utility
        
            '' create a new selectionset
            Set MyObjSS = ThisDrawing.SelectionSets.Add("SelectDim")
    
            '' let user select entities interactively
            MyObjSS.SelectOnScreen
            
            MyObjSS.Highlight True
            
            '' pause for the user
            .prompt vbCr & MyObjSS.Count & " entities selected"
            '.GetString False, vbLf & "Enter to continue "
    
            'For Each MyoEnt In MyObjSS
            For Each MyoEnt In MyObjSS
            
               ' If TypeOf MyoEnt Is AcadDimension Then
               If TypeOf MyoEnt Is AcadDimension Then
        
                    Set MyDim = MyoEnt
                          MyDmTxtOvrdeStr = MyDim.TextOverride
                            MsgBox MyDmTxtOvrdeStr
                            'MyAttTextStr = myvaratt(i).TextString
                            
                            MyObjSS.Highlight False
    
                        End If
                    Next
               ' End If
           ' Next
    End With
    
    
    
    MatchDimTextOverideValueP2
       End Sub
    
    
    Private Sub MatchDimTextOverideValueP2()
    'allows selecting dim on screen
    'pastes the dim text overide value into the newly selected dim
    
    'Dim MyDmTxtOvrdeStr As String
    Dim MyDim As AcadDimension
    Dim MyoEnt As AcadEntity
    Dim MyObjSS As AcadSelectionSet
    
        On Error Resume Next
        ThisDrawing.SelectionSets("SelectDim").Delete
        If Err Then Err.Clear
        With ThisDrawing.Utility
        
            '' create a new selectionset
            Set MyObjSS = ThisDrawing.SelectionSets.Add("SelectDim")
    
            '' let user select entities interactively
            MyObjSS.SelectOnScreen
            
            MyObjSS.Highlight True
            
            '' pause for the user
            .prompt vbCr & MyObjSS.Count & " entities selected"
            '.GetString False, vbLf & "Enter to continue "
    
            'For Each MyoEnt In MyObjSS
            For Each MyoEnt In MyObjSS
            
               ' If TypeOf MyoEnt Is AcadDimension Then
               If TypeOf MyoEnt Is AcadDimension Then
        
                    Set MyDim = MyoEnt
                    
                          'MyDmTxtOvrdeStr = MyDim.TextOverride
                          
                        MyDim.TextOverride = MyDmTxtOvrdeStr
                            
                            'MsgBox MyDmTxtOvrdeStr
    
    
                        End If
                    Next
               ' End If
           ' Next
    End With
    
    End Sub
    thank you for any help.

    PS the msgbox was just me testing,

  2. #2
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Philadelphia, Pa.
    Posts
    407

    Default

    Comcu

    It sounds like you may need a do while loop

    Do while condition is True

    With that you will be able to keep picking until the user hits escape or enter

    ML

  3. #3
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Jun 2005
    Location
    Newcastle Upon Tyne
    Posts
    312

    Default

    ML,

    thank you for your help.

    the code allows me to keep picking until i hit enter. its more that i want the user to be able to select only 1 dimension and then the code simulates the user hitting enter?

    Cheers,

    Col

  4. #4
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Philadelphia, Pa.
    Posts
    407

    Default

    Hi Col

    Without trying your code, I can see that you are using a selectonscreen, that is good.

    I'm still leaning to wards a do while loop

    We would need to do a picked = True

    I am not the greatest with Do While Loops, it seems like every time I attempt one, I need to reach out for help.

    We could take a closer look, if you'd like?

    Do you have a dwg file you could send?

    ML

  5. #5
    Super Member SEANT's Avatar
    Using
    AutoCAD 2012
    Join Date
    Aug 2005
    Location
    Rhode Island
    Posts
    1,971

    Default

    Registered forum members do not see this ad.

    An alternative to Selection Sets – specifically when single picks are preferred – is the ThisDrawing.Utility.GetEntity method. As an example, the code in the threads initial post was modified below. As usual with examples, there is limited error checking.

    Note: The looping action in Sub “MatchDimTextOverideValueP2” can be removed to only allow single picks at that point as well.

    Code:
    Public MyDmTxtOvrdeStr As String
    
    Sub MatchDimTextOverideValueP1()
    
    Dim MyDim As AcadDimension
    Dim MyoEnt As AcadEntity
    
    Dim varPkPt As Variant
    
        With ThisDrawing.Utility
          On Error GoTo Escapement
          .GetEntity MyoEnt, varPkPt, "Select Overridden Dimension: "
          
          If TypeOf MyoEnt Is AcadDimension Then
             Set MyDim = MyoEnt
             MyDmTxtOvrdeStr = MyDim.TextOverride
             MyoEnt.Highlight True
             MsgBox MyDmTxtOvrdeStr
             MyoEnt.Highlight True
          End If
       End With
       
       MatchDimTextOverideValueP2
       
       MyoEnt.Highlight False
    Escapement:
    End Sub
    
    
    Private Sub MatchDimTextOverideValueP2()
    Dim MyDim As AcadDimension
    Dim MyoEnt As AcadEntity
    
    Dim varPkPt As Variant
    
        With ThisDrawing.Utility
        On Error GoTo Escapement
        Do
          .GetEntity MyoEnt, varPkPt, "Select Dimension(s) to override: "
          If TypeOf MyoEnt Is AcadDimension Then
             Set MyDim = MyoEnt
             MyDim.TextOverride = MyDmTxtOvrdeStr
             MyoEnt.Highlight False
          End If
       Loop
       End With
    Escapement:
    End Sub

Similar Threads

  1. Match Prop's - Text Overide Value
    By comcu in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 28th Jul 2008, 12:55 pm
  2. match properties w/text? is there a lisp
    By Chris H. in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 29th May 2008, 02:10 pm
  3. Lisp for Coping a text to another like match properties
    By vins287 in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 19th Nov 2007, 05:24 pm
  4. overide text
    By david in forum AutoCAD Beginners' Area
    Replies: 6
    Last Post: 18th Sep 2007, 09:44 am
  5. Match text
    By FatRobo in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 8th Jul 2006, 08:28 am

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