How to get titleblock details from drawing

How to get titleblock details from drawing

shivam7C2Q8
Explorer Explorer
375 Views
5 Replies
Message 1 of 6

How to get titleblock details from drawing

shivam7C2Q8
Explorer
Explorer

Hii I am wondering if we can fetch the title block details like scale, title, Dwg number, Revision  from drawing like here via apis.

shivam7C2Q8_0-1695801788446.png

I found out this values are set from field text but don't know how to get these values ?

shivam7C2Q8_1-1695801889223.png

 

0 Likes
Accepted solutions (1)
376 Views
5 Replies
Replies (5)
Message 2 of 6

bradeneuropeArthur
Mentor
Mentor
Can you share the drawing template to help you programming this!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 6

FINET_Laurent
Advisor
Advisor

Hi @shivam7C2Q8,

 

It is a bit tricky but achievable. Here is an example of mine :

Dim actDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
Dim s As Sheet = actDoc.ActiveSheet

Dim t As TitleBlock = s.TitleBlock
Dim tDef As TitleBlockDefinition = t.Definition

For Each txtBox As TextBox In tDef.Sketch.TextBoxes
	If txtBox.Text = "<AUTEUR>" Then  MsgBox(t.GetResultText(txtBox))
		
Next

Basicly prompt entries are created when adding a text box in the title block, and formating as folowing : <PropertyName>
So basicly I just search in the text boxes collection and fine the one that I'm looking for, then see it's value.

You could use then a small function like this :

Sub main
	Dim val As String = find_value("AUTEUR")
	MsgBox(val)
	
End Sub

Function find_value(propertyName As String) As String
	Dim actDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
	Dim s As Sheet = actDoc.ActiveSheet

	Dim t As TitleBlock = s.TitleBlock
	Dim tDef As TitleBlockDefinition = t.Definition

	For Each txtBox As TextBox In tDef.Sketch.TextBoxes
		If txtBox.Text = "<" & propertyName & ">" Then  Return t.GetResultText(txtBox)
			
	Next
	
	Return "Property doesn't exist"
End Function

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 4 of 6

shivam7C2Q8
Explorer
Explorer

Hii I have downloaded these sample drawings I will attach one below

0 Likes
Message 5 of 6

shivam7C2Q8
Explorer
Explorer
Hi @FINET_Laurent

above code I tried I am getting the properties but not its values for ex. in orignal post the scale is 1/2 in titleblock but I am not getting that value using t.GetResultText(txtBox). It is returning empty string.

thanks,
Shivam
0 Likes
Message 6 of 6

FINET_Laurent
Advisor
Advisor
Accepted solution

Hi @shivam7C2Q8,

 

My code is working flawless on my end :

FINET_Laurent_0-1695808472098.png

Sub main
	Dim val As String = find_value("Echelle de la vue d'origine")
	MsgBox(val)
	
End Sub

Function find_value(propertyName As String) As String
	Dim actDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
	Dim s As Sheet = actDoc.ActiveSheet

	Dim t As TitleBlock = s.TitleBlock
	Dim tDef As TitleBlockDefinition = t.Definition

	For Each txtBox As TextBox In tDef.Sketch.TextBoxes
		If txtBox.Text = "<" & propertyName & ">" Then  Return t.GetResultText(txtBox)
			
	Next
	
	Return "Property doesn't exist"
End Function

Note that the text specified in the string (line 2) has to match perfectly (capital letters, spaces, ..).
Also check the prompt itself has a value and is not empty.

Kind regards,

FINET L.

 

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill