Delete unresolved files

GeorgK
Advisor
Advisor

Delete unresolved files

GeorgK
Advisor
Advisor

Hello together,

 

I have a phantom "unresolved reference" in an assembly. I could not see it in the assembly. When I open the assembly I get an error message that a file is missing. In the assembly I could find it with this code:

 

https://forums.autodesk.com/autodesk/attachments/autodesk/78/546430/1/UnresolvedFiles.txt

 

Is it possible to delete it with a peace of code?

 

Thank you very much

 

Georg

Reply
Accepted solutions (1)
8,372 Views
9 Replies
Replies (9)

Balaji_Ram
Alumni
Alumni

Hi Georg,

 

Sorry, the FileDescriptor does not permit removing the file reference.

 

But, you can replace the reference if you do have an backup or a old file that shares its heritage.

 

http://adndevblog.typepad.com/manufacturing/2012/08/replace-the-file-reference-by-inventor-api.html

 

Does the file descriptor "FullFileName" return a file path that you recognise ?

That should return the last known path for a file reference that is missing.

 

Regards,

Balaji

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes

GeorgK
Advisor
Advisor

Hello Balaji,

 

I found the old post and did replaced the file now. It would be gread to delete files.

 

Thanks

 

Georg

 

 

0 Likes

Balaji_Ram
Alumni
Alumni

Hi Georg,

 

Glad that you replaced the file reference.

 

I think, providing the delete on the File reference can cause more issues that it solves.

File references are best managed internally by Inventor since it would be quite easy to get things wrong with file references.

 

Also, I think it is for this reason that Inventor API does not let us delete it manually.

 

Regards,

Balaji

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes

rossano_praderi
Collaborator
Collaborator
Accepted solution

Hi Georg,

if I've understood your question...this is my answer...

 

I don't think you need more explanations about the follow code, if you need I'm there

 😉

 

Public Sub DelOccurrence()
    Dim oAsmCompDef As AssemblyComponentDefinition
    Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
    Dim ref As ComponentOccurrence
For Each ref In oAsmCompDef.Occurrences
    If ref.ReferencedDocumentDescriptor.ReferenceMissing = True Then
        ref.Delete
    End If
Next
End Sub

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------

GeorgK
Advisor
Advisor

Hello Rossano,

 

thank you very much. Thats exactly what I am looking for 🙂

 

Georg

0 Likes

Balaji_Ram
Alumni
Alumni

Sorry if my reply was misleading.

 

I had interpreted your query as that of directly deleting the file references.

 

Regards,

Balaji

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes

maximeURGVK
Enthusiast
Enthusiast

Hi,

i got this error messageDELETE LOST REF.PNG

0 Likes

rossano_praderi
Collaborator
Collaborator

If you doesn't use anything else than this subroutine ("DelOccurence") the simple solution is to replace "Public Sub DelOccurence" with "sub Main" and remove the "Set" statement.

 

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes

Anonymous
Not applicable

Hi, hope this answer works besides the long time you've been posted.

 

You are working in the wrong environment. This code it's supposed to work very fine in VBA, not in iLogic.

iLogic runs pretty similar VBA but with limitations.

Give the chance to work combining both solutions and you will see how easy those codes works for your intentions.

 

Cheers.

0 Likes