Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get titleblock details from drawing

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
shivam7C2Q8
218 Views, 5 Replies

How to get titleblock details from drawing

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

 

5 REPLIES 5
Message 2 of 6

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

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 3 of 6
FINET_Laurent
in reply to: shivam7C2Q8

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

Message 4 of 6

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

Message 5 of 6
shivam7C2Q8
in reply to: FINET_Laurent

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
Message 6 of 6
FINET_Laurent
in reply to: shivam7C2Q8

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report