How to use Entity Data for labeling ?

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)

Reply to
Carlito1
Loading thread data ...

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

Reply to
Jeff

Jeff schrieb:

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

Reply to
Carlito1

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

Reply to
Jeff

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?

Reply to
roy

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

Reply to
Jeff

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

:)

which is why I hang out here. thanks.

Reply to
roy

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.