Jump to content

Select Xref Layer to match Source XREF visretain


rcb007

Recommended Posts

I did not know if there was a way to perform a visretain to 0, reload xref, then set visretain to 1 for just a selected layer (instead of the whole xref)?

 

What I have been dealing with lately is a user would change the a linetype and color of (example: property line) from solid line to a phantom line. I would have to to into the plan sheet and the above.

 

The cheat I have been messing around with is, by changing the layer name. that way it pushes through.

 

I hope I am explaining this correctly lol.

Link to comment
Share on other sites

Does this accomplish the desired result, or have I misunderstood your requirements?

 

EDIT: The above will reset specific properties of all layers, but could be modified to target a specific layer if necessary.

Edited by Lee Mac
Link to comment
Share on other sites

Thank you for the feedback! I was able to load the routine in. I did "RXL" then selected the xref layer i wanted to change back to make the source dwg. However, when i did that, it reset the whole xref dwg to match the source. (Just to make sure i kinda make sense. I turned whole xref dwg to color blue and continuous linetype). It did reset it to match the source dwg.

Again, i could have not done the command correctly.

 

 

Link to comment
Share on other sites

For single layers I use the routine by Joe Burke posted here:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/revert-layer/m-p/1278570#M176366

 

Unfortunately the autodesk forum destroyed the formatting & removed all line breaks. My version is below, thought it might have some changes from Joe's original code

;;; Reply-To: "Joe Burke" <jobu...@hawaii.rr.com>
;;; From: "Joe Burke" <jobu...@hawaii.rr.com>
;;; Newsgroups: autodesk.autocad.customization
;;; Subject: Re: Revert Layer
;;; Date: Fri, 25 Mar 2005 02:23:33 -1000
;;;
;;; Jason,
;;;
;;; Here's what I use. It's designed to do what you asked.
;;;
;;; It's not what it should be if you happen to pick an object in an xref on layer zero
;;; or defpoints. But it met my needs at the time.
;;;
;;; I haven't used it much since, so it hasn't had much testing. Let me know if you find
;;; any problems.
;;;
;;; Joe Burke  4/13/2004
;;; update the selected xref layer color and linetype in the
;;; active file from xref source file
(defun c:XrefReloadLayer ( / *Error* *acad* doc documents layers elst vobj
                             layname layobj pos xlayname xblk xblkname path
                             xdoc xlayers xlayobj xclr xltyp xpsty)

  (defun *Error* (Msg)
   (cond
    ((or (not Msg)
         (member Msg '("console break"
                       "Function cancelled"
                       "quit / exit abort"))))
    ((princ (strcat "\nError: " Msg)))
   )
   (princ)
  )

  (setq *acad* (vlax-get-acad-object)
        doc (vla-get-activedocument *acad*)
        documents (vla-get-Documents *acad*)
        layers (vla-get-Layers doc)
  )
  (while
    (or
      (not (setq elst (nentsel "\nSelect object on xref layer to reset color & linetype: ")))
      (not (eq 'ENAME (type (last (last elst)))))
      (not (vlax-property-available-p
           (vlax-ename->vla-object (last (last elst))) 'Path))
    )
    (princ "\nMissed pick or xref not selected: ")
  ) ;_while
  (and
    (setq vobj (vlax-ename->vla-object (car elst)))
    (setq layname (vlax-get vobj 'Layer))
    (if (equal "0" layname) ;obj is probably in a block
      (progn
        (setq vobj (vlax-ename->vla-object (car (last elst))))
        (setq layname (vlax-get vobj 'Layer))
      )
      T
    )
    (setq layobj (vla-item layers layname))
    (if (not (vl-string-search "|" layname))
      (progn
        (princ "\nCannot determine xref layer name... exiting. ")
        (exit)
      )
      T
    ) ;_if
    (setq pos      (vl-string-search "|" layname))
    (setq xlayname (substr layname (+ 2 pos)))
    (setq xblk     (vlax-ename->vla-object (last (last elst))))
    (setq xblkname (vlax-get xblk 'Name))
    (setq path     (XrefReloadLayer_get-xref-path xblkname))
    (setq xdoc     (XrefReloadLayer_DocAtPath path))
    (setq xlayers  (vla-get-Layers xdoc))
    (setq xlayobj  (vla-item xlayers xlayname))
    (setq xclr     (vlax-get xlayobj 'Color))
    (setq xltyp    (vlax-get xlayobj 'Linetype))
    (setq xpsty    (vlax-get xlayobj 'PlotStyleName))
    
    (vlax-release-object xdoc)
    (not (vlax-put layobj 'Color xclr))
    (not (vlax-put layobj 'Linetype xltyp))
    
    
    
    (not (vlax-put layobj 'PlotStyleName xpsty))
  ) ;and
  (vla-regen doc acActiveViewport)
  (princ (strcat "\nLayer " layname " reset to color: " (vl-princ-to-string xclr) ", linetype: "(vl-princ-to-string xltyp)", plotstyle: "(vl-princ-to-string xpsty)))
  (*Error* nil)
) ;end

;; -----------------------------
;; argument: full path
;; returns a document object (srcdoc)
;; either an open document or an ODBX doc
(defun XrefReloadLayer_DocAtPath ( path / *acad* documents srcdoc )
  (setq *acad* (vlax-get-acad-object)
        documents (vla-get-documents *acad*)
  )
  ;check the documents collection
  (vlax-for x documents
    (if (= path (vlax-get x 'FullName))
      (setq srcdoc x)
    )
  )
  ;if not in documents collection, use ObjectDBX
  (if (null srcdoc)
    (cond
      ((> (atoi (getvar "AcadVer")) 15)
        (setq srcdoc
          (vla-GetInterfaceObject *acad* "ObjectDBX.AxDbDocument.16"))
        (vla-open srcdoc path)
      )
      (T
        (if (not
         (vl-registry-read "HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument\\CLSID"))
           (startapp "regsvr32.exe"
             (strcat "/s \"" (findfile "axdb15.dll") "\""))
        )
        (setq srcdoc (vla-GetInterfaceObject *acad* "ObjectDBX.AxDbDocument"))
        (vla-open srcdoc path)
      )
    )
  )
  srcdoc
) ;end

;; -----------------------------


;; -----------------------------
;; If an xref is not found in the saved path AutoCAD searches
;; the whole support path. By Stephan Koster 2001
;; argument: an xref block name
;; returns the full path to the xref if successful
(defun XrefReloadLayer_get-xref-path (blockname / data path saved_path pos)
 (cond ((not (setq data (tblsearch "block" blockname))))
       ;; Does the block exist
       ((/= (logand (cdr (assoc 70 data)) 4) 4))
       ;; Is it an xref
       ((and (setq saved_path (cdr (assoc 1 data)))
             (setq path (findfile saved_path))
             ;; Can it be found on the saved path
        )
       )
       ((not (setq pos (vl-string-position (ascii "\\") saved_path 1 T))))
       (T (setq path (findfile (substr saved_path (+ pos 2)))))
       ;; Can it be found somewhere else in the search path
 )
 path
)


 

Edited by dan20047
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...