MText entity causes loop
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
MText entity causes loop

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
mblewis
Guest





Posted: Thu Dec 16, 2004 11:08 pm    Post subject: MText entity causes loop Reply with quote

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

Back to top
fantum
Guest





Posted: Thu Dec 16, 2004 11:52 pm    Post subject: Re: MText entity causes loop Reply with quote

Click on the word "Resume" in the code window and press the F1 key on your keyboard.
Back to top
mblewis
Guest





Posted: Fri Dec 17, 2004 12:03 am    Post subject: Re: MText entity causes loop Reply with quote

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

Back to top
R. Robert Bell
Guest





Posted: Fri Dec 17, 2004 9:01 pm    Post subject: Re: MText entity causes loop Reply with quote

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@jiveforum2.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
Back to top
mblewis
Guest





Posted: Mon Jan 03, 2005 6:14 pm    Post subject: Re: MText entity causes loop Reply with quote

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.
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB