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

Deleting ipt file in iam

hayattangercekler2
Advocate

Deleting ipt file in iam

hayattangercekler2
Advocate
Advocate

I want to capture and delete the desired ipt file in an iam file in Inventor. How can I do that ?

0 Likes
Reply
Accepted solutions (2)
433 Views
5 Replies
Replies (5)

CattabianiI
Collaborator
Collaborator

I think you want to delete an occurrence, right?
You can iterate over AssemblyComponentDefinition.Occurrences to find the occurrence you want to delete and then call ComponentOccurrence.Delete method.
Check this post for some code: https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/delete-occurrence-in-assembly/m-p/11...

 

0 Likes

hayattangercekler2
Advocate
Advocate

hayattangercekler2_0-1669113892520.png

I tried to capture and delete my file using the code in your answer, but it didn't work. Am I using it correctly?

hayattangercekler2_1-1669114263230.png

 

0 Likes

CattabianiI
Collaborator
Collaborator
Accepted solution

Before writing code understand what you want achieve and the concept involved. I recommend to name variable properly: `file` is a ComponentOccurrence which is not a file!

Now about your error, check ComponentOccurrences.ItemByName manual, the input param should be the name of an existing occurrence, are you sure filename.ipt is a name of an occurrence? It's possible but sounds weird to me.


0 Likes

hayattangercekler2
Advocate
Advocate

var iptFile : assemblyComponentDefinition.Occurrences.ItemByName[$"{iptFileName}:1"];

When I fixed it this way I was able to capture and delete my ipt file. I got a parameter error warning because Inventor adds ":n" to the end of the ipt file in order of addition. Now my problem is solved. Thanks. 😄

0 Likes

JelteDeJong
Mentor
Mentor
Accepted solution

Just another approach:

var occ = assemblyComponentDefinition.Occurrences.
    Cast<ComponentOccurrence>().
    FirstOrDefault(c => c.ReferencedFileDescriptor.FullFileName.Contains(iptFileName));

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes