Need help with this code to get the First 3 Letter of FIlename

Need help with this code to get the First 3 Letter of FIlename

Anonymous
Not applicable
391 Views
1 Reply
Message 1 of 2

Need help with this code to get the First 3 Letter of FIlename

Anonymous
Not applicable

Hi,

 

I have a illogic that runs in assembly and what I want to do is this:

 

if my filename = L19, OR S64 basically our naming convention starts with Letter then number I want that part to become Normal in BOM

but if the filename = 100 then I want that to become Purchase in BOM

 

I might sound simple for the experts out there but I'm just lost.

 

Thanks,
Joel

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 8677 StartFragment: 314 EndFragment: 8645 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

Dim docFile As Document

For Each docFile In oDoc.AllReferencedDocuments

    ThisApplication.Documents.Open(docFile.FullFileName, False)
    
'Library Parts exemption'format model file name                  
Dim LP As String LP = Left(docFile.FullFileName,3) If LP < 100 Then docFile.ComponentDefinition.BOMStructure = 51970 'BOMStructureEnum.kPurchasedBOMStructure docFile.Update docFile.Close Else If LP > 100 Then docFile.ComponentDefinition.BOMStructure = 51973 'BOMStructureEnum.kNormalBOMStructure docFile.Update docFile.Close 'run rule in the drawing document auto = iLogicVb.Automation auto.RunExternalRule(docFile,"AutoFill") End If
Accepted solutions (1)
392 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

yey I got it figured out!! answered my oiwn questions but I hope this helps someone else too:

 

Here's the fix code:

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 10794 StartFragment: 314 EndFragment: 10762 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

Dim docFile As Document

For Each docFile In oDoc.AllReferencedDocuments

    ThisApplication.Documents.Open(docFile.FullFileName, False)
    
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)

'takes the First 3 Letter of the active filename
Dim Fname As String
Fname = Left(docFName,3)


'AssFname = Left(docFName,8)

iProperties.Value(docFName, "Summary", "Category") = iProperties.Value("Project", "Stock Number")


If Fname >= 100 Then
        docFile.ComponentDefinition.BOMStructure = 51973 'BOMStructureEnum.kPurchasedBOMStructure
        docFile.Update
        docFile.Close
        'Else 
    End If
If Fname < 99 Then
        docFile.ComponentDefinition.BOMStructure = 51970 'BOMStructureEnum.kNormalBOMStructure
        docFile.Update
        docFile.Close    

 

 

0 Likes