Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hi All,
I have a VB program who does connect to creo and modify an existing table.
The problem is that it does not use the text font already set in the table.
My font is set to a TTF font "consolas" and height set to 0.09375"
when the program run it change the height to 0.15625" I dont get why!!!!
here is a breif section of the code.
Dim drwTableCell As IpfcTableCell 'ICpfcTableCell
Dim drwTable As IpfcTable = Nothing
Dim cellTxt As String
Dim lines As New Cstringseq
Dim drawing As IpfcDrawing
Dim drwTables As IpfcTables
Dim i As Integer
Dim asyncConnection As IpfcAsyncConnection = Nothing
Dim connSession As IpfcBaseSession
Dim model As IpfcModel
Try
'**** Connexion en cours
asyncConnection = (New CCpfcAsyncConnection).Connect(Nothing, Nothing, Nothing, Nothing)
model = asyncConnection.Session.CurrentModel
If model Is Nothing Then
Throw New Exception("Pas de modele")
End If
connSession = asyncConnection.Session
'**** recuperer l'extension
exten = Mid(model.FileName, Len(model.FileName) - 2, 3)
If exten <> "drw" Then
Throw New Exception("Modele doit être un dessin")
End If
drawing = model
drwTables = drawing.ListTables()
'**** trouver la table des révisions ID9
For i = 0 To drwTables.Count - 1
drwTable = drwTables(i)
tblName = drwTable.id.ToString
If tblName = "9" Then Exit For
Next
cellTxt = "some text"
drwTableCell = (New CCpfcTableCell).Create(2, 1)
lines.Insert(0, cellTxt)
drwTable.SetText(drwTableCell, lines)
Catch ex As Exception
MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)
End Try
Thanks for any help
Solved! Go to Solution.
Hi To all, here is the solution.
Basically the problem was that the text properties are innherited from the drawing template.
So I have created a function to edit drawing table cell
here is the code to edit the drawing table cell:
Public Function setText(CelText As String)
'note that drwTable, drwTableCell & model are declare as public earlier
Dim noteInstructions As IpfcDetailNoteInstructions
Dim lines As New Cstringseq
Dim iText1 As New CCpfcDetailText
Dim itext As IpfcDetailText
Dim selItem1 As IpfcModelItem
Dim NoteIt As IpfcDetailNoteItem
Dim texts1 As CpfcDetailTexts
Dim textLine1 As IpfcDetailTextLine
Dim textLines1 As CpfcDetailTextLines
Dim DDraw As IpfcModel2D
'
lines.Insert(0, CelText)
drwTable.SetText(drwTableCell, lines)
selItem1 = drwTable.GetCellNote(drwTableCell)
NoteIt = DirectCast(selItem1, IpfcDetailNoteItem)
noteInstructions = NoteIt.GetInstructions(True)
textLines1 = New CpfcDetailTextLines
itext = (New CCpfcDetailText).Create(CelText)
itext.TextHeight = 5.0R
texts1 = New CpfcDetailTexts
texts1.Insert(0, itext)
textLine1 = (New CCpfcDetailTextLine).Create(texts1)
textLines1.Insert(0, textLine1)
noteInstructions.TextLines = textLines1
NoteIt.Modify(noteInstructions)
lines.Clear()
DDraw = model
DDraw.Regenerate()
Return Nothing
End Function
Hi To all, here is the solution.
Basically the problem was that the text properties are innherited from the drawing template.
So I have created a function to edit drawing table cell
here is the code to edit the drawing table cell:
Public Function setText(CelText As String)
'note that drwTable, drwTableCell & model are declare as public earlier
Dim noteInstructions As IpfcDetailNoteInstructions
Dim lines As New Cstringseq
Dim iText1 As New CCpfcDetailText
Dim itext As IpfcDetailText
Dim selItem1 As IpfcModelItem
Dim NoteIt As IpfcDetailNoteItem
Dim texts1 As CpfcDetailTexts
Dim textLine1 As IpfcDetailTextLine
Dim textLines1 As CpfcDetailTextLines
Dim DDraw As IpfcModel2D
'
lines.Insert(0, CelText)
drwTable.SetText(drwTableCell, lines)
selItem1 = drwTable.GetCellNote(drwTableCell)
NoteIt = DirectCast(selItem1, IpfcDetailNoteItem)
noteInstructions = NoteIt.GetInstructions(True)
textLines1 = New CpfcDetailTextLines
itext = (New CCpfcDetailText).Create(CelText)
itext.TextHeight = 5.0R
texts1 = New CpfcDetailTexts
texts1.Insert(0, itext)
textLine1 = (New CCpfcDetailTextLine).Create(texts1)
textLines1.Insert(0, textLine1)
noteInstructions.TextLines = textLines1
NoteIt.Modify(noteInstructions)
lines.Clear()
DDraw = model
DDraw.Regenerate()
Return Nothing
End Function