
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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)
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
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)
Solved! Go to Solution.