Select and extraction informations of multiple drawings selection. (VBA/ API)

Select and extraction informations of multiple drawings selection. (VBA/ API)

Anonymous
Not applicable
768 Views
3 Replies
Message 1 of 4

Select and extraction informations of multiple drawings selection. (VBA/ API)

Anonymous
Not applicable

Hi Guys! 

The goal is to extract information from Title Boxes of a Drawing file. 

Firstly i use some simple code in order to get iProprieties from some drawings. That works perfectly but in some drawings the Title Boxes are filled Manually (Without using iProp). 

I started looking for the variable where the values of the title box are. 

According to my research, there are  2 ways to access  this information using VBA: 

 

- Using Apprentice Server: 

 

Dim oSheet As Worksheet
Set oSheet = Application.ActiveSheet

Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)

Dim vrtSelectedItem As Variant

' create Apprentice server for reading into the file
Dim oIV As New ApprenticeServerComponent
Dim oIVDoc As ApprenticeServerDrawingDocument

'Use the Show method to display the File Picker dialog box and return the user's action.
'The user pressed the action button.
If fd.Show = -1 Then.

For Each vrtSelectedItem In fd.SelectedItems

Set oIVDoc = oIV.Open(vrtSelectedItem)

 

Next vrtSelectedItem

 

Using a spy on the variable oIVDoc (ApprenticeDrawingDocument) i could access to the values of all variables of. However I couldn't get the values of variables which contains the values of the title block (Way: oIVDoc -> Sheets ->Item 1->TitleBlock bellow) 

Title_Box_error.PNG

it says there is an error defined by the application or the object. 

 

- The second way to access values of title boxes is to use the class DrawingDocument:

 

Dim vrtSelectedItem As Variant
Dim SelectedItem As Variant

Dim invApp As Object
Set invApp = GetObject(, "Inventor.Application")

Dim oDrawDoc As DrawingDocument

Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)If fd.Show = -1 Then

For Each vrtSelectedItem In fd.SelectedItems
Dim DrawingFile As Document
Set DrawingFile = invApp.Documents.Open(vrtSelectedItem)
Set oDrawDoc = invApp.ActiveDocument

Next

 

Using that solution I could get the values of each box in the title box using the way: 

oDrawdoc (Spy) ->TitleBlockDefinitions->Sketch->TextBoxes

Result Titleblock.PNG

using (GetResultText()) i could get the value thati wanted  finally! 

 

BUT 

 

In that second solution the drawing document must be ACTIVE (Open on Inventor during processing). 

My question are: 

How to automate the process without using "ActiveDocument" when I set the value oDrawDoc which require inventor to be open ? 

Can we use the ApprenticeServer to get these values? 

 

Thanks ! 

 

Ayoub 

Chbani

Engineer intern (BaguetteLand) 

 

0 Likes
Accepted solutions (2)
769 Views
3 Replies
Replies (3)
Message 2 of 4

HermJan.Otterman
Advisor
Advisor
Accepted solution

Apprentice is also Inventor, like "striped"

apprentice can't do everything that Inventor can, but what it can, it does it verry quick!. so with properties you can us it. mind you all documents have to be migrarted to the version of Inventor that you are using, or Apprentice will give an error.

other wise you need Inventor...

what is your question...? How to automate the process without using "ActiveDocument" when I set the value oDrawDoc which require inventor to be open.....

what would you like... no Inventor? what is the problem with option 2?

you could open a document but not displaying it:

Documents.Open( FullDocumentName As String, [OpenVisible] As Boolean ) As Document

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 4

Anonymous
Not applicable

Hi Herm, 

 

Thank you for your reply. indeed the apprentice server does operations quickly compared to Inventor, the final goal is to scan all our Drawings database and create an excel sheet which specifies all information according to Drawings: Engine, part number, sub Assembly: That will allow operators to access to a drawings file just by making a search by Keyword. 

The apprentice server should allow me to do this as "background" operation without loading each file on inventor software get the result and then close that file.

 

I just tried to open the file as you said and that works perfectly without displaying the drawing that reduces the processing time. 

 

Do I have to Close the file after each iteration with:

Set DrawingFile = invApp.Document.Close(True)

Or there is a better solution?

 

 While opening some files a window pop up with due to mismatching links according to a picture on the drawing file which doesn't match: 

Pop window.PNG

Do you know how to get rid of that windows which slow down the process time ? 

 

Thanks ! 

 

Ayoub

0 Likes
Message 4 of 4

HermJan.Otterman
Advisor
Advisor
Accepted solution

yes, I would close the drawings, when you are done with them!

 

you can prevent the dialogboxes in Inventor with : _InvApplication.SilentOperation = True

 

what you are describing, you want to use this to create an excel file for properties and links to other files.... maybe you should install and use Vault....! it comes with Inventor and then you have this all and more...

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan