geocad Posted January 11, 2012 Share Posted January 11, 2012 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 Quote Link to comment Share on other sites More sharing options...
RobDraw Posted January 12, 2012 Share Posted January 12, 2012 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. Quote Link to comment Share on other sites More sharing options...
geocad Posted January 12, 2012 Author Share Posted January 12, 2012 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. Quote Link to comment Share on other sites More sharing options...
irneb Posted January 13, 2012 Share Posted January 13, 2012 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). Quote Link to comment Share on other sites More sharing options...
geocad Posted January 13, 2012 Author Share Posted January 13, 2012 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 Quote Link to comment Share on other sites More sharing options...
irneb Posted January 16, 2012 Share Posted January 16, 2012 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. Quote Link to comment Share on other sites More sharing options...
Tiger Posted January 16, 2012 Share Posted January 16, 2012 (edited) 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 January 17, 2012 by Tiger added update Quote Link to comment Share on other sites More sharing options...
Dipali Posted January 16, 2012 Share Posted January 16, 2012 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 Quote Link to comment Share on other sites More sharing options...
geocad Posted January 16, 2012 Author Share Posted January 16, 2012 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 Quote Link to comment Share on other sites More sharing options...
geocad Posted January 16, 2012 Author Share Posted January 16, 2012 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 Quote Link to comment Share on other sites More sharing options...
irneb Posted January 17, 2012 Share Posted January 17, 2012 As research you could look at some other threads, like those listed at the bottom of this one, or some others I've been involved with: http://forums.augi.com/showthread.php?t=96718 http://forums.augi.com/showthread.php?t=81272 I'll have a check about applying such through Lisp and come back. Quote Link to comment Share on other sites More sharing options...
Tiger Posted January 17, 2012 Share Posted January 17, 2012 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. Quote Link to comment Share on other sites More sharing options...
geocad Posted January 17, 2012 Author Share Posted January 17, 2012 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. Quote Link to comment Share on other sites More sharing options...
geocad Posted January 17, 2012 Author Share Posted January 17, 2012 As research you could look at some other threads, like those listed at the bottom of this one, or some others I've been involved with: http://forums.augi.com/showthread.php?t=96718 http://forums.augi.com/showthread.php?t=81272 I'll have a check about applying such through Lisp and come back. Thanks for the links. Quote Link to comment Share on other sites More sharing options...
irneb Posted January 19, 2012 Share Posted January 19, 2012 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). Quote Link to comment Share on other sites More sharing options...
geocad Posted January 19, 2012 Author Share Posted January 19, 2012 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? Quote Link to comment Share on other sites More sharing options...
irneb Posted January 20, 2012 Share Posted January 20, 2012 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. Quote Link to comment Share on other sites More sharing options...
designerstuart Posted April 8, 2013 Share Posted April 8, 2013 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! Quote Link to comment Share on other sites More sharing options...
designerstuart Posted April 9, 2013 Share Posted April 9, 2013 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. Quote Link to comment Share on other sites More sharing options...
designerstuart Posted April 9, 2013 Share Posted April 9, 2013 okay got it. need to reload the xrefs manually after using. excellent code, thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.