Hello,
I am using Vault Professional 2013 and customzing using C#. I am stuck up with updating issue.
Problem: My current problem is to update only attachment file, not the original file.
Lets consider we have dwg file and its assiciated dwf. I download this dwf make certain changes and upload to vault.
How to update only attachment file.
Regards
Amit
Solved! Go to Solution.
Solved by Redmond.D. Go to Solution.
You check out the attachment, make your updates on disk, and check in the attachment.
Thanks for reply Doug, I actually did this but the associativity between dwg and dwf is lost.
When i click in dwg it won't display this preview. Can you suggest me some methods on how to do this.
Rgds
Amit
What does your check-in code look like? Are you keeping the same classification and hidden values?
This is my code for checkin
I refered from this below link and made some modification to suit my requirement
// Check in the file
public Autodesk.Connectivity.WebServices.File Checkin(Autodesk.Connectivity.WebServices.File file, FileClassification fileClassification, Boolean hidden)
{
Autodesk.Connectivity.WebServices.File retFile = null;
string filePath = Path.Combine(kCheckOutPath, file.Name);
using (FileStream stream = new FileStream(filePath, FileMode.Open,FileAccess.Read))
{
byte[] fileData = new byte[stream.Length];
stream.Read(fileData, 0, fileData.Length);
ByteArray IFileData=new ByteArray();
IFileData.Bytes=new byte[stream.Length];
stream.Read(IFileData.Bytes, 0, IFileData.Bytes.Length);
// Perform the upload
if (fileClassification == FileClassification.DesignVisualization)
{
retFile = mgr.DocumentService.CheckinFile(file.MasterId, "",false, System.IO.File.GetLastWriteTime(filePath),null , null, false,file.Name, file.FileClass, hidden, IFileData);
for (int i = 0; i < fileAssocParamList.Count; i++)
{
FileAssocParam param1 = (FileAssocParam)fileAssocParamList[i];
if (param1.CldFileId == file.Id)
{
param1.CldFileId = retFile.Id;
}
}
System.IO.FileAttributes attr = System.IO.File.GetAttributes(filePath);
//the local file can't be read only.
if ((attr & System.IO.FileAttributes.ReadOnly) == 0)
{
System.IO.File.SetAttributes(filePath, FileAttributes.ReadOnly);
}
}
else
{
// Get bom
Autodesk.Connectivity.WebServices.BOM tbom =mgr.DocumentService.GetBOMByFileId(file.Id);
FileAssocParam[] paramArray = (FileAssocParam[])fileAssocParamList.ToArray(typeof(FileAssocParam));
//retFile = mgr.DocumentService.CheckinFile(file.MasterId, file.Comm,false, System.IO.File.GetLastWriteTime(filePath),paramArray, tbom, true,file.Name, file.FileClass, hidden, IFileData);
retFile = mgr.DocumentService.CheckinFile(file.MasterId, file.Comm, false, System.IO.File.GetLastWriteTime(filePath), paramArray, tbom, true, file.Name, file.FileClass, hidden, IFileData);
if (System.IO.File.Exists(filePath) == true)
{
System.IO.FileAttributes attr =
System.IO.File.GetAttributes(filePath);
//the local file can't be read only.
if ((attr & System.IO.FileAttributes.ReadOnly) == 0)
{
System.IO.File.SetAttributes(filePath, FileAttributes.ReadOnly);
}
}
}
}
return retFile;
}
Thanks and Regards
Amit
That code looks correct to me. The next thing to try is AddDesignVisualizationFileAttachment. Use that function to create a new link from the parent DWG to your new DWF version.
Ok Doug, thanks for information. I will work on it and get back to you.
Rgds
Amit
No Doug, i am not able to use AddDesignVisualizationFileAttachment. I am still under confusion on how to achieve this.
You need to be more specific. Are you getting an error when using AddDesignVisualizationFileAttachment? Are you confused on what to pass in?
Yes Doug, you are absolutely right I am getting confused on what to pass.
I tried to get AddDesignVisualizationFileAttachment in place of FileDesignVisualization, but the object doesn't exists. What exactly should i pass to methods.
Rgds
Amit
You have the DWG file and the DWF file. Now you have to add the link between the two, which is what AddDesignVisualizationFileAttachment does.
The first parameter is the ID of the parent file, which is the DWG. The second parameter is the association to the child DWF file. For the second parameter, create a new FileAssocParam class and fill in all the fields except for RefId and Source. You can leave those null.
CldFileId is the ID of the DWF file. ExpectedVaultPath is the full path to the DWF in Vault. Typ should be Attachment.
Thanks for the reply, i will work on it and later get back to you.
With Warm Regards
Amit
Hi Doug,
The problem still persists.
1) i check out the dwf file.
2)When its copied to local system, i make some changes.
3)I check in the file to vault
4)Then i execute AddDesignVisualizationFileAttachment with all paramaters you specified, yet there is no connection between dwg and dwf. The associativity is lost between two files.
Hi Doug,
Thanks for information, it worked. The information you provided played a crucial role in completion of project.
Thanks for Guidance.
Best Regards
Amit
This works fine if I stick to the naming convention e.i., "part1.ipt" / "part1.ipt.dwf"
But using a custom naming scheme for the designvisualization e.g., "part1_test.ipt.dwf" breaks the link to the preview pane.
Is this the expected behavior or am I missing something?
( Vault Basic 2013 )
Hi noontz,
I never tested with different naming conventions, till today i tested with the same naming conventions as customer requirement and the behaviour is not known to me.
I will test the same this weekend and reply the same to you.
Best Regards
Amit
Hi Amit
Thanks for your reply & interest. Did you hit the same limitations? My assumption is, that the preview pane is restricted to the specific namingconvention.
Hi noontz,
I tested the same and its working fine. As far as the you explicitly attach the dwf/dwfx file to dwg/ipt, it works fine.
Just make sure the extensions are right and you are attaching the dwf to ipt/dwg properly. Even a minor bug does not attach the dwf to dwg/ipt.
With Best Regards
Amit
Hi Amit.
Big thanks for your efforts!
I´m using AddDesignVisualizationFileAttachment as suggested by Doug after both files are checked-in. Everything looks right & no "bugs" as far as I can see. It´s just the preview pane I can´t seem to "syncronize", when I´m using a custom naming scheme?. Guess I´ll need some more try & error to get it right
Can't find what you're looking for? Ask the community or share your knowledge.