Jump to content

XREF Layer Color and VISRETAIN=1


geocad

Recommended Posts

Hey everybody,

 

I have a base map that references several tens of other drawings. I have visretain=1 because I want to freeze certain xref layers in individual view ports of 36 different layouts in the base map. My issue is that when I make a change to an xref, say a layer color, it will not be seen because visretain=1. If I change visretain=0 and save the xref drawing and reload it in the base map, the color change will show, but now all my freeze options in the viewports for that xref's layers are reset. Is there a way to update an xrefs layer properties without losing the base maps viewport freeze settings for that xref. Hopefully this makes sense.

 

Thanks for any help.

 

Josh

Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • geocad

    8

  • irneb

    5

  • designerstuart

    3

  • Tiger

    2

Top Posters In This Topic

Posted Images

I run into this quite frequently and I don't think there is a way to do exactly what you desire. What I do is change the name of the layer in the XREF slightly. If it's named A-ANNO, I'll change it to A_ANNO.

Link to comment
Share on other sites

Thank you for the response Rob. Glad to hear that I am not the only one who has faced this challenge. I did figure out a work around that works well enough for me. I keep the base drawing open, open the xref make the change and save it, go back into the open base map and change visretain to 0 and click on the pop up (not sure if this is available on previous versions) to reload the xref, then change visretain=1. I then freeze the layer I didn't want in all view ports. I think if I had to have certain layers frozen in some view ports and not in others this might not work so well, but since it is primarily a few layers frozen in all view ports, it seems to work. The key for me was not to close the base and reopen it with visretain=0, as it would reset everything.

Link to comment
Share on other sites

Have you tried using Layer States? You can save the layer state prior to editing the xref, then set VisRetain=0, reload it, set VisRetain=1, then open the Layer States manager, selec the state you saved, click the "Clear All" button in the "Layer properties to restore" group on the right, then click the "Restore" button at the bottom.

 

Note that the On/Off and Frozen/Thawed properties is always restored - you can only omit other properties like Colour, Linetype, etc. If you can't see the properties, click the round "Expand" button at the bottom right (it should have a image like a Greater-Than sign).

capture_01132012_124349.png

Link to comment
Share on other sites

I have been playing around with the layer states and they do work well, just as you described. They work well when the xref is changed while the base map is open so that visretain can be changed from 1 to 0, update the drawing, change visretain back to 1 and restore the layer state, but I cannot get them to work when I set visretain to 0 and close and reopen the drawing. I figured that if I had to change a bunch of drawings I could just make visretain=0, save the drawing, close it, reopen the drawing and restore all my settings with the layer state, but this doesn't work. I am not very familiar with layer states and was wondering if I was missing something or maybe they don't work in that way.

 

Thanks for the help.

 

Josh

Link to comment
Share on other sites

Well, the problem I have with LS is that it's all layers or none. You can't pick which layers to adjust. And also you need to perform a LS restore inside each VP is you've got VPFreeze and / or VP Overrides ... which could be a schlep. Luckily there is a method of automating these through lisp, but it's a bit "advanced".

 

The biggest issue with LS is that it tends to break, or at least perform strangely when you start adding / removing / renaming layers.

Link to comment
Share on other sites

UPDATE!

I was too fast with this "solution" and further proper testing (not at 4PM) shows that this doesn't work. Too bad.

 

I have this problem all the time - last week I tried something out of the blue though. After I changed VISRETAIN to 0 and reloaded the xref, I did an UNDO - and the layers went back to where they were. I would love to know if this works for everyone or if its just my particular combination of files that lets it work.

Edited by Tiger
added update
Link to comment
Share on other sites

Hey everybody,

 

I have a base map that references several tens of other drawings. I have visretain=1 because I want to freeze certain xref layers in individual view ports of 36 different layouts in the base map. My issue is that when I make a change to an xref, say a layer color, it will not be seen because visretain=1. If I change visretain=0 and save the xref drawing and reload it in the base map, the color change will show, but now all my freeze options in the viewports for that xref's layers are reset. Is there a way to update an xrefs layer properties without losing the base maps viewport freeze settings for that xref. Hopefully this makes sense.

 

Thanks for any help.

 

Josh

 

it happens to me only if i have chnaged that property(color) in host drawing, than it does not get updated but other wise if you left it to defaut as it is in original drawing, than whenever you chnage it, it will get updated in host drawing with reloading without making visretain 0

Link to comment
Share on other sites

Well, the problem I have with LS is that it's all layers or none. You can't pick which layers to adjust. And also you need to perform a LS restore inside each VP is you've got VPFreeze and / or VP Overrides ... which could be a schlep. Luckily there is a method of automating these through lisp, but it's a bit "advanced".

 

The biggest issue with LS is that it tends to break, or at least perform strangely when you start adding / removing / renaming layers.

 

I will definitely look to layer states in the future, but at this time, with 36 plates, I will avoid using them if you have to perform an LS restore in each VP.

 

Thanks for all of the responses.

 

Josh

Link to comment
Share on other sites

I have this problem all the time - last week I tried something out of the blue though. After I changed VISRETAIN to 0 and reloaded the xref, I did an UNDO - and the layers went back to where they were. I would love to know if this works for everyone or if its just my particular combination of files that lets it work.

 

I was curious to see what would happen and tried to recreate what you had done. I changed a layer color in an xref and saved it, I then set visretain=0 and reloaded the xref. The changed layer updated and all the VP frozen layers from that xref became unfrozen. I did an undo and it returned the VP to its original appearance as it undid the reload of the xref; it didn't show the change I had made to the xref. I couldn't recreate what you had done, but I think I may have misunderstood what you were saying. When exactly did you use undo and what did it undo.

 

Thanks.

 

Josh

Link to comment
Share on other sites

I was curious to see what would happen and tried to recreate what you had done. I changed a layer color in an xref and saved it, I then set visretain=0 and reloaded the xref. The changed layer updated and all the VP frozen layers from that xref became unfrozen. I did an undo and it returned the VP to its original appearance as it undid the reload of the xref; it didn't show the change I had made to the xref. I couldn't recreate what you had done, but I think I may have misunderstood what you were saying. When exactly did you use undo and what did it undo.

 

Thanks.

 

Josh

 

I tested it further on my machine and I have to admit that I was too fast in thinking I had found the holy workaround - it doesn't work on my machine either. I apologise for getting your hopes up.

Link to comment
Share on other sites

I tested it further on my machine and I have to admit that I was too fast in thinking I had found the holy workaround - it doesn't work on my machine either. I apologise for getting your hopes up.

 

No worries, it was worth a try.

Link to comment
Share on other sites

OK, I've made a Lisp for reloading selected layer's selected properties from the xref:

(vl-load-com)
(or *Application* (setq *Application* (vlax-get-acad-object)))
(or *Application-ActiveDocument*
   (setq *Application-ActiveDocument* (vla-get-ActiveDocument *Application*))
)
(or *ActiveDocument-Blocks*
   (setq *ActiveDocument-Blocks* (vla-get-Blocks *Application-ActiveDocument*))
)
(or *ActiveDocument-Layers*
   (setq *ActiveDocument-Layers* (vla-get-Layers *Application-ActiveDocument*))
)

;;; -------------------------------------------------------------------------------------
;;; Obtain doc object of XRef
;;; -------------------------------------------------------------------------------------
;;; Argument: XRef name
;;; -------------------------------------------------------------------------------------
(defun XRLay:GetXDoc (xname / blk doc acVer)
 (if (and (not (vl-catch-all-error-p
                 (setq blk (vl-catch-all-apply 'vla-Item (list *ActiveDocument-Blocks* xname)))
               )
          )
          (= (vla-get-IsXRef blk) :vlax-true)
          (setq blk (findfile (vla-get-Path blk)))
     )
   (progn
     (setq doc (vla-GetInterfaceObject
                 *Application*
                 (if (< (setq acVer (atoi (getvar "ACADVER"))) 16)
                   "ObjectDBX.AxDbDocument"
                   (strcat "ObjectDBX.AxDbDocument." (itoa acVer))
                 )
               )
     )
     (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list doc blk))))
       doc
       (progn (vlax-release-object doc) nil)
     )
   )
 )
)

;;; -------------------------------------------------------------------------------------
;;; Get list of XRefs
;;; -------------------------------------------------------------------------------------
(defun XRLay:GetXRefs (/ lst)
 (vlax-for blk *ActiveDocument-Blocks*
   (if (= (vla-get-IsXRef blk) :vlax-true)
     (setq lst (cons (vla-get-Name blk) lst))
   )
 )
 (acad_strlsort lst)
)

;;; Function to load XRefLayers dialog
(defun load_dialog_XRefLayers (/ fn f)
 (setq fn (strcat (getvar "TEMPPREFIX") "XRefLayers.DCL"))
 (setq f (open fn "w"))
 (write-line "XRLay : dialog {" f)
 (write-line
   "  label = \"Select XRefs' Layers && Properties to revert back to original\";"
   f
 )
 (write-line "  : row {" f)
 (write-line "    : column {" f)
 (write-line "      : popup_list {" f)
 (write-line "        key = \"xrefs\";" f)
 (write-line "        label = \"List of &XRefs\";" f)
 (write-line "        edit_width = 50;" f)
 (write-line "      }" f)
 (write-line "      : list_box {" f)
 (write-line "        key = \"layers\";" f)
 (write-line "        label = \"List of XRef &Layers\";" f)
 (write-line "        height = 18;" f)
 (write-line "        multiple_select = true;" f)
 (write-line "      }" f)
 (write-line "    }" f)
 (write-line "    : column {" f)
 (write-line "      : boxed_column {" f)
 (write-line "        label = \"&Properties\";" f)
 (write-line "        : toggle { label = \"Off/On\"; key = \"off\"; }" f)
 (write-line "        : toggle { label = \"Freeze/Thaw\"; key = \"freeze\"; }" f)
 (write-line "        : toggle { label = \"Locked\"; key = \"lock\"; }" f)
 (write-line "        : toggle { label = \"Plot\"; key = \"plot\"; }" f)
 (write-line "        : toggle { label = \"Color\"; key = \"color\"; }" f)
 (write-line "        : toggle { label = \"Line Type\"; key = \"linetype\"; }" f)
 (write-line "        : toggle { label = \"Line Weight\"; key = \"lineweight\"; }" f)
 (write-line "        spacer_1;" f)
 (write-line "        : toggle { label = \"Viewport Freeze\"; key = \"vpfrz\"; }" f)
 (write-line "        : toggle { label = \"Viewport Overrides\"; key = \"vpovr\"; }" f)
 (write-line "      }" f)
 (write-line "      : row {" f)
 (write-line
   "        : button { key = \"accept\"; label = \"&Apply\"; is_default = true; }"
   f
 )
 (write-line
   "        : button { key = \"cancel\"; label = \"&Close\"; is_cancel = true; }"
   f
 )
 (write-line "      }" f)
 (write-line "    }" f)
 (write-line "  }" f)
 (write-line "}" f)
 (close f)
 (load_dialog fn)
) ;_ end of defun

;;; Function to run the XRLay dialog
(defun run_dialog_XRefLayers_XRLay (key_list extra / dcl return)
 (if (and (setq dcl (load_dialog_XRefLayers)) (new_dialog "XRLay" dcl))
   (progn
     (foreach key key_list
       (if (cadr key)
         (set_tile (car key) (cadr key))
       )
       (if (caddr key)
         (action_tile (car key) (caddr key))
       )
       (if (cadddr key)
         (progn
           (start_list (car key))
           (mapcar 'add_list (cdddr key))
           (end_list)
         )
       )
     )
     (if extra
       (eval extra)
     )
     (setq return (start_dialog))
     (unload_dialog dcl)
   )
 )
 return
) ;_ end of defun


;;; -------------------------------------------------------------------------------------
;;; Dialog to ask user to select XRefs & Properties to reload
;;; -------------------------------------------------------------------------------------
(defun c:XLayerReload (/ XRlst XLayLst :SelectXRef :DoLayers)
 (defun :SelectXRef ($value / doc x layCol)
   (if (setq XLayLst nil
             doc     (XRLay:GetXDoc (nth (read $value) XRlst))
       )
     (progn
       (vlax-for lay (vla-get-Layers doc)
         (if (not (wcmatch (strcase (vla-get-Name lay)) "0,DEFPOINTS"))
           (setq XLayLst (cons (vla-get-Name lay) XLayLst))
         )
       )
       (vlax-release-object doc)
       (start_list "layers" 3)
       (mapcar 'add_list XLayLst)
       (end_list)
       (set_tile "layers" "")
     )
     (progn
       (start_list "layers" 3)
       (end_list)
     )
   )
 )

 (defun :DoLayers (/ xname llst doc xlcol clcol cl)
   (if (and (setq doc (XRLay:GetXDoc (setq xname (nth (read (get_tile "xrefs")) XRlst))))
            (setq llst (mapcar (function (lambda (n) (nth n XLayLst)))
                               (read (strcat "(" (get_tile "layers") ")"))
                       )
            )
            (setq xlcol (vla-get-Layers doc))
       )
     (progn
       (foreach xl llst
         (if (and
               (not (vl-catch-all-error-p
                      (setq cl (vl-catch-all-apply
                                 'vla-Item
                                 (list *ActiveDocument-Layers* (strcat xname "|" xl))
                               )
                      )
                    )
               )
               (not (vl-catch-all-error-p
                      (setq xl (vl-catch-all-apply
                                 'vla-Item
                                 (list xlcol xl)
                               )
                      )
                    )
               )
             )
           (progn
             (mapcar
               (function
                 (lambda (item)
                   (if (eq (get_tile (car item)) "1")
                     (vl-catch-all-apply
                       'vlax-put-property
                       (list cl
                             (cdr item)
                             (vl-catch-all-apply
                               'vlax-get-property
                               (list xl (cdr item))
                             )
                       )
                     )
                   )
                 )
               )
               '(("off" . "LayerOn")
                 ("freeze" . "Freeze")
                 ("lock" "Lock")
                 ("plot" . "Plottable")
                 ("color" . "Color")
                 ("linetype" . "Linetype")
                 ("lineweight" . "Lineweight")
                )
             )
           )
         )
       )
       (vlax-release-object doc)
     )
   )
 )

 (if (setq XRlst (XRLay:GetXRefs))
   (run_dialog_XRefLayers_XRLay
     (list (append '("xrefs" "0" "(:SelectXRef $value)") XRlst)
           '("accept" nil "(:DoLayers)")
           '("cancel" nil "(done_dialog 1)")
           '("off" "1")
           '("freeze" "1")
           '("lock" "1")
           '("plot" "1")
           '("color" "1")
           '("linetype" "1")
           '("lineweight" "1")
           '("vpfrz" "0")
           '("vpovr" "0")
     )
     '(:SelectXRef "0")
   )
 )
)

Save this into a LSP file and have it loaded through one of these methods: http://lee-mac.com/autoloading.html

 

Then you should have a new command: XLayerReload. This opens a dialog with all the xrefs in a drop-down at the top-left. When you change the current XRef - all its layers are displayed in the list box below. Select all the layers you want to reload (use Shift or Ctrl click to select more than one). On the right check which properties need to be reloaded. Then click the Apply button, you can apply more than once.

 

Note this command disregards VisRetain (as it should) and any such changes are permanent ... may need to wrap it into an undo group in the future so changes can be undone in one go instead of several.

 

Also the VPFreeze / VP Override hasn't been implemented yet, so currently they do nothing. In the future this would probably apply such reloads to all viewports in the current DWG as well (not just the model space).

Link to comment
Share on other sites

OK, I've made a Lisp for reloading selected layer's selected properties from the xref:

 

Then you should have a new command: XLayerReload. This opens a dialog with all the xrefs in a drop-down at the top-left. When you change the current XRef - all its layers are displayed in the list box below. Select all the layers you want to reload (use Shift or Ctrl click to select more than one). On the right check which properties need to be reloaded. Then click the Apply button, you can apply more than once.

 

Note this command disregards VisRetain (as it should) and any such changes are permanent ... may need to wrap it into an undo group in the future so changes can be undone in one go instead of several.

 

Also the VPFreeze / VP Override hasn't been implemented yet, so currently they do nothing. In the future this would probably apply such reloads to all viewports in the current DWG as well (not just the model space).

 

Thank you for the Lisp; I'll have to spend some time with this.

 

How long did it take you to write something like this?

Link to comment
Share on other sites

Thank you for the Lisp; I'll have to spend some time with this.

 

How long did it take you to write something like this?

Oh, about 4 hours ... lots of copy n paste from other code of mine. Most of the time was taken up with debugging.
Link to comment
Share on other sites

  • 1 year later...

this is just what I was looking for - thanks irneb

only trouble is, I can't make it work!

dialog box opens, I untick everything except 'color', select my xref and layer, hit 'apply' and..... nothing.

box stays open, nothing happens. as if 'apply' button is disconnected!

Link to comment
Share on other sites

after more tries, I've notice that no layers show up if you have the xref open. but still, I have no joy. seems like its dead. is it a version thing?

 

would appreciate knowing if anyone else can make it work. Thanks all.

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...