broncos15 Posted May 16, 2016 Share Posted May 16, 2016 I had a quick question on an edit I was going to make to Lee Mac's copy to xref routine found at http://lee-mac.com/copytoxref.html. I am trying to add in the ability to check if the xref is open and if so, not allow the user to copy to it and alert them (because it doesn't actually copy to it). The only way I can think of doing this is making use of the open function and then checking to see if it is read only or not. My issue is that it seems like this would really slow down the routine. Can anyone think of a faster way to accomplish what I am trying to do? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 16, 2016 Share Posted May 16, 2016 Attempt to locate a .dwl file with the same filename as the xref source drawing and which cannot be deleted. Quote Link to comment Share on other sites More sharing options...
broncos15 Posted May 16, 2016 Author Share Posted May 16, 2016 Attempt to locate a .dwl file with the same filename as the xref source drawing and which cannot be deleted.Lee, thanks for the advice, I looked up .dwl files and I didn't even know that they existed. I am trying to figure out where they are stored though. I have a drawing opened currently, but I can't find anywhere in the project directory a .dwl file with the current file name. Am I going about this incorrectly? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 16, 2016 Share Posted May 16, 2016 Lee, thanks for the advice, I looked up .dwl files and I didn't even know that they existed. I am trying to figure out where they are stored though. I have a drawing opened currently, but I can't find anywhere in the project directory a .dwl file with the current file name. Am I going about this incorrectly? The .dwl will be a hidden file, but still discoverable using findfile - for example: (findfile (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".dwl")) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 16, 2016 Share Posted May 16, 2016 Consider the following function: (defun LM:dwgopen-p ( dwg / dwl ) (and (setq dwg (findfile dwg)) (setq dwl (findfile (apply 'strcat (reverse (cons ".dwl" (cdr (reverse (fnsplitl dwg)))))))) (not (vl-file-delete dwl)) ) ) You may also refer to lines 918-982 of my Batch Attribute Editor application for another example of this technique. Quote Link to comment Share on other sites More sharing options...
broncos15 Posted May 16, 2016 Author Share Posted May 16, 2016 Thanks Lee, I looked into it and you are correct like usual haha, it was just a hidden file on my computer. Thank you so much for the help and I will be messing around with this some more, it is definitely some good practice! Quote Link to comment Share on other sites More sharing options...
broncos15 Posted May 16, 2016 Author Share Posted May 16, 2016 Lee, I apologize for my ignorance on this, but I can't get the code to work correctly. For the conditional statement I entered in ((and (setq dwl (findfile (apply 'strcat (reverse (cons ".dwl" (cdr (reverse (fnsplitl dwg))))))) ) (not (vl-file-delete dwl)) ) (prompt "\nXref is currently open and therefore cannot be saved to.") ) I didn't enter in the dwg findfile because this was already checked earlier in the conditional statement and I put the above code right before the code that actually does stuff (ie it copies the items to the dwg). Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 16, 2016 Share Posted May 16, 2016 I would suggest inserting the following between lines 123 & 124: ( (LM:dwgopen-p dwg) (prompt "\nThe xref is currently open and is therefore read-only.") ) And of course copying the above function definition to the end of the code. Quote Link to comment Share on other sites More sharing options...
broncos15 Posted May 16, 2016 Author Share Posted May 16, 2016 Lee, thank you so much for the help, it worked perfectly. For my own understanding, why did the location of the code in the conditional statement matter? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2016 Share Posted May 17, 2016 Lee, thank you so much for the help, it worked perfectly. Excellent, you're welcome. For my own understanding, why did the location of the code in the conditional statement matter? Because the condition which follows is opening the target drawing through ObjectDBX. Quote Link to comment Share on other sites More sharing options...
broncos15 Posted May 17, 2016 Author Share Posted May 17, 2016 That makes sense, thank you again for the help! 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.