Title Block iLogic - Use Filename as Drawing Number

Title Block iLogic - Use Filename as Drawing Number

matt.adkins
Contributor Contributor
866 Views
3 Replies
Message 1 of 4

Title Block iLogic - Use Filename as Drawing Number

matt.adkins
Contributor
Contributor

----edit----

Received some assistance elsewhere and the below snippet works for me now. Figured that I'd add it to the thread in case anyone has the same issue in the future.

 

 

'Store the current file's filename
fileName = ThisDoc.FileName(False) 'without extension

drawingNumber = fileName

'Set the custom iProperty to the modified string
iProperties.Value("Custom", "Drawing No") = drawingNumber

 

 

 

Okay, I've been battling this for a while now and I cannot get things to work. 

 

History: Our Part Numbers and Drawing Numbers are not exactly the same. (I.e. part no: 648-1254 & drawing no: 5ASM-648-1254 (much to my chagrin, this cannot be changed)) Because of this, I originally created a prompted entry in the title block where you can enter the drawing number every time you create a new drawing. This worked, however, I would like something that is a little more automated. This led me to the below post which is covering what I would like to do; basically use the filename minus the extension. 

 

https://forums.autodesk.com/t5/inventor-forum/get-text-part-from-the-drawing-file-name-and-without-e... 

 

I created an iLogic rule and used the code called out in the post and changed the custom field to "Drawing No"

 

 

 

iProperties.Value("Custom", "Drawing No") = iFileName
iFileName = ThisDoc.FileName(False) 'without extension

 

 

 

 

This gives me the new field in the custom tab, as I would expect

mattadkins_1-1678800652093.png

I then edit my title block to utilize this field for the "Drawing No." section.

 

mattadkins_0-1678800531094.png

I save the template, close it and then create a new drawing in order to test it. 

 

The problem is when I save a drawing, nothing happens. The "Drawing No" field does not populate with the document filename (minus extension), which means that the title block section doesn't populate either.

 

Is there a step that I am missing? I'm pretty new to iLogic, so I wouldn't be surprised. Does anyone have any ideas?

 

0 Likes
Accepted solutions (1)
867 Views
3 Replies
Replies (3)
Message 2 of 4

A.Acheson
Mentor
Mentor

Should be a simple fix. Your iproperty is being set before you retrieve the filename. Reverse the order. 

 

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

A.Acheson
Mentor
Mentor

Hi @matt.adkins Did you get the two lines to work? I see you edited the original message. It would be best practice to write a new post with updated code and then accept that as the answer. It will help other users learn if they see one message with the problem and one with the solution. 

 

Dim FileName As String = ThisDoc.FileName(False) 'without extension
iProperties.Value("Custom", "Drawing No") = FileName

 or directly without creating an additional string variable. 

 

iProperties.Value("Custom", "Drawing No") = ThisDoc.FileName(False) 'without extension

 

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

matt.adkins
Contributor
Contributor
Accepted solution

This is what I got to work for me after getting some insight from another location.

 

'Store the current file's filename
fileName = ThisDoc.FileName(False) 'without extension

drawingNumber = fileName

'Set the custom iProperty to the modified string
iProperties.Value("Custom", "Drawing No") = drawingNumber