iLogic help + Accessing the File name of a referenced document.

iLogic help + Accessing the File name of a referenced document.

MechMachineMan
Advisor Advisor
1,648 Views
4 Replies
Message 1 of 5

iLogic help + Accessing the File name of a referenced document.

MechMachineMan
Advisor
Advisor

I'm trying to make a list of all referenced / referencing documents and currently all it does is show up blank, as if it is skipping over the whole For section.

 

Please take a look and advise me on what I'm doing wrong.

 

SubMain()

 

oWrite = System.IO.File.CreateText("C:\Users\FILE NAME HERE"&".txt")

oDoc=ThisDoc.Document

Fori=1To 100

    oWrite.WriteLine(i)

    Next

 

 

Forj=1TooDoc.AllReferencingDocuments.Count

    DimoRefAsDocument = oDoc.AllReferencingDocuments.Item(j)

    oWrite.WriteLine(oRef.FullFileName)

    Next

    

oWrite.Close

 

End Sub


--------------------------------------
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
0 Likes
Accepted solutions (1)
1,649 Views
4 Replies
Replies (4)
Message 2 of 5

rossano_praderi
Collaborator
Collaborator
Accepted solution

Hi, I think this can be your solution...

 

Sub Main()

oWrite = System.IO.File.CreateText("d:\test.txt") ' Change the filename as you like
oDoc = ThisDoc.Document
 
For j = 1 To oDoc.AllReferencedDocuments.Count
    oWrite.WriteLine(j & ") " & oDoc.AllReferencedDocuments.Item(j).FullFileName)
Next

' ******* if you want the first level referenced documents then this is your option *********
'For j = 1 To oDoc.AllReferencedDocuments.Count
'    oWrite.WriteLine(j & ") " & oDoc.AllReferencedDocuments.Item(j).FullFileName)
'Next

oWrite.Close
End Sub

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 3 of 5

rossano_praderi
Collaborator
Collaborator

I made a mistake...this is the correction for part of my posted code....sorry.

 

' ******* if you want the first level referenced documents then this is your option *********
'For j = 1 To oDoc.ReferencedDocuments.Count
'    oWrite.WriteLine(j & ") " & oDoc.ReferencedDocuments.Item(j).FullFileName)
'Next

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 4 of 5

MechMachineMan
Advisor
Advisor
Thanks! That seems to have done it. Was getting random Invalid errors because my indexing was off, then was not printing any info due to me using the wrong document object/referencing.

Now that it's working... Time to figure out how to put it in a drawing table!

--------------------------------------
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
0 Likes
Message 5 of 5

rossano_praderi
Collaborator
Collaborator
Hi, I'm glad to be helpful.

Bregs
Rossano Praderi


--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes