See the top rated post in this thread. Click here

Results 1 to 3 of 3

Thread: Xref filename to layer name

  1. #1
    Member
    Join Date
    2005-01
    Posts
    13
    Login to Give a bone
    0

    Default Xref filename to layer name

    Hi,

    I'm looking to make a little tweak to a lisp routine that i use.

    I have a routine that i use to insert an xref to a drawing. The routine creates a layer name "Zz_30_30_ExternalReferences_" and makes that layer name current. It then runs the xref command (no dialogue box) and inserts the xref at 0,0 etc. so the xref sits on the layer created by the lisp. The routine then changes the current layer back to the layer that was current prior to running the routine.

    What i want to do is add to the end of the name of the created layer the dwg filename of the xref (no need for file path or file extension).

    e.g. filename of xref is "survey.dwg", created layer becomes "Zz_30_30_ExternalReferences_survey".

    Anyone able to help?

    my current code is:

    (defun c:InsertXref (/)
    (setq oldlayer (getvar "CLAYER")) ;get the current layer first

    (COMMAND "LAYER" "M" "Zz_30_30_ExternalReferences_" "C" "White" "" "") ;create layer and set colour

    (initdia)
    (command "_.-XREF" "_Overlay")
    (if (> (getvar "CMDACTIVE") 0)
    (progn
    (command "_None" '(0.0 0.0 0.0))
    (while (> (getvar "CMDACTIVE") 0) (command ""))
    )
    )
    (princ)
    (setvar "CLAYER" oldlayer)
    (command "_regenall")
    (command "_zoom" "E")

    )

  2. #2
    100 Club
    Join Date
    2002-08
    Posts
    191
    Login to Give a bone
    2

    Default Re: Xref filename to layer name

    Insert the xref first to get the name, then create / modify the layer accordingly.
    Code:
    (defun c:InsertXref ( / oldlayer dxf_ent name_xref tbl_layu )
    	(setq oldlayer (getvar "CLAYER")) ;get the current layer first
    	(initdia)
    	(command "_.-XREF" "_Overlay")
    	(if (> (getvar "CMDACTIVE") 0)
    		(progn
    			(command "_None" '(0.0 0.0 0.0))
    			(while (> (getvar "CMDACTIVE") 0) (command ""))
    		)
    	)
    	(setq name_xref (cdr (assoc 2 (setq dxf_ent (entget (entlast))))))
    	(entmod (subst (cons 8 (strcat "Zz_30_30_ExternalReferences_" name_xref)) (assoc 8 dxf_ent) dxf_ent))
    	(setq tbl_lay (entget (tblobjname "LAYER" (strcat "Zz_30_30_ExternalReferences_" name_xref))))
    	(entmod (subst (cons 62 7) (assoc 62 tbl_lay) tbl_lay))
    	(princ)
    	(setvar "CLAYER" oldlayer)
    	(command "_.regenall")
    	(command "_.zoom" "_Extent")
    )

  3. #3
    Member
    Join Date
    2005-01
    Posts
    13
    Login to Give a bone
    0

    Default Re: Xref filename to layer name

    Perfect. Thanks Bruno

Similar Threads

  1. 2014: Layout name to PDF filename
    By RG88 in forum AutoCAD General
    Replies: 3
    Last Post: 2013-11-09, 06:56 AM
  2. 2008 SCALE 1:100 xref xref xref xref- scale list issues
    By Apsis0215 in forum AutoCAD Customization
    Replies: 2
    Last Post: 2008-11-21, 08:17 PM
  3. Ignore XREF portion of layer name upon restoring layer state
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2006-11-08, 12:30 PM
  4. Replies: 2
    Last Post: 2006-09-01, 01:42 PM
  5. Xref Filename Field to remain *
    By DBowers in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2005-07-28, 06:19 PM

Tags for this Thread

Posting Permissions

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