I'm not familiar with C# coding, but here is the starting and ending portions of the code to edit a TitleBlockDefinition in iLogic.
All lines of code here starting with an ' apostrophe means it is commented out, and is just there to show you another example of how to the same thing.
You can either access the TitleBlockDefinition by digging down through the Sheet, then TitleBlock (as it looks like you were attempting to to), or you can access it by oDoc.TitleBlockDefinitions.Item(1), if its the first one. Or you can replace the 1 with the quoted String name of it.
The first "Edit" line is a bit tricky, because it works more like a Get statement, than a invocation.
It acts as a Sub that returns the reference to a copy of the DrawingSketch within the TitleBlockDefinition for you.
Then you can use that reference as a variable to edit the sketch.
There's a long scrolling list of ways to edit the sketch, so I thought I'd leave that portion out for a later discussion, if needed.
When you're done editing the sketch, the ExitEdit line for the oTBDef, if you answer True, it saves your edited sketch back over the original, replacing it. Or if you answer True, this () area offers a second optional setting, where you can specify a New Name As Object (but it can just be a String), and if you specify one, it then saves your edits as a new TitleBlockDefinition.
Dim oDoc As DrawingDocument = ThisDrawing.Document
'Dim oTBDefs As TitleBlockDefinitions = oDoc.TitleBlockDefinitions
'Dim oSheet As Sheet = oDoc.Sheets.Item(1)
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oTBDef As TitleBlockDefinition = oSheet.TitleBlock.Definition
Dim oTBDSketch As DrawingSketch
oTBDef.Edit(oTBDSketch)
'Now use oTBDSketch as your variable representing a DrawingSketch to Edit it.
'Then, when done, the following line saves your changes.
oTBDef.ExitEdit(True)
'Or, if you want to save it as a new TitleBlockDefinition, use the following line instead.
'oTBDef.ExitEdit(True,oNewNameAsString)
I don't know of a good way to translate this to C# for you.
I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.
Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.
- Options to format contents of MessageBox, InputBox, and InputListBox Click Here
- Ability to fully constrain and dimension to the edjes of images within drawing title block sketches, SketchedSymbol sketches, other drawing sketches, and assembly sketches Click Here
- Save section view status in DesignViewRepresentation, so it can be used in drawing view Click Here
- Add SolidBodies folder to iLogic Rule Editor Model Tab Click Here
- Convert all views to Raster before autosave stores to 'OldVersions' folder Click Here
Thanks, and best of luck in your future Inventor Customization endeavors.
Autodesk Inventor 2020 Online Help
Inventor Forum
Inventor Customization Forum
Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)