Jump to content

Copy Number + .01


Absntmind

Recommended Posts

I am coming across a situation at work (which will last for a period of time) where we are creating a numerical grid. I created the proto with a default grid, and the same number copied throughout (#1.11-0.00). The thing killing me is having to edit each one, one at a time. Can be time consuming when there are a few hundred. A while back, someone helped out with a match text lisp for a different situation, which is somewhat helpfull in this situation. Also one which will copy a number, then place the second below it adding .01 . I can match one row, then only edit one digit at a time for each sequence. Still takes a long time.

 

I was wondering if between the two, a lisp could be created to match the text then instead of replacing the text exactly, add .01 to the number. Such as if I have a row, I edit the first number, use a command, then select the first, and after, every number I select will go up .01 ( #123.11-0.00 , #123.12-0.00, #123.13-0.00, ect..). Or if it would just be easier to create a new one from scratch.

 

If anyone could point me in the right direction, or at least help me get started, it would be very much appretiated :)

Link to comment
Share on other sites

I have this as VBA if you want it

Public Sub TextNumber()
     Dim objSelected As Object
     Dim blnFlag As Boolean
     Dim intCnt As Integer
     Dim strValue As String
     Dim objTxt As AcadText
     Dim objSelSet As AcadSelectionSet
     On Error GoTo ErrControl
     Set objSelSet = ThisDrawing.SelectionSets.Add("Text")
     objSelSet.SelectOnScreen
     intCnt = 1
     For Each objSelected In objSelSet
           If TypeOf objSelected Is AcadText Then
                 Set objTxt = objSelected
                 If blnFlag = False Then      'This is the first entity selected
                       objTxt.TextString = intCnt
                       blnFlag = True
                 Else
                       objTxt.TextString = intCnt
                 End If
                 intCnt = intCnt + 1
           Else
                 MsgBox "Object number " & intCnt & " is not DText, you need to reselect", vbInformation, "Gap Set"
                 ThisDrawing.SelectionSets.Item("Text").Delete
           End If
     Next
     ThisDrawing.SelectionSets.Item("Text").Delete
     ThisDrawing.Application.Update
Exit_Here:
     Exit Sub
ErrControl:
     MsgBox Err.Description
End Sub

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...