Problem highlighting entity

Discussion in 'AutoCAD' started by ajtruckle, Dec 16, 2004.

  1. ajtruckle

    ajtruckle Guest

    I have this basic macro:

    [pre]
    Option Explicit
    Public Sub SplitPoly()
    Dim ent As AcadObject
    Dim basePnt As Variant

    On Error Resume Next

    Call ThisDrawing.Utility.GetEntity(ent, basePnt, "Please choose an entity to split:")
    If Err <> 0 Then
    Err.Clear
    Else
    ent.Highlight
    End If

    End Sub
    [/pre]

    But once the macro has executed, the entity (polyline) I selected is not highlighted. I was expecting it to show dashed, as I get when I do this in lisp:

    [pre]
    (redraw ename 3)
    [/pre]

    What am I doing wrong?
     
    ajtruckle, Dec 16, 2004
    #1
  2. ajtruckle

    Michel Guest

    You must set the Highlight-property to 'True' :
    ent.Highlight True

    Michel
     
    Michel, Dec 16, 2004
    #2
  3. hi

    you have to give the parameter 'true' or 'false' with ent.Highlight to
    give the input for turning highlight on or off.

    ==> ent.Highlight True

    - alfred -
     
    Alfred NESWADBA, Dec 16, 2004
    #3
  4. ajtruckle

    ajtruckle Guest

    Thank you. I have this working. Can I ask you another question? As it is, it will pick any entity whether the entity is visible or not.

    Is there a way to:

    a) ensure the entity picked is a visible entity and not on a locked layer

    b) ensure the entity is a polyline (ie: something that will be acceptable as a parameter to the "break" command).

    ??

    Andrew
     
    ajtruckle, Dec 16, 2004
    #4
  5. ajtruckle

    Michel Guest

    After an entity is picked, you might want to check if the layer is locked and whether the selected entity is a polyline. The sample should get you started. Be careful, there are two types of polylines (AcDbPolyline and AcDb2dPolyline), so might want to check both types.
    Checking visibility works the same way: If ent.Visible=True then...


    Public Sub SplitPoly()
    Dim ent As AcadEntity
    Dim basePnt As Variant

    On Error Resume Next
    ThisDrawing.Utility.GetEntity ent, basePnt, "Please choose an entity to split:"
    If Err <> 0 Then
    Err.Clear
    Else
    If ThisDrawing.Layers(ent.Layer).Lock = False And ent.ObjectName = "AcDbPolyline" Then
    ent.Highlight True
    End If
    End If

    End Sub
     
    Michel, Dec 16, 2004
    #5
  6. ajtruckle

    ajtruckle Guest

    I did it like this:

    [pre]
    Option Explicit
    Public Sub SplitPoly()
    On Error Resume Next

    Dim Layer As AcadLayer
    Dim ent As AcadObject
    Dim basePnt As Variant

    InitUserPrompt

    SelectEntity:
    Call ThisDrawing.Utility.GetEntity(ent, basePnt, _
    vbCrLf & "Please choose an entity to split:")
    If Err.Number = 0 Then
    ' Entity must NOT be on a locked or frozen layer
    Set Layer = ThisDrawing.Layers(ent.Layer)

    If Layer.Lock = True Or Layer.Freeze = True Then
    ' We must try again!
    Call UpdateUserPrompt(" This entity is on a locked or frozen layer!")
    GoTo SelectEntity

    ' Must be valid entity type and the layer must be ON
    ElseIf TypeOf ent Is AcadPolyline Or _
    TypeOf ent Is AcadLWPolyline Or _
    TypeOf ent Is Acad3DPolyline And _
    Layer.LayerOn = True Then

    Call ent.Highlight(True)

    Else
    ' We must try again!
    Call UpdateUserPrompt(" You must select a POLYLINE or 3D POLYLINE.")
    GoTo SelectEntity

    End If
    End If

    ' Continue with macro

    ResetUserPrompt

    End Sub

    Private Sub ResetUserPrompt()

    ThisDrawing.Utility.Prompt (vbCrLf & "Command:")

    End Sub

    Private Sub UpdateUserPrompt(strPrompt As String)

    ThisDrawing.Utility.Prompt (strPrompt)

    End Sub

    Private Sub InitUserPrompt()

    ThisDrawing.Utility.Prompt (vbCrLf)

    End Sub

    [/pre]
     
    ajtruckle, Dec 16, 2004
    #6
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.