Results 1 to 10 of 10

Thread: routine to insert Xref's

  1. #1
    Member
    Join Date
    2008-05
    Posts
    20
    Login to Give a bone
    0

    Default routine to insert Xref's

    Hi guys,
    this has been asked several times but i still cant find a way to do so
    i need a routine to insert xref,s . what im thinking of is a script i can apply to many drawings by script pro and during each session i get asked to choose the file to xref.
    do you guys have any thought or could be better idea to do this.

    Many thanks in advance

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,762
    Login to Give a bone
    0

    Default Re: routine to insert Xref's

    Have you tried the XATTACH command? A little more information would be helpful.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Member
    Join Date
    2008-05
    Posts
    20
    Login to Give a bone
    0

    Default Re: routine to insert Xref's

    Quote Originally Posted by Opie View Post
    Have you tried the XATTACH command? A little more information would be helpful.
    Thanks Opie, it looks good, but i have to click "ok" after choosing the file to xref, i don't usually change any of the insertion default sittings, so can i automate this by script so no need to click "ok" ?
    In fact i just need the fastest and easiest way to insert xrefs, I'm not stick to particular way.

  4. #4
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: routine to insert Xref's

    That xattach command always opens the file selection dialog as well as the External Reference dialog. No matter if it's called from lisp or a script. Also no matter what filedia / cmddia are set to.

    What I suggest you try is use the INSERT command to first insert the DWG as a block. Then change it by calling the Express tool BlockToXref's support defun (acet-block-to-xref ...). Look at the blocktoxrefsup.lsp file in the Express folder. The defun asks for the block name, the file name and then a T/nil to purge.

    A bit convoluted, but at least it "should" work.

  5. #5
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: routine to insert Xref's

    Couldn't you just use (getfiled .....) and (command "_.-xref"...)?

  6. #6
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: routine to insert Xref's

    Ugh , you're correct!

    But you don't even need to use getfiled first. You can simply automate the arguments of the -XREF command:
    Code:
    (defun c:QuickXAttach (/)
      (initdia)
      (command "_.-XREF" "_Attach" "_None" '(0.0 0.0 0.0))
      (while (> (getvar "CMDACTIVE") 0) (command ""))
      (princ)
    )
    If you need to be able to select the insertion point, change the "_None" '(0.0 0.0 0.0) to pause.

  7. #7
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: routine to insert Xref's

    Quote Originally Posted by irneb View Post
    Ugh , you're correct!

    But you don't even need to use getfiled first. You can simply automate the arguments of the -XREF command:
    Code:
    (defun c:QuickXAttach (/)
      (initdia)
      (command "_.-XREF" "_Attach" "_None" '(0.0 0.0 0.0))
      (while (> (getvar "CMDACTIVE") 0) (command ""))
      (princ)
    )
    If you need to be able to select the insertion point, change the "_None" '(0.0 0.0 0.0) to pause.

    True, I was just thinking about if the user doesn't select a file.

    Code:
    (defun c:QuickXAttach (/ f)
      (if (setq f (getfiled "Select Reference File:" (getvar 'dwgprefix) "dwg" 2))
        (progn (command "_.-XREF" "_Attach" f "_None" '(0.0 0.0 0.0))
               (while (> (getvar "CMDACTIVE") 0) (command ""))
        )
      )
      (princ)
    )

  8. #8
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: routine to insert Xref's

    Good point

    ... Many ways to skin a cat:
    Code:
    (defun c:QuickXAttach (/)
      (initdia)
      (command "_.-XREF" "_Attach")
      (if (> (getvar "CMDACTIVE") 0)
        (progn
          (command "_None" '(0.0 0.0 0.0))
          (while (> (getvar "CMDACTIVE") 0) (command ""))
        )
      )
      (princ)
    )
    From the back or the front

  9. #9
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: routine to insert Xref's

    Quote Originally Posted by irneb View Post
    Good point

    ... Many ways to skin a cat:
    Code:
    (defun c:QuickXAttach (/)
      (initdia)
      (command "_.-XREF" "_Attach")
      (if (> (getvar "CMDACTIVE") 0)
        (progn
          (command "_None" '(0.0 0.0 0.0))
          (while (> (getvar "CMDACTIVE") 0) (command ""))
        )
      )
      (princ)
    )
    From the back or the front
    Very impressive! I never would have thought of that.

  10. #10
    Member
    Join Date
    2008-05
    Posts
    20
    Login to Give a bone
    0

    Default Re: routine to insert Xref's

    Thank you guys, it was of great help

Similar Threads

  1. Trying to find a comma insert routine
    By BCrouse in forum AutoLISP
    Replies: 2
    Last Post: 2009-09-02, 03:30 AM
  2. Insert Copy Routine
    By cadconcepts in forum AutoLISP
    Replies: 12
    Last Post: 2008-03-21, 06:18 AM
  3. Replies: 5
    Last Post: 2006-12-20, 04:11 PM
  4. Date Insert Block routine
    By b_v_mc in forum AutoLISP
    Replies: 12
    Last Post: 2006-05-17, 05:59 PM
  5. Block insert and explode lisp routine
    By rayski in forum AutoLISP
    Replies: 4
    Last Post: 2005-05-19, 01:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •