- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My goal is to replace the reference of an Assembly without marking it as Dirty.I tried to use ReplaceReference alone but this modified my assembly. I just found out when the replace reference has been executed, it will trigger the OnFileResolution, from that, I tried to handle the callback to start using ChildFileDesc2 but still the assembly has been modified.
The only posible way I can see to achieve that is, Close the Assembly and open it again, from that, the onFileResolution will be fired again and if I try to handle that and start using the ChildFileDesc2 instead of original reference(ChildFileDesc1), the assembly is not modified, but I can't use that on my current operation. If you have any trick to do that, please share it to my. Thank you.
Sample Code Below:
ChildFileDesc1 = "C:\workspace\Part1.ipt"
ChildFileDesc2 = "C:\workspace2\Part1.ipt" // This is a copy of ChildFileDesc1 but located on different folder
foreach (Inventor.FileDescriptor ChildFileDesc1 in This.Assembly.File.ReferencedFileDescriptors)
{
if (ChildFileDesc1.FullFileName.Equals(ChildFileDesc2 .FullName) == false)
continue;
ChildFileDesc.ReplaceReference(ChildFileDesc2 .FullName);//This mark the assembly as dirty, also this will trigger the OnFileResolution callback.
}
//This will not modify the assembly
Callback:
void OnFileResolution(string RelativeFileName, string LibraryName, ref byte[]
CustomLogicalName, EventTimingEnum BeforeOrAfter, NameValueMap Context, out string FullFileName, out HandlingCodeEnum HandlingCode)
{
FullFileName = ChildFileDesc2 ;
HandlingCode = HandlingCodeEnum.kEventHandled;
}
Solved! Go to Solution.