Resolve File in Drawing using Ilogic

C_Haines_ENG
Collaborator

Resolve File in Drawing using Ilogic

C_Haines_ENG
Collaborator
Collaborator

Id like to be able to resolve files in a drawing file. I manually rename them in the file explorer and would like to resolve the file when I run a command. 

0 Likes
Reply
762 Views
13 Replies
Replies (13)

A.Acheson
Mentor
Mentor

Hi @C_Haines_ENG 

That wouldn't be a very easy task to automate. Knowing what you named your file too is the most difficult portion. Unless it was a pretty predictable index number that could be easily appended to a filename. Being inside the file and then performing renames is an easier method as your capturing information as you go and potentially reusing. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

C_Haines_ENG
Collaborator
Collaborator

Essentially the file name is the same 6 digit code as the part file linked in the drawing.

 

As well, in terms of renaming, it would first rename everything to 000001, 000002, 000003. I would pick a number to start and then It would just go through all the parts and drawings and rename them say at 500111, 500112, 500113.

0 Likes

Cadkunde.nl
Collaborator
Collaborator

If you don't have Vault Basic for that task.

Next best thing is i think: Design Assistant (Start --> Autodesk Inventor --> Design Assistant)

Or you can try: iLogic design copy (only visible if you have no documents open in inventor)

 

https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Copying-an-Invento...

 

Writing custom code would require many attempts and time before it is what you want.

0 Likes

C_Haines_ENG
Collaborator
Collaborator

We do have Vault, but I am unaware of how I could Mass rename all the parts.

 

All I really need from someoneone is the ilogic code to resolve a file. I can figure out how to rename and get file names, I just need the actual resolve file code.

0 Likes

raith-mb
Advocate
Advocate

If I understand you right:

You rename the IPTs and also the corresponding IDWs

When you are donne and open any IDW, the "unresolved file" Message appears. Since the old IPT does not exist any more.

 

In this case you need to replace the old IPT FullFileName by the one from the renamed:

Set oDrawDoc = ThisApplication.ActiveDocument
    If oDrawDoc.DocumentType <> kDrawingDocumentObject Then
       MsgBox "no IDW available"
       Exit Sub  
    End If
    
    Dim oFile As File
    Set oFile = oDrawDoc.File   
    Dim oFD As FileDescriptor
    Set oFD = oFile.ReferencedFileDescriptors.Item(1)
    Call oFD.ReplaceReference("C:\Temp\Part01new.ipt")

 

WCrihfield
Mentor
Mentor

In order to effectively use the FileDescriptor.ReplaceReference() method, you would need to have a list of old & new FullFileName Strings in pairs, like in a NameValueMap or a Dictionary(Of String, String) that was created when you renamed the files.  It would need to record each file's original FullFileName, then record its new FullFileName, and store those entry pairs.  Then you could use that collection of name pairs to replace the file references in the drawing by looping through all FileDescriptors In DrawingDocument.File.ReferencedFileDescriptors, and check if the FileDescriptor's FullFileName matches one of the 'old' names, than if so, use FileDescriptor.ReplaceReference and supply the 'new' name from that pair of names.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

C_Haines_ENG
Collaborator
Collaborator

Here is my rough plan of it. The drawing and part file have the same name which simplifies things.

 

1. Look for Lowest 6 Digit number in Folder (Store This)

2. Rename the two files that share that number to 000001, Then look for the next number above the originally stored number, rename 00002, continue until all are renamed.

3. Ask user for new start of number range.

4. Step 2, however Renaming all part numbers with the newly entered starting number, add 1, rename next, add 1.

5. Open all the drawing files, cycle through using the Resolve file command using the name of the drawing file, so if a drawing was renamed to 660044.dwg, it will replace the file with 660044.ipt.

 

Simple enough for sure. The only files contained within the folder will be the ones we want renamed anyway.

Cadkunde.nl
Collaborator
Collaborator

If you have Vault, please use vault for renaming.

If all files are in a certain folder and its subfolder.

 

Go to the highest folder and make a search like *0001*

 

Select all files and rename.

 

In the 2nd window of the rename wizard.

Right click in the New Name column.

Select: Replace...

 

Now you can replace 00000 with 50011. and it will replace it for all files.

 

This is also possible with copy design and the new name column.

 

0 Likes

Cadkunde.nl
Collaborator
Collaborator

I checked in vault, but you can also go to the drawing.

Select the "Uses" tab

 

Select all children and right click Rename.

Use the replace i mentioned, and you are done

 

0 Likes

C_Haines_ENG
Collaborator
Collaborator

Would I not have to do that for every single drawing?

0 Likes

Cadkunde.nl
Collaborator
Collaborator

If you do the search i mentioned earlier.

 

Or you make a search with multiple criteria eg only idws. With 00000 in filename. Or author = .....

 

You can find all the files.

 

Then select all. Rename.

New name column --> replace...

 

That should work easy

0 Likes

C_Haines_ENG
Collaborator
Collaborator

When I run this in my drawing file, it replaces the inserted view with the thing I just want to resolve it with. How can i Fix this?

0 Likes

WCrihfield
Mentor
Mentor

Hi @C_Haines_ENG.  Judging by the process you described to me before, I would think that an iLogic rule similar to this one would work for the task of processing every drawing file in a specified folder, to replace their model file references with the model file of the same file name in that same folder.  I don't know if you wanted it to be its own separate process like this or not, but this is something similar to some of my previous solutions, that you can try out.  The code for the iLogic rule is attached as a text file.

Edit:  I replaced the contents of the attached file, after posting, because I saw a flaw in the original, due to not originally testing it.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes