Set part number through saving with ilogic rule

Set part number through saving with ilogic rule

hf.stork_1991
Participant Participant
283 Views
1 Reply
Message 1 of 2

Set part number through saving with ilogic rule

hf.stork_1991
Participant
Participant

Hello all,

 

Lets get right to the problem. In inventor we use a lot of structural shapes from the content center. Our problem is that the part number and file name are not the same when generating a new structural member. This leads to problems in our Bill of Materials. For instance: we never use the length in the file name because this can change a lot of times before production starts.

 

For this I tried to use a simple rule that runs everytime the document is saved. 

iProperties.Value("Project", "Part Number") = ThisDoc.FileName

 

But when saving a large assembly that has a lot of updated parts and assemblies that are not checked out from the vault we get a lot of errors because these have the "read only" status. Now I wanted to try some options I found on the forum where the status of the file is used to check if a part/assembly is checked out. That way I would only run when making a new part or if it is checked out from the vault.

 

Dim d As Inventor.Document = ThisDoc.Document
Dim fio As New System.IO.FileInfo(d.FullDocumentName)

If fio.IsReadOnly = False Then
iProperties.Value("Project", "Part Number") = ThisDoc.FileName

Else
'YOUR CODE IF THE FILE IS CHECKED NOT OUT
End If

 

This is to where I got. But it still throws some errors trying to save parts/assemblies which have not been checked out. Any help would be great.

0 Likes
284 Views
1 Reply
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor

You can just test if the part number is the same as file name. In this case you can quit rule

 

Dim fileName As String = ThisDoc.FileName(False)
If iProperties.Value("Project", "Part Number") = fileName Then Return
iProperties.Value("Project", "Part Number") = fileName

 

0 Likes