Cann't add the border and titel block from Defind options

Cann't add the border and titel block from Defind options

ngocson8335
Advocate Advocate
495 Views
6 Replies
Message 1 of 7

Cann't add the border and titel block from Defind options

ngocson8335
Advocate
Advocate

Dear Team,

 

I'm having the problem when I was coding. I would like to add the border and title block but can not.

 

Please help me to fix this problem.

 

Here is my code:

 

Imports Inventor
Public Class Form1

Dim invApp As Inventor.Application
Dim oDrawDoc As DrawingDocument


Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
'Attach to the Existing Runnin Inventor Application

invApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")

Catch ex As Exception

System.Windows.Forms.MessageBox.Show("Error: Inventor must be running...")

Exit Sub

End Try
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


oDrawDoc = invApp.Documents.Open("D:\OneDrive\OneCAD\ATC\Training Documents\Excercise File\Template\Template.idw", True)

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

'Active bản vẽ hiện tại
oDrawDoc = invApp.ActiveDocument

'Open template sẵn có
Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.Add(DrawingSheetSizeEnum.kBDrawingSheetSize)

Dim oSheetActive As Sheet
oSheetActive = oDrawDoc.ActiveSheet

'Thêm một khung bản vẽ Custom DIN EN ISO 5457
Dim oBorderDef As Inventor.Border
oBorderDef = oSheetActive.AddBorder(oDrawDoc.BorderDefinitions.Item("DIN EN ISO 5457"))

'Thêm một khung tên custom DIN EN ISO 5457
Dim oTitleBlock As Inventor.TitleBlock
oTitleBlock = oSheetActive.AddTitleBlock(oDrawDoc.TitleBlockDefinitions.Item("DIN EN ISO 5457"))

End Sub
End Class

Ngoc Son
Autodesk User
0 Likes
Accepted solutions (2)
496 Views
6 Replies
Replies (6)
Message 2 of 7

marcin_otreba
Contributor
Contributor

hi,

 

could you provide samle of your drawing ?  i think problem is that you have some prompted inputs in your border/title block definitions.

0 Likes
Message 3 of 7

ngocson8335
Advocate
Advocate

Hi,

Here is my file.

Thank you

Ngoc Son
Autodesk User
0 Likes
Message 4 of 7

ngocson8335
Advocate
Advocate

Hi sir,

 

Are you still working on this case?

 

Ngoc Son

Inventor's user

Ngoc Son
Autodesk User
0 Likes
Message 5 of 7

marcin_otręba
Advisor
Advisor
Accepted solution

sorry, but actually i use 2017 and i can't open your file.

But i'm almost sure that the problem is that you have some prompted entries.  Try to create simpole border even with one line, and simple titleblock. Then try to place it bu code and it will work.

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 6 of 7

marcin_otręba
Advisor
Advisor
Accepted solution

Could you provide photo from your drawing resources (tree) ?

try :  

Set oBorder = oSheet.AddDefaultBorder()

 

also try :

  Dim oTitleBlockDef As TitleBlockDefinition
    Set oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item("DIN EN ISO 5457")
Dim sPromptStrings(1 To 2) As String
    sPromptStrings(1) = "String 1"
    sPromptStrings(2) = "String 2"


    ' Add an instance of the title block definition to the sheet.
    Dim oTitleBlock As TitleBlock
    Set oTitleBlock = oSheet.AddTitleBlock(oTitleBlockDef, , sPromptStrings)

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 7 of 7

ngocson8335
Advocate
Advocate

Thank you for your suggested. I fixed it.

Ngoc Son
Autodesk User
0 Likes