Jump to content

Copy to Xref - Check if xref is open


broncos15

Recommended Posts

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?

Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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"))

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

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