How to use Entity Data for labeling ?

Discussion in 'AutoCAD' started by Carlito1, May 19, 2006.

  1. Carlito1

    Carlito1 Guest

    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)
     
    Carlito1, May 19, 2006
    #1
  2. Carlito1

    Jeff Guest

    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, May 20, 2006
    #2
  3. Carlito1

    Carlito1 Guest

    I did email but get this "> unrouteable mail domain "sonic451.net"
     
    Carlito1, May 20, 2006
    #3
  4. Carlito1

    Jeff Guest

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

    Jeff
     
    Jeff, May 21, 2006
    #4
  5. Carlito1

    Jeff Guest

    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
     
    Jeff, May 22, 2006
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.