- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a part number called abc-123. The relevant files include an idw and 3-4 ipt files one for each operation the part goes through in the manufacturing process. The file names are as follows:
Drawing filename "abc-123.idw"
Model Files Include:
Finished Part name "abc-123.ipt"
op-10 part name "abc-123_op10.ipt"
op-20 part name "abc-123_op20.ipt"
op-30 part name "abc-123_op30.ipt"
op-40 part name "abc-123_op40.ipt"
Here is my code:
Dim app As Application: Set app = ThisApplication
Dim doc As Document: Set doc = app.ActiveDocument
Dim fso As New Scripting.FileSystemObject
Dim ffName: Set ffName = doc.fullFileName 'Gets path with filename and extension
Dim ext: Set ext = fso.GetExtensionName(ffName) 'Gets just the extension
Dim fName: Set fName = fso.GetFileName(ffName) 'Gets just the filename with extension
Dim pNo: Set pNo = Left(fName, Len(fName) - Len(ext) - 1)
If TypeOf doc Is DrawingDocument Then
Dim imFile As Document 'inventor model file Set imFile = doc.ReferencedDocuments(1) 'The (1) represents the Item1 found in the Locals path tree Set designInfo = imFile.PropertySets.Item("Design Tracking Properties") Dim rdpNo As Property Set rdpNo = designInfo.Item("Part Number") 'Referenced Document Part Number
The problem I'm running into is that all the idw files don't always have the Finished part name as Item1:
Set imFile = doc.ReferencedDocuments(1)
there are actually 5 items. Sometimes it will be Item2, Item3, Item4 or Item5. I have to use the PropertySets from the Finished PartName as this is where we store all our iProperties Data.
So my Plan was to do an If statement that compares "pNo" to rdpNo" if they match then use that item PropertySet.
Just looking for some guidance on if this is the correct way to achieve this or do I need to code it differently.
Solved! Go to Solution.