Jump to content

Removing external references with VBA


Squiggs

Recommended Posts

Hello All,

 

My CADD department has tens of thousands of files that all seem to have an unused external reference to a file that no longer exists. I am trying to automate a way to go through all these files and remove the external refrences programatically. I have found several posts of people iterating through the ThisDrawing.Blocks and looking for Blocks that are XRefs, however none of these blocks are flagged as XRefs. Is there another way to delete these references?

 

Thanks for your help.

Link to comment
Share on other sites

if its the same name for every dwg, I would use a script, which is very easy to write.

 

open dwgname xref d "xrefname" " " qsave close

repeat above with new dwg number

Link to comment
Share on other sites

Blocks and looking for Blocks that are XRefs, however none of these blocks are flagged as XRefs. Is there another way to delete these references?

 

Yes. XRefs have Path property (path to XRef file) but ordinary blocks havn't.

Link to comment
Share on other sites

The name is indeed very similar between the files, the all have the same external reference, but a handful have a few more.

 

What language is the script posted by CmdrDuh? This doesn't look like VB, how can I implement that?

 

Or by ASMI's suggestion, do I iterate through the ThisDrawing.Blocks collection and just look for a Path that is not 'Nothing' even if the IsXRef property is false and remove it? Or am I looking at the wrong collection altogether?

Link to comment
Share on other sites

A script file is just text, not a particular language. What you want can be done in any language, VBA, LISP, or just a script. A script is the "typed" version of your commands, so if you were to do this from the Keyboard, and write down all the steps, including "Returns/Enter" to accept the defaults, that would be a script that the computer would follow. An example, how to draw a line by script:

line 0,0 1,1 0,2 qsave

line command followed by space (which if you did from the keyboard would issue the line command, typed coordinates 0,0 to be first point, 1,1 to be second point. Notice the space between 0,0 and 1,1, another "enter" as if i had typed it at the keyboard. On to 0,2, and then 2 spaces, 1 to process the 0,2 and the second to give the line command a blank "Enter" to stop the command. Then a qsave to save the dwg.

 

Does this make sense?

Link to comment
Share on other sites

copy and paste this into notepad and save as c:\test.scr (or whatever you want) , open a blank dwg, save it as something, and then drag and drop the file

line 0,0 2,2 0,5 qsave

zoom e zoom 0.5x qsave

Link to comment
Share on other sites

how do I execute these scripts? Its not a .bat or .vbs file then? Whats the launcher app?

you can also type scr at command prompt and browse to find the scr file

Link to comment
Share on other sites

Thanks for the help with this. The scripting is working pretty good, but revealed a new issue. The files that are listed in the External References window are not showing up as XRefs in the command window. If we type "-xref ?" in the command window, it says there are no XRefs. However the file clearly shows up in the External References window with a red exclamation mark.

 

Any idea how to remove these items?

Link to comment
Share on other sites

I tried to detach an xref that was unresolved( had a red exclamation mark) and it detached. In my script, I put the name i wanted to detach and it took it.

Link to comment
Share on other sites

Thanks a lot for your help on this, someone else had just mentioned to me that images and external references are in the same window now in 2009, which is why I thought it was an external reference. Your solution is working great.

 

I am in your debt.

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