Xref Attach with no dialog?

Discussion in 'AutoCAD' started by Daniel J. Altamura, R.A., Apr 25, 2004.

  1. I can't figure out why the following code works at the command line, but not
    in program code.

    (command "-xref" "attach" "Title.dwg" "0,0" (getvar "dimscale") (getvar
    "dimscale") "0")

    Even if FILEDIA=0, the program keeps bringing up the dialog asking to select
    reference file. I want to supply the filename beforehand and not have to
    select it. Any ideas?

    Thanks for any help.
    Dan
     
    Daniel J. Altamura, R.A., Apr 25, 2004
    #1
  2. Daniel J. Altamura, R.A.

    Jeff Mishler Guest

    I'm not sure why, but you can use the following to emulate what you are
    doing:

    (defun addxref (name inspt x y z rot overlay)
    (vl-load-com)
    (vla-AttachExternalReference (vla-get-modelspace
    (vla-get-activedocument
    (vlax-get-acad-object)))
    (findfile (strcat name ".dwg"))
    name
    (vlax-3d-point inspt)
    x
    y
    z
    rot
    (if overlay
    :vlax-true
    :vlax-false
    )
    )
    )

    Usage would be like this:

    (addxref name insertionpoint xscale yscale zscale rotation overlay)
    where:
    name = a string for name of the xref, such as "Title"
    insertion point= 3d point for insertion
    xscale, yscale, zscale = real number for correseponding scale factor
    rotation = angle of rotation in radians
    overlay = If nil xref is placed as an attachment, else overlay is used

    So a sample would be:
    (addxref "car" '(5 5 5) 10 10 10 0.75 t)

    NOTE: This is written to assume that the drawing to be xref'ed can be found
    in the search path(s). Either verify this prior to calling the routine or
    you can rewrite this one to act as you wish.

    HTH,
    Jeff
     
    Jeff Mishler, Apr 26, 2004
    #2
  3. Thanks a lot Jeff! That worked perfectly. I really appreciate the help.

    Dan
     
    Daniel J. Altamura, R.A., Apr 26, 2004
    #3
  4. I have no problem with this. Not sure why it doesn't work for you.

    (defun c:xa ()
    (command "-xref" "attach" "drawing2.dwg" "0,0" 1 1 "0")
    (princ)
    )

    --
    Best Regards, Jimmy Bergmark
    CAD and Database Developer Manager at www.pharmadule-emtunga.com
    Take a look at
    JTB FlexReport (FLEXlm report tool) - www.jtbworld.com/jtbflexreport
    SmartPurger (Purges automatically) - www.jtbworld.com/?/smartpurger.htm
    or download some freeware at www.jtbworld.com
    More on AutoCAD 2005;
    www.jtbworld.com/autocad2005.htm
     
    Jimmy Bergmark, Apr 26, 2004
    #4
  5. Jimmy,
    Thanks for forcing me to take another hard look at my code. I discovered
    that I had an extra (initdia) function being used for xrefs, instead of just
    for block insertions. Now it works fine.

    Thanks again,
    Dan
     
    Daniel J. Altamura, R.A., Apr 26, 2004
    #5
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.