Bolding Some Text In AcadBlockReference Entity

Bolding Some Text In AcadBlockReference Entity

Anonymous
Not applicable
435 Views
3 Replies
Message 1 of 4

Bolding Some Text In AcadBlockReference Entity

Anonymous
Not applicable
After inserting an AcadBlockReference entity into a drawing -- is there a way to programmatically alter it so that some of the texts are bold.

I have 25 title blocks and each title block has anywhere from 14 to 22 attributes inside. Once in a while they would request me to make such and such a text in the attribute bold and everytime I do that -- there is a chain reaction and I have to change it in many of the titleblocks.

The result is that a lot of my efforts go into something that I am thinking a code can do instead of being able to put my efforts on other things in full swing.

Any suggestion welcome and thank you for all the kind help you can give.

Matt
0 Likes
436 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
I am right now planning to make use of the StyleName property of GetAttributes method but not sure if that is the way to go.

I am trying the code below to create a style that is bold but I end up with an Mtext set with that textstyle that is not bold.

I have to manually double click an Mtext which has the style created by the code below, then click outside of the small console like popout (normally used for editing Mtext) before it can actually become bold.

Private Sub cmdBold_Click()
Dim clsK As clsKX, varA As Variant, varAS As Variant, intCnt As Integer
Dim strNameOfStyle As String, sty As AcadTextStyle

Set clsK = New clsKX
With ThisDrawing
strNameOfStyle = "": strNameOfStyle = "80SB3"
Set clsK.ThisDrawing = ThisDrawing
If clsK.TextstyleExists(strNameOfStyle) = False Then
Set sty = .TextStyles.Add(strNameOfStyle)
With sty
.fontFile = "simplex.shx"
.ObliqueAngle = 15# * (3.14159 / 180#)
.SetFont "arial", True, False, 0, 0
End With
End If
End With
MsgBox "done"
Set clsK = Nothing
End Sub

I do not have any idea why an mtext with style 80SB3 does not automatically become bold.

Any ideas/suggestion welcome.

Matt
0 Likes
Message 3 of 4

Anonymous
Not applicable
I'm not sure if you're looking at this entirely correct or if I'm maybe missing something??
Your first post mentions attributes, your second is talking of mtext,,, 2 entirely different objects.
You can change the textstyle of an attribute, but it must be done in the acadblock, not the acadblockreference. In addittion, you're looking to change the stylename property of the acadattribute itself, not the textstring, etc.
So your sequence should be something to the effect of:
1)define the bold text style you want
2)set a variable to the block located in thisdrawing.blocks
dim blk as acadblock
for each blk in thisdrawing.blocks
if blk.name = yatta then
exit for
end if
next blk
3)grab the attribute and change the style
if blk.hasattributes then
myarray=blk.getattibutes
for i = 0 to ubound(myarray)-1
if myarray(i).tagstring = yattayatta then
myarray(i).stylename = myStylenameAsaString
end if
next i
end if

Sorry about the spaces instead of tabs, I'm using the html version of the ng. 🙂
Hope this helps,
-Josh
0 Likes
Message 4 of 4

Anonymous
Not applicable
Hello Josh,
Thank you for your valuable answer --
Your response is really enlightening.

Sorry for the confusion -- the mtext thing had to do with me trying to see if I can make an mtext bold for starters.

I figured, I should first be able to do such a small task programmatically before attempting to control attributes which is more complex than an ordinary Mtext.

Since I was getting no result with Mtext without the user intervention I mentioned -- I was starting to doubt if that bold argument would work at all in the more complex entity.

Your answer proved me wrong. While trying to figure out this riddle I was able to complete some task using a small macro I built in Lisp but now that I have seen your answer -- I will try to build a smoother program using your concept ..

Thanks again.
Matt
0 Likes