TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
Be sure your post is relevant to the current discussion.  Create a new topic within the appropriate board if you are unsure.

text_background_ex.tcm again
Read 9611 times
* September 09, 2009, 04:09:45 PM
I am trying to find a copy of Tom Snapes old text_background_ex macro.

I posted this before the forum crashed and someone was kind enough to answer and post the old macro.  I think it was IBRuethsch but I am not sure.

I was not able to download the macro before the forum crashed and now my old post is no longer listed.

Any help would be appreciated
CWCookman

Logged


* September 10, 2009, 10:46:54 AM
#1
Hello cwcookman
yes - you are right. I posted an answer.
Tomas helped me that days.
But the macro didn´t do what it suppose to do.

The problem is the internal CS. When the text was moved before you use the macro, then the background is created at the original place.
TC now include this feature (add to any text a background)  and I haven´t used the macro for a long time.

best regards
Bernd

(if this post disappear again , please contact me direct)



[attachment deleted by admin]

Logged


* September 10, 2009, 06:53:25 PM
#2
Thank you ibruethsch for your help.  This time I downloaded the macro as soon as I saw it rather than relying on the site to keep it secure.

I should be able to check it out on my development computer in the next few days.


Best Regards,
CWC

Logged


* September 25, 2009, 06:55:21 PM
#3
I finally got the time to try and test text_background_ex.tcm macro.

For some reason when I loaded text_background_ex.tcm (renamed as suggested) the macro does not show up.  I suspect either the file on the the site is corrupted or it was generated in a version of TCad that is not compatible with mine.  I use TCad 10.5 as it is the last version with integrated VBA.

This is the first time I have loaded a macro and had it not show up.  I tried loading into a new blank drawing, I also tried downloading the file more than once.

ibruethsch, would it be too much to ask for you to copy the code and either place it in a text file or post it here?  If there is a and associated form it can be exported as a frm file.

Any help would  be appreciated.

CWC

Logged


* October 11, 2009, 04:08:08 AM
#4
Hello
I improved the macro in one case:
'##################################################################################
'Text_Background_ex.tcm macro for TurboCAD
'Tom Snape 01/28/05
'Example code for adding a background behind a selected text graphic.
'Does not work with Multitext
'Only works with text in default justification ("Left" and "Top")
'Bare bones code with no error handling
' using ucs added by Bernd Rüthschilling 11.10.2009
'##################################################################################

Sub Text_Background_wcs()
Dim gr1 As Graphic
Dim grh As Graphic
Set gr1 = Application.ActiveDrawing.Selection.Item(0).Graphics
Set grh = Application.ActiveDrawing.Graphics.add
With gr1.Vertices
grh.Vertices.add .Item(2).X + gr1.UCS.GetEntry(0, 3), .Item(2).Y + gr1.UCS.GetEntry(1, 3), 0
grh.Vertices.add .Item(3).X + gr1.UCS.GetEntry(0, 3), .Item(3).Y + gr1.UCS.GetEntry(1, 3), 0
grh.Vertices.add .Item(4).X + gr1.UCS.GetEntry(0, 3), .Item(4).Y + gr1.UCS.GetEntry(1, 3), 0
grh.Vertices.add .Item(5).X + gr1.UCS.GetEntry(0, 3), .Item(5).Y + gr1.UCS.GetEntry(1, 3), 0
End With
grh.Close
grh.BrushStyle = "Solid"
grh.Properties("BrushColor") = Application.NamedColors("White")
gr1.BringToFront
Application.ActiveDrawing.ActiveView.Refresh

Dim v1 As Vertex
Dim x1 As Double
Dim y1 As Double
Set v1 = gr1.Vertices(0)
x1 = v1.X
y1 = v1.Y
'MsgBox x1 & ", " & y1

End Sub

it works with one selected item.

Bernd

Logged


* October 12, 2009, 11:37:56 AM
#5
Hi Bernd,

I wonder if it wouldn't be simpler just to set the UseWorldCS property to True for both sets of vertices before copying the vertices from the text graphic to the background graphic?

i.e.
gr1.Vertices.UseWorldCS = True
grh.Vertices.UseWorldCS = True
With gr1.Vertices
grh.Vertices.Add .Item(2).X, .Item(2).Y, .Item(2).Z
grh.Vertices.Add .Item(3).X, .Item(3).Y, .Item(3).Z
etc.

That should go a bit faster and be a bit more readable too.

Kevan

Logged


* October 13, 2009, 12:48:26 AM
#6
Hi Kevan

I found the UseWorldCS property. But when I tried to use it, it seems that I always had the wrong syntax.
I agree with you - it is easier to read.

best regards
Bernd

Logged