Hi,
Is there any way of the deleting the automattically saved full path for reference files. One command that I use is "AttachedFile.SetAttachNameDeferred NewFileName". If the NewFileName is not available, Mstn looks back at the last known full path, finds the old file (with a different name) and displays it. I would like it to show as missing if it can't find the new file.
--Thanks, --Robert
Dear Robert,
I have done a similar job on basis of "clean the server" - 120000K file later... yusing Microstation XM
I used
Call oAttachment.SetAttachNameDeferred(sAttachmentPath) Call oAttachment.Rewrite Call oAttachment.Reattach(vbNullString, vbNullString)
where by sAttachmentPath is the new path an file name that may or may not exist - I converted a lot of absolute paths to relative paths and added some confguration variables to the paths too. I am no sure why I added the reatach I think this was to update the drawing to reflect the what the user will see when the drawing is opened first time. I susspect you are missing the rewrite which is needed to commit the change to the drawing.
One word of warning I have many issues processing large numbers of files more than 500 in one microstation session will probably cause microstation to crash - I used 1 microstation session per project but I had 10000k projects.
Best Regards,
Ian Emery
Hi Ian,
I tried your trick. I was already using SetAttachedNameDeferred & Rewrite, but not the Reattach. No luck. Here's what's happening. I am changing the extensions of the attachments from dwg to dgn. If I don't convert a file (xxx.dwg) to dgn, the reference dialog box shows me the filename "xxx.dgn" (which is non-existant) and when I hover my mouse over the filename to show the full path, I get "xxx.dwg"!
Any other tricks out there?
RobertArnold: ...the reference dialog box shows me the filename "xxx.dgn" (which is non-existant) and when I hover my mouse over the filename to show the full path, I get "xxx.dwg"!
...the reference dialog box shows me the filename "xxx.dgn" (which is non-existant) and when I hover my mouse over the filename to show the full path, I get "xxx.dwg"!
That is a subtle but possibly important detail. What type of file are you working on and what are the reference file types?
HI Phil,
Here's the routine... Starting with an open DWG file, I save it as dgn (v8), then I change the .dwg attachments to .dgn (deferred attachment due to the fact that I may or may not have already processed that file.) Essentially this becomes a batch convert routine, which is part of larger routine that processes the elements of the new file...
Also, I have MS_DISALLOWFULLREFPATH set to (undefined), so the full path is being stored in the file by default. Unfortunately, we commonly reference files on a different drive letter, so if you set this variable you loose those files every time you exit the drawing. I really wish that the "save relative path" option would save the full path when a relative path is not available, that way i could specify on a case-by-case basis when to save the full path, but that's a different story.
---------------------------------------------
Private Function SaveAsDGN() As Boolean Dim NewFileName As String Dim SuggestedName As String Dim UnUsed1 As Long Dim UnUsed2 As Long Dim AttachedFile As Attachment Dim Cancelled As Long SaveAsDGN = False NewFileName = Left(ActiveDesignFile.FullName, Len(ActiveDesignFile.FullName) - 4) & ".dgn" Set OS = CreateObject("Scripting.FileSystemObject") If OS.fileexists(NewFileName) Then SuggestedName = NewFileName NewFileName = Space(255) Cancelled = mdlDialog_fileCreate(NewFileName, UnUsed1, UnUsed2, SuggestedName, "*.dgn", ActiveDesignFile.Path, "Save As DGN") If Cancelled <> 0 Then Exit Function End If ActiveDesignFile.SaveAs NewFileName, True, msdDesignFileFormatV8 'Change attachments to DGNs CadInputQueue.SendCommand "MODEL ACTIVE model" 'AutoCad default CadInputQueue.SendCommand "MODEL ACTIVE default" 'Microstation default On Error Resume Next For Each AttachedFile In ActiveModelReference.Attachments NewFileName = AttachedFile.DesignFile.Name NewFileName = Left(NewFileName, Len(NewFileName) - 4) & ".dgn" AttachedFile.SetAttachNameDeferred NewFileName AttachedFile.Rewrite Next On Error GoTo 0 SaveAsDGN = True End Function
This looks similar to my project and the code seams simple. I think the issue is with the relative path setting.
We moved all our absolute paths to relative paths system wide and shifted a lot of reference files to try and get all the files for one project in one simple tree/folder structure and move away from the spaghetti feeling (don't ask).
After the conversion some of our users had the same issue you report when they tried to reattach references I could not fix. We saw he same action you saw with the attached name not being the same path as that shown in the tooltip under the mouse. The cause was the use relative path check box at the button of the select reference dialog not being set to on when using relative paths - If I remember correctly. I fixed this by changing the setting MS_ALWAYSRELATIVEREFPATH or MS_REFDEFAULTSETTINGS. We are using system wide settings
MS_DISALLOWFULLREFPATH = 1
MS_REFDEFAULTSETTINGS = SAVERELATIVEPATH=1 ...+ other settings
MS_ALWAYSRELATIVEREFPATH = 1
I think I used MS_REFDEFAULTSETTINGS = SAVERELATIVEPATH=1
To switch on the check box in question and the one of the other two to disable the check box so it could not be changed.
you change change these settings for one session using a macro like
Public Sub UseRelativePaths() Call ActiveWorkspace.AddConfigurationVariable("MS_ALWAYSRELATIVEREFPATH", "1", False) Call ActiveWorkspace.AddConfigurationVariable("MS_DISALLOWFULLREFPATH", "1", False)
'more coding is needed to edit the settings string MS_REFDEFAULTSETTINGS or
'simple hard code the company setting + relative path default...
End Sub
The false parameter means the changes to the variable are not saved outside of this session. I
would try setting these settings to force relative paths just before calling your conversion function.
I set the configuration variables MS_ALWAYSRELATIVEREFPATH and MS_DISALLOWFULLREFPATH as described before. But when I try to attach the file from my code with key-in REFERENCE ATTACH [filepath\filename.dgn] the logical name of the attachement contains only the filename (without relative path). When I save the master file close it and reopen it MicroStation can't find the attached file.
When I attach the file from References dialog, the logical name of attachment has also the relative path and after reopening the master file MicroStation knows where to find the reference.
What am I doing wrong?
You have posted a question about MicroStation reference attachments to an old VBA posting. Your question is not about VBA and does not appear to be about the thread topic "Delete full path on reference files".
You would do better (i.e. receive more responses) if you were to post your question to the general MicroStation V8i Forum.
Regards, Jon Summers LA Solutions
Thanks for that advice.