[VBA] Change an External Reference to a Self Reference

I have a situation where I am importing a model in code and it works exactly as I want. Except that the model being imported, is referencing a different model in the same file as the model.

The file I am importing it into, has an identically named model in it that I really want the imported model to reference, but what actually happens is that the model continues to reference the now external model.

One reason that it still finds the external file is this all has to function in a ProjectWise environment. So the original attachment looks like this: PW_WORKDIR:d0243249\SHA_border.dgn

According to VBA, my file name is a simple local path - in effect, the variable PW_WORKDIR has been expanded to a local path and then there is a subfolder equal to the "d" & the DMS number - in this case, d0257865. So it is not a simple task to rewrite the reference file, as I need the attachment to read like this PW_WORKDIR:d0257865\ followed by the active file name.

I know I can deconstruct and reconstruct this in code, but I discovered something that is so much simple, except it does not work in code.

I discovered that if I open the Reference Attachment dialog box and simply replace the current reference file path with a period and press return, MicroStation apparently checks the active file to see if the attached mode name matches as model name in the file and it it does, it rewrites the attachment as a self attachment, using the PW_WORKDIR:d0257865\ syntax.

This is a process that needs to go out agency wide for all active projects. So while I can provide the model import code, I wonder if the simplicity of typing a period in the file name field  is the best solution or if there is some other way in code to tell MicroStation to check the file as a self attachment - in effect, some type of code that is a elegant and simple as the typing that period?

If there isn't, there should be.

Parents Reply Children