Jump to content

VBA - Add style to Text


katto01

Recommended Posts

Hello,

I have this routine to add text in AutoCAD.

I was wondering if I could set the font size, type and color. Could not find any reference to this.

 

Thank you

 

Public Sub AddMyTextHeight(xx, yy, HEIGHT, XC, textString)
Dim textObj As AcadText
Dim insertionPoint(0 To 2) As Double
insertionPoint(0) = xx
insertionPoint(1) = yy 
insertionPoint(2) = 0
Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, HEIGHT)
textObj.color = XC
End Sub

Link to comment
Share on other sites

You can assign a style, but not a font.

 

If you setup a style first, like "Arial" using the Arial font - you could do this:

 

textObj.StyleName = "Arial"

 

Font size would be the Height property

 

textObj.Height = 12

 

Color isn't listed as property for AcadText, but I can assign it. There is also the TrueColor property, using RGB values

 

You can get more information at this AutoDesk page on AcadText for more information.

 

https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-ActiveX/files/GUID-ED298AC7-19E0-4E54-8983-48439EF70116-htm.html

Link to comment
Share on other sites

Hello,

I have this routine to add text in AutoCAD.

I was wondering if I could set the font size, type and color. Could not find any reference to this.

 

Thank you

 

 

 

Find and open your "acadauto.chm" file. It's invaluable. :D

 

Try looking in c:\program files\common files\autodesk shared\ :unsure:

 

I would attach a copy but i can't upload it :(

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...