double click to open xref?

Discussion in 'AutoCAD' started by devon, Jul 14, 2004.

  1. devon

    devon Guest

    Hi,

    I am new to VB in acad and have a workmate who is sharp with VB.

    I would like to know what reactors/commands in VB I need to use so I can have him make a VB routine that allows you to double click on an xref and then it opens up.

    I assume you need to undefine the "reference edit" command and then set a double ckick reactor for opening the selected xref.

    Any help would be most appreciated.

    Thanks
    Devon
     
    devon, Jul 14, 2004
    #1
  2. devon

    Tom Roberts Guest

    Hi Devon

    If you disable autocads double click feature by setting the DBLCLKEDIT
    system variable to OFF you can then write your own code to fire when the
    AcadDocument.BeginDoubleClick event occurs. The problem is that you loose
    the doubleclick feature on all entity types so you have to write code for
    every entity type that you want to react to the doubleclick event.

    Below is some code that will open an Xref when doubleclicked and also handle
    a few other entity types.

    Regards
    Tom Roberts
    __________________________
    MechWest Design & Drafting
    Perth, Western Australia



    '****************************** START OF VBA CODE
    ******************************
    Private Sub AcadDocument_BeginDoubleClick(ByVal PickPoint As Variant)

    On Error GoTo ERR_DBLCLK

    Dim sObjNme As String
    Dim objEnt As AcadEntity
    Dim objBlk As AcadBlock
    Dim objSS As AcadSelectionSet
    Dim sFilename As String

    Set objSS = ThisDrawing.PickfirstSelectionSet
    If Not objSS Is Nothing Then
    If objSS.Count > 0 Then
    Set objEnt = objSS(objSS.Count - 1)
    sObjNme = objEnt.ObjectName
    Select Case sObjNme
    Case "AcDbBlockReference"
    Set objBlk = ThisDrawing.Blocks(objEnt.Name)
    If objBlk.IsXRef Then
    sFilename = objEnt.Path
    Application.Documents.Open sFilename
    End If
    Case "AcDbAttributeDefinition"
    ThisDrawing.SendCommand "_DDEDIT" & vbLf
    Case "AcDbHatch"
    ThisDrawing.SendCommand "_HATCHEDIT" & vbLf
    Case "AcDbMline"
    ThisDrawing.SendCommand "_MLEDIT" & vbLf
    Case "AcDbMText", "AcDbText"
    ThisDrawing.SendCommand "_DDEDIT" & vbCrLf
    Case Else
    ThisDrawing.SendCommand "_PROPERTIES" & vbLf
    End Select
    End If
    End If
    EXIT_DBLCLK:
    Exit Sub

    ERR_DBLCLK:
    GoTo EXIT_DBLCLK

    End Sub
    '****************************** END OF VBA CODE
    ******************************



    have him make a VB routine that allows you to double click on an xref and
    then it opens up.
    double ckick reactor for opening the selected xref.
     
    Tom Roberts, Jul 14, 2004
    #2
  3. devon

    devon Guest

    Hi,

    Thanks for the pointer. I tried that vb code but get nothing happening.

    I just stick it into a .dvb file correct? through the vb editor in acad ?

    Thanks
     
    devon, Jul 14, 2004
    #3
  4. In the ThisDrawing portion of the DVB.
    Regards - Nathan
     
    Nathan Taylor, Jul 14, 2004
    #4
  5. devon

    devon Guest

    Thank you both very much for the help and replys.

    One question,

    I can't seem to double click on attributed blocks and get the attedit dialogue.
    But the VB code looks like its listed in there.

    Any idea why this would be?
    It works fine for the other double clicking.

    Cheers
    Devon
     
    devon, Jul 16, 2004
    #5
  6. No worries Devon, give this a go.

    Code:
    
    Private Sub AcadDocument_BeginDoubleClick(ByVal PickPoint As Variant)
    
    On Error GoTo ERR_DBLCLK
    
    Dim sObjNme As String
    Dim objEnt As AcadEntity
    Dim objBlk As AcadBlock
    Dim objSS As AcadSelectionSet
    Dim sFilename As String
    
    Set objSS = ThisDrawing.PickfirstSelectionSet
    If Not objSS Is Nothing Then
    If objSS.Count > 0 Then
    Set objEnt = objSS(objSS.Count - 1)
    sObjNme = objEnt.ObjectName
    Select Case sObjNme
    Case "AcDbBlockReference"
    Set objBlk = ThisDrawing.Blocks(objEnt.Name)
    If objBlk.IsXRef Then
    sFilename = objEnt.Path
    Application.Documents.Open sFilename
    Else 'Added by Nathan
    If objEnt.HasAttributes = True Then 'Added by Nathan
    ThisDrawing.SendCommand "EATTEDIT " 'Added by Nathan
    Else 'Added by Nathan
    ThisDrawing.SendCommand "REFEDIT "  'Added by Nathan
    End If 'Added by Nathan
    End If
    Case "AcDbAttributeDefinition"
    ThisDrawing.SendCommand "_DDEDIT" & vbLf
    Case "AcDbHatch"
    ThisDrawing.SendCommand "_HATCHEDIT" & vbLf
    Case "AcDbMline"
    ThisDrawing.SendCommand "_MLEDIT" & vbLf
    Case "AcDbMText", "AcDbText"
    ThisDrawing.SendCommand "_DDEDIT" & vbCrLf
    Case Else
    ThisDrawing.SendCommand "_PROPERTIES" & vbLf
    End Select
    End If
    End If
    EXIT_DBLCLK:
    Exit Sub
    
    ERR_DBLCLK:
    GoTo EXIT_DBLCLK
    
    End Sub
    
    
    Regards - Nathan
     
    Nathan Taylor, Jul 16, 2004
    #6
  7. devon

    devon Guest

    Thanks Nathan

    Cheers for the help. Much appreciated.

    Another thing, when you select the attribute to edit (doubleclick on) the eattedit dia pops up and the 1st attribute is highlighted (like 2000x acad)
    Is their any function you can do so it highlights the attribute you click on.

    like if you type eattedit at the cmd line, and then select the 4th line in a Titleblock, thats then the one that the eattedit dialogue has highlighted.

    Does this make sence? I am just saying that the result using the same command in 2004/05 seems ot work different if you type it compared to if I have it in this vb code.

    Cheers
     
    devon, Jul 16, 2004
    #7
  8. I think it would be possible albeit more complicated than the last change was to make. I may look at it at some stage for my own DoubleClick routine but in the meantime someone else may provide the answer.

    Regards - Nathan
     
    Nathan Taylor, Jul 16, 2004
    #8
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.