Open an Xref for editing

Discussion in 'AutoCAD' started by John Smith, Jul 30, 2003.

  1. John Smith

    John Smith Guest

    How can I open an Xref for editing using VBA? Below is my lisp code
    which works for AutoCAD R14.

    (defun dea_xref_edit ()
    (setq m "\n\nSelect XREF to edit:")
    (setq a 1)
    (setq a (entget (car (entsel m)) '("*")))
    (setq b (cdr (assoc 0 a)))
    (if (eq b "INSERT")
    (progn
    (setq c (cdr (assoc 2 a)))
    (setq d (tblsearch "BLOCK" c))
    (setq e (cdr (assoc 70 d)))
    (setq f (cdr (assoc 1 d)))
    (if (= (logand e 4) 4)
    (progn
    (command ".qsave")
    (setq c (strcat (getvar "DWGPREFIX") c))
    (setq g nil)
    (setq g (findfile c))
    (if (eq g nil)
    (setq g (findfile f))
    )
    (setvar "FILEDIA" 0)
    (command ".open" g "")
    )
    (dea_xref_edit_1)
    )
    )
    (dea_xref_edit_1)
    )
    (princ)
    )

    (defun dea_xref_edit_1 ()
    (setq a (getfiled "Object was not an XREF. Choose an XREF:" (getvar
    "DWGPREFIX") "dwg" 2))
    (command ".qsave")
    (command ".open" a "")
    )
     
    John Smith, Jul 30, 2003
    #1
  2. Here is a brief sample:

    Public Sub Test()
    Dim Picked As AcadEntity
    Dim PickPt
    ThisDrawing.Utility.GetEntity Picked, PickPt, vbCrLf & "Select an XRef: "

    If TypeOf Picked Is AcadExternalReference Then
    Dim XRef As AcadExternalReference
    Set XRef = Picked

    Dim FileName As String
    FileName = XRef.Path

    Dim XRefDoc As AcadDocument
    Set XRefDoc = AcadApplication.Documents.Open(FileName)
    Else
    MsgBox "Selected object was not an XRef.", vbExclamation, "Edit XRef"
    End If
    End Sub


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | How can I open an Xref for editing using VBA? Below is my lisp code
    | which works for AutoCAD R14.
    |
    | (defun dea_xref_edit ()
    | (setq m "\n\nSelect XREF to edit:")
    | (setq a 1)
    | (setq a (entget (car (entsel m)) '("*")))
    | (setq b (cdr (assoc 0 a)))
    | (if (eq b "INSERT")
    | (progn
    | (setq c (cdr (assoc 2 a)))
    | (setq d (tblsearch "BLOCK" c))
    | (setq e (cdr (assoc 70 d)))
    | (setq f (cdr (assoc 1 d)))
    | (if (= (logand e 4) 4)
    | (progn
    | (command ".qsave")
    | (setq c (strcat (getvar "DWGPREFIX") c))
    | (setq g nil)
    | (setq g (findfile c))
    | (if (eq g nil)
    | (setq g (findfile f))
    | )
    | (setvar "FILEDIA" 0)
    | (command ".open" g "")
    | )
    | (dea_xref_edit_1)
    | )
    | )
    | (dea_xref_edit_1)
    | )
    | (princ)
    | )
    |
    | (defun dea_xref_edit_1 ()
    | (setq a (getfiled "Object was not an XREF. Choose an XREF:" (getvar
    | "DWGPREFIX") "dwg" 2))
    | (command ".qsave")
    | (command ".open" a "")
    | )
    |
     
    R. Robert Bell, Jul 30, 2003
    #2
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.