Results 1 to 2 of 2

Thread: Assigning an xref to a layer

  1. #1
    Member
    Join Date
    2021-08
    Posts
    23
    Login to Give a bone
    0

    Post Assigning an xref to a layer

    I have been using the code below to assign xrefs to the necessary layer when there bought into drawings. This works well however, this does not work when using add on package, I can see the process to attach an xref using the package is evoked using _dmsattach as shown in the image attached.

    I was wondering how I could add this command to the below code to ensure that when I attach an xref through the add on package it will go to the correct layer?

    Any help would be greatly appreciated.

    Code:
    (if (null myxr-react)
      (setq myxr-react (vlr-command-reactor nil '((:vlr-commandwillstart . myxr-swaplayer)
    					      (:vlr-commandended . myxr-restorelayer)
    					      (:vlr-commandcancelled . myxr-restorelayer))))
      )
    
    (defun setormakelayer (layn doc)
        (if	(null (tblsearch "layer" layn))
          (vla-add (vla-get-layers doc) layn))
        (setvar "clayer" layn)
    )
    
    ;;commandwillstart callback (reactor commandlist)
    (defun myxr-swaplayer (r cl / doc)
      (if (wcmatch (strcase (car cl)) "*XATTACH*,*XREF*,*-XREF* ");allowance for other commands
        (progn
          (setq doc (vlr-document r))
          (vlr-data-set r (getvar "clayer"))
        (if
          (= 1 (vla-get-activespace doc))
          (setormakelayer "_XREF" doc)
          (setormakelayer "_XREF" doc)
          ))))
    
    ;;commandended callback (reactor commandlist)
    (defun myxr-restorelayer (r cl)
      (if (and (member (car cl) '("XREF" "XATTACH" "-XREF"))
    	   (vlr-data r))
        (setvar "clayer" (vlr-data r))
        (vlr-data-set r nil)
        )
      )
    Attached Images Attached Images
    Last edited by BlackBox; 2021-10-21 at 11:31 AM. Reason: Please use [CODE] Tags

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Assigning an xref to a layer

    Not familiar with _dmsattach; perhaps simply making these two lines the same will help:

    Code:
    (if (null myxr-react)
      (setq myxr-react (vlr-command-reactor nil '((:vlr-commandwillstart . myxr-swaplayer)
    					      (:vlr-commandended . myxr-restorelayer)
    					      (:vlr-commandcancelled . myxr-restorelayer))))
      )
    
    (defun setormakelayer (layn doc)
        (if	(null (tblsearch "layer" layn))
          (vla-add (vla-get-layers doc) layn))
        (setvar "clayer" layn)
    )
    
    ;;commandwillstart callback (reactor commandlist)
    (defun myxr-swaplayer (r cl / doc)
      (if (wcmatch (strcase (car cl)) "*ATTACH,*XCLIP*,*XREF");allowance for other commands
        (progn
          (setq doc (vlr-document r))
          (vlr-data-set r (getvar "clayer"))
        (if
          (= 1 (vla-get-activespace doc))
          (setormakelayer "_XREF" doc)
          (setormakelayer "_XREF" doc)
          ))))
    
    ;;commandended callback (reactor commandlist)
    (defun myxr-restorelayer (r cl)
      (if (wcmatch (strcase (car cl)) "*ATTACH,*XCLIP*,*XREF");allowance for other commands
    	   (vlr-data r))
        (setvar "clayer" (vlr-data r))
        (vlr-data-set r nil)
        )
      )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. Batch Assigning Xref's
    By wdobbin791223 in forum AutoLISP
    Replies: 1
    Last Post: 2021-03-28, 11:37 PM
  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. Assigning Elevation to a Layer
    By ljupadhyay in forum ACA General
    Replies: 6
    Last Post: 2007-04-24, 07:28 PM
  4. Assigning Elevation to a Layer
    By ljupadhyay in forum ACA Wish List
    Replies: 1
    Last Post: 2007-04-24, 05:03 PM
  5. assigning layer key to new all style?
    By vanderloo5 in forum ACA General
    Replies: 0
    Last Post: 2005-06-28, 03:15 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
  •