Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic: change the part numbers of all ipt in assembly and sub-assembly

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Ursa_Major
980 Views, 2 Replies

iLogic: change the part numbers of all ipt in assembly and sub-assembly

Hello,

 

i got a question about the change of iproperties in a assembly. My assembly contains sub-assemblys on different levels and i want to change every .ipt part number to a part of the filename.

 

The first Rule i got:

 

 iProperties.Value("Project", "Part Number") = Split(ThisDoc.FileName(False),"-")(+1)

 

and the idea to get it in all .ipt´s:

 

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
Dim docFile As Document 

'kAssemblyDocumentObject = 12291 
If openDoc.DocumentType = 12291 Then
    'Iterate though the part files in the assembly
    For Each docFile In openDoc.AllReferencedDocuments    
        'kPartDocumentObject = 12290 
        If docFile.DocumentType = 12290 Then    
                                
            'set part number to file name (without extension)
                    If docFile.FileName(False) = "*-*-*" Then
                    docFile.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = Split(ThisDoc.FileName(False),"-")(+1)
                    End If    
        End If         
    Next    
Else    

MessageBox.Show("Use Assembly")
End If 

 

All i get is "system.missingmemberexception no default member found for file name". It would be great if somebody here could help me with this problem.

 

 

2 REPLIES 2
Message 2 of 3
MechMachineMan
in reply to: Ursa_Major

Try:

 

System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) instead of oDoc.FileName

 

Also,

 

add a try/catch around the fetching of the filename in case the file has not been saved yet.

 

Good luck.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 3
Ursa_Major
in reply to: Ursa_Major

Thanks for the quick answer MechMachineMan, i will try it and post the results.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report