Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: op_thorsager

Wow.  That is a rather long, and complex code for someone who is just getting started with iLogic, so I am impressed that it is working this well for you so far.  After seeing the whole (or most of) the code you are working with, I can see how attempting to implement our suggestions into it can seem more complicated than I had in mind.  Now I am thinking that I would suggest making a few different changes in a few different places.  I can see now that you do not yet have a 'list' of old & new full file names, as we were suggesting, so I am thinking about ways to create one within your existing code to help with replacing the drawing file references.

 

Between your Sub named "CopyDrawing" and the next Sub named "Export", you are declaring several variables.  Those variables will be 'shared' because they are being declared between any other routines, and not within any other routine.  When done that way, all other routines will recognize them, and be able to use them.

 

In that same area, I'm thinking we could create something like a NameValueMap or a Dictionary(Of String, String) type variable.  Those types of variables can store a list of entries, but unlike a normal/simple list or array, the entries in these each have two parts.  In a NameValueMap, you an unlimited number of entries, each pair having a 'Name' and a 'Value'.  Similarly in a Dictionary(Of String, String), you have an unlimited number of entries, each having a 'Key', and a 'Value'.  Using one of these, we could record the 'old' full file name as the 'Name' or 'Key', then the 'new' full file name as the 'Value' in each entry, at some point earlier in your code, like in your Sub named "CopyParts".  Then down within your Sub named "CopyDrawing", we could use that collection variable when we loop through each file reference of the drawing.  Instead of just getting 'Item(1)' of the drawing's ReferencedFileDescriptors, we would loop through each FileDescriptor In FileDescriptorsEnumerator (what you get from File.ReferencedFileDescriptors).  Then within that loop (For Each Object In Collection...do something...Next), we would check if the FileDescriptor's FullFileName matches any of the 'old' ones in our list, and if to, use its ReplaceReference method to replace the 'old' one with the 'new' one.  Does that make sense to you?  I know, it is a lot to take in, because this is a big, complex task you are taking on.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)