Exporting text from unresolved drawing

Exporting text from unresolved drawing

kacper_sikorskiD42JA
Contributor Contributor
390 Views
4 Replies
Message 1 of 5

Exporting text from unresolved drawing

kacper_sikorskiD42JA
Contributor
Contributor

Hello,

I've got an idea how to optimize my work but i'm not sure how to approach this problem.

 

I have a folder that contains around 100 drawings (sometimes more sometime less), all i want to do is to get a drawing number and drawing name from it to excel. My problem is that all those files are unresolved and model that the name comes from is not avaliable (name of the drawing is from the model).

kacper_sikorskiD42JA_0-1721394543187.png

This is my table, Drwg.No can be imported from Iproperty of a drawing "Part Number" but Title is from model.

I think it should be possible because inventor is storing the memory about title somewhere.

 

Is it possible to get those parameters from the outside of inventor? (for example using excel or python)

It would help so i don't have to open all of those drawings and run ilogic on them.

 

If not possible from outside, would it be possible to get it using Ilogic when all files are open?

 

At the end it should give me an excel looking like this

kacper_sikorskiD42JA_1-1721394923145.png

 

Thanks for help in advance! 😄

 

0 Likes
391 Views
4 Replies
Replies (4)
Message 2 of 5

sanganaksakha
Advocate
Advocate

Hello,

Here is some sample code (Excel VBA Macro so that you don't need to open Inventor) to get you started.

 

Sub getIdwTitle()
    Dim idwFilePath As String
    '''''''''''
    idwFilePath = "C:\temp\GetTitle.idw" ''''' Change to existing path on your sustem
    Dim filePaths(0) As String
    filePaths(0) = idwFilePath
    '''' Replace the above 3 lines to create an array of all drawing files in the folder
    
    '''''''''''''''
    
    Dim oApprentice As New ApprenticeServerComponent
    Dim apprDocIdw As ApprenticeServerDrawingDocument
    Dim modelFileName As String
       
    Dim i As Integer
    For i = 0 To UBound(filePaths)
        Set apprDocIdw = oApprentice.Open(filePaths(i))
    modelFileName = apprDocIdw.Sheets(1).DrawingViews(1).ReferencedDocumentDescriptor.DisplayName
    Debug.Print modelFileName 
    '''' Add code to remove extension from the modelFileName    
    '''' Add code to write the name to Excel Cell
    Next

End Sub

 

 Using VB.Net code can be more robust and compact.

0 Likes
Message 3 of 5

Michael.Navara
Advisor
Advisor

This is several questions

How to obtain Title:

You can obtain the text from title block using GetResultText method. Here is a sample iLogic call

 

Dim drw As DrawingDocument = ThisDoc.Document
Dim titleBlock as TitleBlock = drw.ActiveSheet.TitleBlock
Dim resultText As String = titleBlock.GetResultText(titleBlock.Definition.Sketch.TextBoxes(1))
Logger.Debug(resultText)

 

 

How to iterate files in directory:

 

Dim rootPath As String = "C:\Path\To\Files"
For Each fileName In System.IO.Directory.EnumerateFiles(rootPath, "*.idw")
    Dim options As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
    options.Value("SkipAllUnresolvedFiles") = True

    Dim document as Document = ThisApplication.Documents.OpenWithOptions(fileName, options)

    'Do something

    document.Close(true)
Next

 

 

Save data to file:

It is much better to use CSV file instead of Excel, because the work is much easier.

 

Execute:

The best approach is to use external iLogic rule which can open, process and close the documents.

 

0 Likes
Message 4 of 5

kacper_sikorskiD42JA
Contributor
Contributor
Hi, thanks for the answer but when i'm trying the first part of the code with getresulttext method i get only this. I tried it for multiple values of Texboxes.
INFO| 2: >>---------------------------
INFO| 3: >>---------------------------
INFO| 4: >>---------------------------
INFO| 5: >>---------------------------
INFO| 6: >>---------------------------
INFO| 7: >>---------------------------
INFO| 8: >>---------------------------
INFO| 9: >>---------------------------
INFO| 10: >>---------------------------
INFO| 11: >>---------------------------
INFO| 12: >>---------------------------
INFO| 13: >>---------------------------
INFO| 14: >>---------------------------
INFO| 15: >>---------------------------
INFO| 16: >>---------------------------
INFO| 17: >>---------------------------
INFO| 18: >>---------------------------
INFO| 19: >>---------------------------
0 Likes
Message 5 of 5

Frederick_Law
Mentor
Mentor

Change Logger.Debug to Logger.Info.

Or change your Log level to Debug.

0 Likes