katto01 发表于 2022-7-6 21:47:51

VBA - Add style to Text

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 AcadTextDim insertionPoint(0 To 2) As DoubleinsertionPoint(0) = xxinsertionPoint(1) = yy insertionPoint(2) = 0Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, HEIGHT)textObj.color = XCEnd Sub

spiff88 发表于 2022-7-6 22:42:25

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

dlanorh 发表于 2022-7-6 23:07:29

 
 
Find and open your "acadauto.chm" file. It's invaluable.   
 
Try looking in c:\program files\common files\autodesk shared\
 
I would attach a copy but i can't upload it
页: [1]
查看完整版本: VBA - Add style to Text