Results 1 to 5 of 5

Thread: MText entity causes loop

  1. #1
    mblewis Guest

    MText entity causes loop

    the following code is based on suggestion by R. Robert Bell
    to get attribute tagstrings from BlockDef:

    Public Sub Stdz_Malform_Tagnames2()
    ' BlockDefinition objects
    ' this Sub selects & modifies BlockDefinition objects, _
    not BlockReference objects

    On Error GoTo ERR_HAND
    Dim oMyBlock As AcadBlock

    Set oMyBlock = ThisDrawing.Blocks.Item(myTBlock)
    Dim oEnt As AcadEntity

    For Each oEnt In oMyBlock
    If TypeOf oEnt Is AcadAttribute Then
    oEnt.TagString = "MyNewTag"
    End If ' AcadAttribute
    Next oEnt
    Exit Sub
    ERR_HAND:
    Resume
    End Sub

    PROBLEM: when oEnt is MText entity, endless loop results when "Next oEnt" is processed; execution causes error which triggers On Error which executes Resume which returns to "Next oEnt" which......
    have set Watch on oEnt and when this trap occurs, oEnt Type=AcadEntity/lAcadMText in Watches box.

    any suggestions for avoiding this debilitating loop?

    marklewis

  2. #2
    fantum Guest
    Click on the word "Resume" in the code window and press the F1 key on your keyboard.

  3. #3
    mblewis Guest
    nice touch, fantum.

    will add "Next" after Resume to break outta loop.

    duh, why didn't i think of that? sometimes it takes others to correctly align the mirror for us to see the obvious.

    marklewis

  4. #4
    R. Robert Bell Guest
    What purpose do you have the error handler in there for anyway?

    <hint> Look at your function description. Ask yourself "Is it doing too
    much?" </hint>

    --
    R. Robert Bell


    "mblewis" <nospam@address.withheld> wrote in message
    news:5388368.1103220524687.JavaMail.jive@jiveforum 2.autodesk.com...
    the following code is based on suggestion by R. Robert Bell
    to get attribute tagstrings from BlockDef:

    Public Sub Stdz_Malform_Tagnames2()
    ' BlockDefinition objects
    ' this Sub selects & modifies BlockDefinition objects, _
    not BlockReference objects

    On Error GoTo ERR_HAND
    Dim oMyBlock As AcadBlock

    Set oMyBlock = ThisDrawing.Blocks.Item(myTBlock)
    Dim oEnt As AcadEntity

    For Each oEnt In oMyBlock
    If TypeOf oEnt Is AcadAttribute Then
    oEnt.TagString = "MyNewTag"
    End If ' AcadAttribute
    Next oEnt
    Exit Sub
    ERR_HAND:
    Resume
    End Sub

    PROBLEM: when oEnt is MText entity, endless loop results when "Next oEnt" is
    processed; execution causes error which triggers On Error which executes
    Resume which returns to "Next oEnt" which......
    have set Watch on oEnt and when this trap occurs, oEnt
    Type=AcadEntity/lAcadMText in Watches box.

    any suggestions for avoiding this debilitating loop?

    marklewis

  5. #5
    mblewis Guest
    back from vacating....
    purpose for ErrorHandler?
    during code trials, to catch any anomalies i didn't thinkof. usually eliminate after code proven.
    in this specific case, it helped me to see endless loop caused by this Sub.

Similar Threads

  1. Combine mtext to mtext
    By wdglenn in forum Customization
    Replies: 1
    Last Post: 03-04-2005, 01:09 PM
  2. loop
    By jlspartz in forum Customization
    Replies: 6
    Last Post: 03-01-2005, 01:57 PM
  3. Re-occuring loop...?
    By REscamilla in forum Customization
    Replies: 13
    Last Post: 02-10-2005, 03:32 PM
  4. Loop with variable
    By in forum VBA
    Replies: 0
    Last Post: 02-09-2005, 04:45 PM
  5. conditional loop
    By jlspartz in forum Customization
    Replies: 5
    Last Post: 01-14-2005, 03:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum