How to use Entity Data for labeling ?

May 19, 2006 6 Replies

Hi, Included in my drawing are 500 circles as Entitys with Data attached. Each Entity has 7 text felds. I need to label each Entity with a number out of its attached Entity Data.



I wasted 2 Days on this and no success.



Is anyone here with the know how to do this by script (VBA)?



Any hints are welcome.



Many thanks in advance



(I revised the posting because stating Block for Entity firsttime)


If you email me a drawing with 1 or 2 of these circles with the data attached I could probably help you.

miff at sonic dot net

Jeff

Jeff schrieb:

I did email but get this "> unrouteable mail domain "sonic451.net"

I put my real email in the post......but that domain you show needs the 451 removed. It helps to keep spam away.

THIS MIGHT BE FUN. from the command line:

(SETQ IT (ENTGET (CAR (ENTSEL))))

pick on of your circle entities.

cut and paste the dxf code for the entity to the board and we can all see what we are talking about.

huh?

That won't quite get it, roy. ;-) Since the data is stored as XDATA you need to ask for that in the (entget)...... (SETQ IT (ENTGET (CAR (ENTSEL)) '("*")))

And as it turns out, Carlito's XDATA is under the basic "ACAD" application name and I sent this code to them:

Sub labelCircles() Dim oSS As AcadSelectionSet Dim oCirc As AcadCircle Dim iCode(1) As Integer Dim vData(1) As Variant Dim iXCode As Variant Dim vXData As Variant Dim dTextSize As Double Dim I As Integer Dim oText As AcadText Dim sStr As String

dTextSize = 1 'adjust as desired

On Error Resume Next Set oSS = ThisDrawing.SelectionSets.Add("MyCircles") If Err Then Set oSS = ThisDrawing.SelectionSets.Item("MyCircles") Err.Clear oSS.Clear End If On Error GoTo 0

iCode(0) = 0: vData(0) = "CIRCLE" iCode(1) = 1001: vData(1) = "ACAD"

oSS.Select acSelectionSetAll, , , iCode, vData For Each oCirc In oSS oCirc.GetXData "ACAD", iXCode, vXData For I = 0 To UBound(vXData) If iXCode(I) = 1000 And InStr(1, vXData(I), "Nr") Then sStr = Mid(vXData(I), 4) Set oText = ThisDrawing.ModelSpace.AddText(sStr, oCirc.Center, dTextSize) ''The next 2 lines should be adjusted to do what you want. oText.Alignment = acAlignmentCenter oText.TextAlignmentPoint = oCirc.Center Exit For End If Next Next End Sub

Jeff

YOU KNOW: I don't learn something new every day. only on the good days.....

:)

which is why I hang out here. thanks.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required