Jump to content

MText Font problem


Kshirsagar

Recommended Posts

Currently, I can extract all text from Excel and create same in AutoCAD by using addMText function. Before saving autoCAD file I can see expected result, like if 1 cell contains font Tahoma then Autocad file will have font Tahoma too. but when I save & close autoCAD file, I can see font changes to ARIAL. Can any one help me in this situation.

 

Code has pasted below. Thank you in advance.

 

myText = xlSheet.Cells(iRow, iCol)

xDist = xDist + xlSheet.Cells(iRow, iCol).Width

InsertPoint(0) = spX 'xDist

InsertPoint(1) = -spY 'yDist

InsertPoint(2) = 0

 

Set Styobj = acadApp.ActiveDocument.TextStyles.Item("Standard") 'Add("M_Font1")

Typeface = CStr(xlSheet.Cells(iRow, iCol).Font.Name) 'E.g typeface could be Tahoma, Arial

If xlSheet.Cells(iRow, iCol).Font.FontStyle = "Bold" Then

bold = True

Else

bold = False

End If

If xlSheet.Cells(iRow, iCol).Font.Italic = "True" Then

Italic = True

Else

Italic = False

End If

Charset = 1

PitchandFamily = 1 Or 16

Styobj.SetFont Typeface, bold, Italic, Charset, PitchandFamily

acadApp.ActiveDocument.ActiveTextStyle = Styobj

Set mText = doc.ModelSpace.AddMText(InsertPoint, xlSheet.Cells(iRow, iCol).Width + 1, myText)

mText.Height = 4

mText.Color = acGreen

mText.Update

 

Set Styobj = Nothing

Link to comment
Share on other sites

I notice you are modifying the TextStyle font to match that retrieved from the Excel file - I've had trouble with this method in the past, certainly as far as changing bold/italic settings - they look ok, but don't stay.

 

How about approaching it using MText formatting codes? Or is this not desirable?

 

Lee

Link to comment
Share on other sites

Hi Lee,

 

Above program works, I can see expected results BUT When I open AutoCAD file again all texts font get replace with default Arial. I dont know why. any Idea?

Link to comment
Share on other sites

As I remarked:

 

I've had trouble with this method in the past, certainly as far as changing bold/italic settings - they look ok, but don't stay.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...