Change Title block and Border

Change Title block and Border

r_hoekstra
Contributor Contributor
807 Views
8 Replies
Message 1 of 9

Change Title block and Border

r_hoekstra
Contributor
Contributor

Is there a way to get titleblocks and borders from the drawings resources in a drawing ?

 

I found how to change the titleblocks or border but then you had to give the names. I want to get a list of titleblocks and borders which are in the drawing so i can select the desired titleblock and border for the drawing in a userform..

0 Likes
Accepted solutions (1)
808 Views
8 Replies
Replies (8)
Message 2 of 9

yuzeaa
Advocate
Advocate

Title block:

Dim drawingdoc As DrawingDocument = ThisDoc.Document
Dim osheet As Sheet = drawingdoc.ActiveSheet
Dim TitleBlocks As New List(Of String)
For Each t In drawingdoc.TitleBlockDefinitions
	TitleBlocks.Add(t.Name)
Next
SelectedName = InputListBox("Select TitleBlock", TitleBlocks, "", Title := "TitleBlockDefinitions", ListName := "List")
If SelectedName Is Nothing Then Return
TitleBlockDef = drawingdoc.TitleBlockDefinitions(SelectedName)
Try:osheet.TitleBlock.Delete : Catch: End Try
osheet.AddTitleBlock(TitleBlockDef)

Border:

Dim drawingdoc As DrawingDocument = ThisDoc.Document
Dim osheet As Sheet = drawingdoc.ActiveSheet
Dim Borders As New List(Of String)
For Each b In drawingdoc.BorderDefinitions
	Borders.Add(b.Name)
Next
SelectedName = InputListBox("Select Border", Borders, "", Title := "BorderDefinitions", ListName := "List")
If SelectedName Is Nothing Then Return
BorderDef = drawingdoc.BorderDefinitions(SelectedName)
Try:osheet.Border.Delete : Catch: End Try
Try
osheet.AddBorder(BorderDef)
Catch
osheet.AddDefaultBorder
End Try
0 Likes
Message 3 of 9

r_hoekstra
Contributor
Contributor

Thank you for the help.. 

For the borders it works but for the titleblock it gives an error about incorrect parameter. 

on this part 

osheet.AddTitleBlock(TitleBlockDef)

 

0 Likes
Message 4 of 9

yuzeaa
Advocate
Advocate

Can you provide a photo of your drawing browser? Will selecting each titleblock result in an error?

0 Likes
Message 5 of 9

r_hoekstra
Contributor
Contributor

Yeah every titleblock will give an error..
But i got prompted entrys in them. So that will be the problem i think..

Removed the prompted entrys, now it works.. Now try to get it working with the prompted entrys

0 Likes
Message 6 of 9

yuzeaa
Advocate
Advocate

Yes ,that would be the problem. How many prompt entrys?

0 Likes
Message 7 of 9

r_hoekstra
Contributor
Contributor
i got 2 prompted entrys in them at the moment.
0 Likes
Message 8 of 9

yuzeaa
Advocate
Advocate
Accepted solution

I guess you will then ask if it can be automatically replaced?

Dim drawingdoc As DrawingDocument = ThisDoc.Document
Dim osheet As Sheet = drawingdoc.ActiveSheet
Dim TitleBlocks As New List(Of String)
For Each t In drawingdoc.TitleBlockDefinitions
	TitleBlocks.Add(t.Name)
Next
Dim oPromptstrings(1) As String
SelectedName = InputListBox("Select TitleBlock", TitleBlocks, "", Title := "TitleBlockDefinitions", ListName := "List")
If SelectedName Is Nothing Then Return
Promptstrings_1 = InputBox("First Promptstring", "Title", "")
If Promptstrings_1 = "" Then Return
Promptstrings_2 = InputBox("Second Promptstring", "Title", "")
If Promptstrings_2 = "" Then Return
oPromptstrings(0) = Promptstrings_1
oPromptstrings(1) = Promptstrings_2	
TitleBlockDef = drawingdoc.TitleBlockDefinitions(SelectedName)
Try:osheet.TitleBlock.Delete : Catch: End Try
osheet.AddTitleBlock(TitleBlockDef,,oPromptstrings)

 

0 Likes
Message 9 of 9

r_hoekstra
Contributor
Contributor
Thank you.. this works really well.. 🙂

Not yet using the automatic update of the prompted entries, so i commented those lines out.

0 Likes