iLogic, move title block to top right (or other) corner

iLogic, move title block to top right (or other) corner

Tigerpirro
Advocate Advocate
1,501 Views
8 Replies
Message 1 of 9

iLogic, move title block to top right (or other) corner

Tigerpirro
Advocate
Advocate

Basically i am setting up a code that lets me quickly swap between different borders, sizes and title blocks.

However i cant get my function for choosing in which corner i want the title block in to work.

 

I am guessing that I am missing something obvious since it is a built in command.

 

I tried 

SyntaxEditor Code Snippet

ThisDrawing.ActiveSheet.TitleBlock.SetSpacingToCorner("0","0", SheetCorner.TopRight)

 

Suggestions?

0 Likes
1,502 Views
8 Replies
Replies (8)
Message 2 of 9

MechMachineMan
Advisor
Advisor

Don't know where you are finding this information... but according to my testing

 

ThisDrawing.ActiveSheet.Titleblock returns a string rather than a titleblock object

 

SyntaxEditor Code Snippet

ThisApplication.ActiveDocument.ActiveSheet.TitleBlock.Location = TitleBlockLocationEnum.kTopRightPosition

however this only a read-only call.

 

So you might just have to re-add the titleblock with it in the proper location, or try using the .Position method. 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 9

Tigerpirro
Advocate
Advocate

I wanted to call the function that controls this built in functionality.

title block placement.jpg

 

0 Likes
Message 4 of 9

SašoPrijatelj
Advocate
Advocate

Hello,

 

try this on a document, that already has a title block inserted:

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'reference to existing title block
Dim oTitleBlock As TitleBlock
oTitleBlock = oDrawDoc.Sheets(1).TitleBlock

'reference to definition of existing title block
Dim oTitleBlockDef As TitleBlockDefinition
oTitleBlockDef = oTitleBlock.Definition

'delete existing title block
oTitleBlock.Delete

'insert title block to a new location: kBottomLeftPosition, kBottomRightPosition, kTopLeftPosition, kTopRightPosition
oDrawDoc.Sheets(1).AddTitleBlock(oTitleBlockDef, TitleBlockLocationEnum.kTopLeftPosition)
-----------------------------------------------------------------------
AutoDXF - automatic flat pattern creation and batch export to DXF for Inventor

Please use "Accept as Solution" & give "Kudos" if this response helped you.
Message 5 of 9

asiteur
Collaborator
Collaborator

Indeed, readding the titleblock in the correct position seems to be the only way.

I have tried to map the titleblock using the Transformation property, but eventhough it is not read-only the titleblock doesn't seem to respond to any transformation.



Alexander Siteur
Project Engineer at MARIN | NL
LinkedIn

0 Likes
Message 6 of 9

MechMachineMan
Advisor
Advisor

@SašoPrijatelj's method works, but without extra coding, will delete all Prompted Entry fields and will fail to reinsert a title block with prompted entries.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 7 of 9

SašoPrijatelj
Advocate
Advocate

This example will also carry over specific prompted entries. In this case there are 2 and are named <Pr1> and <Pr2>.

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'reference to existing title block
Dim oTitleBlock As TitleBlock
oTitleBlock = oDrawDoc.Sheets(1).TitleBlock

Dim sPrompts(1) As String
Dim oTextBox As Inventor.TextBox
Dim sPromptedValue As String

Dim oTextBoxes As Inventor.TextBoxes
 oTextBoxes = oTitleBlock.Definition.Sketch.TextBoxes

For Each oTextBox In oTextBoxes
    sPromptedValue = oTitleBlock.GetResultText(oTextBox)
    'watch for letter case!
    If oTextBox.Text = "<Pr1>" Then
        sPrompts(0) = sPromptedValue
    ElseIf oTextBox.Text = "<Pr2>" Then
        sPrompts(1) = sPromptedValue
    End If
Next

'reference to definition of existing title block
Dim oTitleBlockDef As TitleBlockDefinition
oTitleBlockDef = oTitleBlock.Definition

'delete existing title block
oTitleBlock.Delete

'insert title block to a new location: kBottomLeftPosition, kBottomRightPosition, kTopLeftPosition, kTopRightPosition
oDrawDoc.Sheets(1).AddTitleBlock(oTitleBlockDef, TitleBlockLocationEnum.kTopLeftPosition,sPrompts)

 

 

-----------------------------------------------------------------------
AutoDXF - automatic flat pattern creation and batch export to DXF for Inventor

Please use "Accept as Solution" & give "Kudos" if this response helped you.
Message 8 of 9

wtriplett
Contributor
Contributor

Appreciate any help!  I have several different title blocks that need to be in the bottom left or bottom right location.  Is it possible to change the title block position when setting up a sheet as follows: 

 

'----------------------------------------------------------------------------------------------------
'i need this title block to be bottom right
ElseIf Parameter.Value("SheetSize") = "D" And Parameter.Value("TBStyle") = "VERTICAL" Then 
	ActiveSheet.ChangeSize("D")
	ActiveSheet.Border = "ITI DE VERTICAL"
	ActiveSheet.TitleBlock = "ITI TB VERTICAL"
	
'----------------------------------------------------------------------------------------------------
'i need this title block to be bottom left
ElseIf Parameter.Value("SheetSize") = "D" And Parameter.Value("TBStyle") = "HORIZONTAL" Then 
	ActiveSheet.ChangeSize("D")
	ActiveSheet.Border = "ITI DE HORIZONTAL"
	ActiveSheet.TitleBlock = "ITI TB HORIZONTAL"
	
'----------------------------------------------------------------------------------------------------

 

0 Likes
Message 9 of 9

A.Acheson
Mentor
Mentor

@wtriplett 

Looking at the code you posted I don't believe there is an ilogic way to position the titleblock. You need to use the API and reference the  Titleblockdefinitions  contained in the sheet and then pick one definition by name to add to the active sheet. 

 

I found the information in the below links. I found the API online help very useful when you look at the samples. The snippets can be a bit tricky if they have not been used in a context. 

 

Title Block Definitions
https://adndevblog.typepad.com/manufacturing/2013/01/deleting-the-titleblockdefinition-from-a-sheet....
https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-389C7661-CA66-437B-95A4-28F2A11A7A57
TitleBlock Positioning
https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-0D142B83-F651-409E-8299-BC9D5BB0BF4C

 

 

' Set a reference to the drawing document.
' This assumes a drawing document is active.
  
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'reference to Active Sheet
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

'reference to existing title block
Dim oTitleBlock As TitleBlock
oTitleBlock = oSheet.TitleBlock

'reference to adefinitions of Sheet title blocks by Name
Dim oTitleBlockDefs As TitleBlockDefinitions
oTitleBlockDefs = oDrawDoc.TitleBlockDefinitions

' Obtain a reference to the desired border defintion.
Dim oTitleBlockDef As TitleBlockDefinition


' Check to see if the sheet already has a title block and delete it if it does.
    If Not oTitleBlock Is Nothing Then
        oTitleBlock.Delete
    End If

	 '----------------------------------------------------------------------------------------------------
'i need this title block to be bottom right
If Parameter.Value("SheetSize") = "D" And Parameter.Value("TBStyle") = "VERTICAL" Then 
	ActiveSheet.ChangeSize("D")
	ActiveSheet.Border = "ITI DE VERTICAL"
	'ActiveSheet.TitleBlock = "ITI TB VERTICAL"
	
	'Set Titleblock definition by name
	oTitleBlockDef = oTitleBlockDefs.Item("ITI TB VERTICAL")
	'insert title block To a New location: kBottomLeftPosition, kBottomRightPosition, kTopLeftPosition, kTopRightPosition
	oSheet.AddTitleBlock(oTitleBlockDef, TitleBlockLocationEnum.kBottomRightPosition)
'----------------------------------------------------------------------------------------------------
'i need this title block to be bottom left
ElseIf Parameter.Value("SheetSize") = "D" And Parameter.Value("TBStyle") = "HORIZONTAL" Then 
		ActiveSheet.ChangeSize("D")
		ActiveSheet.Border = "ITI DE HORIZONTAL"
		'ActiveSheet.TitleBlock = "ITI TB HORIZONTAL"
		
		'Set Titleblock definition by name
		oTitleBlockDef = oTitleBlockDefs.Item("ITI TB HORIZONTAL")
		'insert title block To a New location: kBottomLeftPosition, kBottomRightPosition, kTopLeftPosition, kTopRightPosition
		oSheet.AddTitleBlock(oTitleBlockDef, TitleBlockLocationEnum.kBottomLeftPosition)
End If




Any questions let me know. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes