Highligh method broken ?

Discussion in 'AutoCAD' started by Gilles Plante, Apr 21, 2004.

  1. Hi all,

    I have created a VBA application on AutoCAD 2000i, using the Highlight
    method on lw polylines. The users for this application run AutoCAD 2002. To
    my great surprise, highlighting an object on AutoCAD 2002 does not work (it
    does not work either on 2004). Has someone found a way to 'fix' it ?

    Please don't tell me the example included in the help file works... I know !
    Remove the call to MsgBox, and then it does not work.

    Thanks

    Gilles Plante
     
    Gilles Plante, Apr 21, 2004
    #1
  2. Remove the call to MsgBox, and then it does not work.

    The Highlight method is kind of unpredictable, I think, but the example
    works even if you get rid of the MsgBox.... but the highlight gets turned
    back off immediately. Delete the "Highlight(False)" line and the objects
    will all stay highlighted.

    On my machine, with the MsgBox turned on, the screen doesn't redraw (and
    thus I don't see the highlight) until I move the MsgBox. So I added a
    "Regen" or "entry.Update" between the "Highlight" and the "MsgBox", thinking
    that this would make the Highlight visible. Unexpectedly, either of these
    commands turned the highlight off. I consider this to be a bug --
    refreshing the screen should not turn off highlighting, IMO.

    Unfortunately I can't think of a way other than Regen or Update to make the
    screen redraw and thus make the highlight visible consistently.


    James
     
    James Belshan, Apr 21, 2004
    #2
  3. Have you tried calling .Update after highlight?

    Also, try using AcadApplication.Update as well
     
    Tony Tanzillo, Apr 22, 2004
    #3
  4. Tony,

    I have tried .Update at the object and application level. It does not work.

    From the example, I removed the call to MsgBox and added a call to insert a
    delay of say 3 seconds. Objects never get highlighted.

    Everything is fine on 2000i, but on 2002 and 2004, it just does not work.
    And I can't find any trick to force it to show the highlight. I had to
    change the object color to highlight it.

    Gilles
     
    Gilles Plante, Apr 22, 2004
    #4
  5. Gilles Plante

    Jeff Mishler Guest

    FWIW, I just opened a blank drawing in 2k2, created a new vba project, cut &
    paste the Highlight example from the help, commented out the msgbox &
    entry.Highlight (False) lines and the items are correctly highlighted.

    I'm guessing there's something else going on.

    Jeff
     
    Jeff Mishler, Apr 22, 2004
    #5
  6. Here's something you might try.

    Instead of starting your VBA code using VBARUN or vl-vbarun,
    try starting it using the following:

    (defun C:VBARUNX ()
    (vl-load-com)
    (vla-runmacro
    (vlax-get-acad-object)
    (getstring "\nMacro name: ")
    )
    (princ)
    )

    See if when run using this, the highlighting works (without
    having to modify the object).
     
    Tony Tanzillo, Apr 22, 2004
    #6
  7. Gilles,
    Tony's suggestion to use the AcadApplication.update fixed it on my machine.
    The objects highlight like they are supposed to if I make the following
    change to the Highlight Example.

    For Each entry In ThisDrawing.ModelSpace
    entName = entry.ObjectName
    entry.Highlight (True)
    ThisDrawing.Application.Update 'added this line
    MsgBox "The name of this object is " & entName, vbInformation,
    "Highlight Example"
    entry.Highlight (False)
    Next


    James
     
    James Belshan, Apr 22, 2004
    #7
  8. You need to be careful here, because it the display of the
    message box may be what's causing AutoCAD to refresh the
    view, and if you remove the call to MsgBox, it may not do
    that.

    The people that wrote the sample either didn't realize that
    the message box display comes into play here, or they couldn't
    figure out how to get it to work without the message box.
     
    Tony Tanzillo, Apr 22, 2004
    #8
  9. Tony, Gilles,
    This code works for me, with no message box, but with Tony's Update line,
    cycling the highlight through the model. Run it on a small model, though,
    and not at 11:59pm. I use MDT6.0, based on ACAD 2002.

    Sub Cycle_Highlight()
    Dim entName As String
    Dim entry As AcadEntity
    For Each entry In ThisDrawing.ModelSpace
    entName = entry.ObjectName
    entry.Highlight (True)
    ThisDrawing.Application.Update
    Dim wait As Double, start As Double
    wait = 3: start = Timer
    Do: DoEvents: Loop Until Timer >= start + wait
    entry.Highlight (False)
    Next
    End Sub

    James
     
    James Belshan, Apr 22, 2004
    #9
  10. Gilles Plante

    Joldy Guest

    hi Gilles

    I had the same problem few days ago.
    I've tried the .update method and it failed

    the solution I found is to put a sendcommand just after the highlight.

    ex:

    obj.highlight true
    thisdrawing.sendcommand " "

    it's not beautifull but it works for me
     
    Joldy, Apr 26, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.