Wanted: filter fields out in a selection set. DXF Code for FIELDS?

Discussion in 'AutoCAD' started by Dan, Oct 20, 2004.

  1. Dan

    Dan Guest

    I wish to be able to filter fields out in a selection set. Any ideas?
    From the help menu, I found the following:
    FIELD group codes

    Group code
    Description

    0
    Object name (ACAD_FIELD)



    I am now diving into DXF codes....LOOK OUT!
    Been learning alot from this group, but could not find any info on this. If
    you know of a way, please enlighten me.

    Thanks!
    Dan
     
    Dan, Oct 20, 2004
    #1
  2. Dan

    Ed Jobe Guest

    I havn't tried filtering for fields but, to answer your question:
    Help>Developer Help>Dxf Reference>Objects>Field.
     
    Ed Jobe, Oct 20, 2004
    #2
  3. Dan

    TomD Guest

    At the command line, type the following:

    (entget (car (entsel)))

    and select a FIELD object. What you see will be the DXF data in lisp
    format, so to speak.
     
    TomD, Oct 20, 2004
    #3
  4. Fields aren't a separate object. They are part of text-based objects. You
    are out of luck for DXF codes.

    --
    R. Robert Bell


    I wish to be able to filter fields out in a selection set. Any ideas?
    From the help menu, I found the following:
    FIELD group codes

    Group code
    Description

    0
    Object name (ACAD_FIELD)



    I am now diving into DXF codes....LOOK OUT!
    Been learning alot from this group, but could not find any info on this. If
    you know of a way, please enlighten me.

    Thanks!
    Dan
     
    R. Robert Bell, Oct 20, 2004
    #4
  5. Dan

    Ed Jobe Guest

    However, since they can only be in mtext, you could get closer by filtering
    mtext. You could then iterate through the mtext objects.
     
    Ed Jobe, Oct 20, 2004
    #5
  6. Dan

    Dan Guest

    Thanks for your assistance.
    I tried your suggestion and got this far:

    Command: (entget (car (entsel)))

    Select object: ((-1 . <Entity name: 7ec9f778>) (0 . "MTEXT") (5 . "702AF")
    (102
    .. "{ACAD_XDICTIONARY") (360 . <Entity name: 7ec9f780>) (102 . "}") (330 .
    <Entity name: 7e358cc8>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
    "S0ANNOT") (62 . 5) (48 . 0.125) (100 . "AcDbMText") (10 35.3658 460.221
    3.66252e-292) (40 . 1.125) (41 . 0.0) (71 . 1) (72 . 5) (1 . "MK632") (7 .
    "CT1") (210 0.0 0.0 1.0) (11 1.0 0.0 0.0) (42 . 4.56652) (43 . 1.17009) (50
    ..
    0.0) (73 . 1) (44 . 1.0))

    I want to figure out what the following would be.

    FilterType(0) = ????
    FilterData(0) = ????

    The help file is where I started. This is the whole section:

    FIELD group codes

    Group code
    Description

    0
    Object name (ACAD_FIELD)

    1
    Evaluator ID

    2
    Field code string

    3
    Overflow of field code string

    4
    Format string

    300
    Evaluation error message

    90
    Number of child fields

    360
    Child field ID (AcDbHardOwnershipId); repeats for number of children

    91
    Evaluation option

    92
    Filing option

    94
    Field state flag

    95
    Evaluation status

    96
    Evaluation error code

    97
    Number of object IDs used in the field code

    330
    Object ID used in the field code (AcDbSoftPointerId); repeats for the
    number of object IDs used in the field code

    93
    Number of the data set in the field

    6
    Key string for the field data; a key-field pair is repeated for the
    number of data sets in the field

    7
    Key string for the evaluated cache; this key is hard-coded as
    ACFD_FIELD_VALUE

    90
    Data type of field value

    91
    Long value (if data type of field value is long)

    140
    Double value (if data type of field value is double)

    330
    ID value, AcDbSoftPointerId (if data type of field value is ID)

    92
    Binary data buffer size (if data type of field value is binary)

    310
    Binary data (if data type of field value is binary)
     
    Dan, Oct 20, 2004
    #6
  7. Dan

    Dan Guest

    FYI- Fields CAN be in Text. Guess I am outta luck for now until I can figure
    out a sneeky way. I won't give up.

    Thanks again all,
    Dan
     
    Dan, Oct 20, 2004
    #7
  8. And they *can* be in Attribs.

    --
    R. Robert Bell


    However, since they can only be in mtext, you could get closer by filtering
    mtext. You could then iterate through the mtext objects.
     
    R. Robert Bell, Oct 21, 2004
    #8
  9. Dan

    TomD Guest

    Dan,

    Judging by what Robert and Ed have posted, I'd say it's going to be tricky,
    at best. As you can see by the data list that ENTGET returned, there is
    some dictionary data attached to that object. I would start by
    investigating that aspect. Since Acad finds these, there must be a way,
    though it may well be undocumented and difficult to find.

    I did a quick test by adding a FIELD and two plain text objects to a drawing
    and did the following at the command prompt:

    (ssget "X" '((102 . "{ACAD_XDICTIONARY")))

    This returned a selection set containing only the FIELD. While I would
    suggest there is likely more to finding them, this seems to be a good start.
    For VBA, the info would be:

    FilterType(0) = 102
    FilterData(0) = "{ACAD_XDICTIONARY"

    Again, I cannot stress enough that I would think there is more to finding
    them, but this may be a good start.

    Best of luck.
     
    TomD, Oct 21, 2004
    #9
  10. Dan

    Ed Jobe Guest

    Are you trying to say I made a misteak? :)
     
    Ed Jobe, Oct 21, 2004
    #10
  11. Dan

    Dan Guest

    Thanks very much for the lead Tom!

    Dan

     
    Dan, Oct 21, 2004
    #11
  12. Umm... no. Just a _slight_ overstatement. <esg>
     
    R. Robert Bell, Oct 21, 2004
    #12
  13. Dan

    Ed Jobe Guest

    You did catch that was with tongue-in-cheek, right? misteak vs mistake? ;-)
     
    Ed Jobe, Oct 21, 2004
    #13
  14. Well, you can't filter for a FIELD but you can filter for a dictionary then
    iterate for a FIELD:

    Option Explicit

    Private Declare Function timeGetTime Lib "winmm.dll" () As Long

    Sub FindFields()
    Dim oEnt As AcadEntity
    Dim oSS As AcadSelectionSet
    Dim FilterType() As Integer
    Dim FilterData() As Variant
    ReDim FilterType(4)
    ReDim FilterData(4)
    FilterType(0) = -4
    FilterData(0) = "<or"
    FilterType(1) = 0
    FilterData(1) = "TEXT"
    FilterType(2) = 0
    FilterData(2) = "MTEXT"
    FilterType(3) = -4
    FilterData(3) = "or>"
    FilterType(4) = 102
    FilterData(4) = "{ACAD_XDICTIONARY"
    Set oSS = SelectionSets.Add(CStr(timeGetTime))
    oSS.Select acSelectionSetAll, _
    FilterType:=FilterType, _
    FilterData:=FilterData
    'Check to see if items found
    If oSS.Count > 0 Then
    Dim oXDic As AcadDictionary
    Dim iCntr As Integer
    Dim bGotOne As Boolean
    'iterate selset
    For Each oEnt In oSS
    Set oXDic = oEnt.GetExtensionDictionary
    bGotOne = False
    'iterate dictionary
    For iCntr = 0 To oXDic.Count - 1
    'check for field
    If oXDic.Item(iCntr).name = "ACAD_FIELD" Then
    bGotOne = True
    Exit For
    End If
    Next
    'if no field found remove from selset
    If Not bGotOne Then oSS.RemoveItems oEnt
    Next
    Else
    'notify user
    MsgBox "None found"
    Exit Sub
    End If
    'notify user
    MsgBox oSS.Count
    If Not oXDic Is Nothing Then Set oXDic = Nothing
    If Not oEnt Is Nothing Then Set oEnt = Nothing
    End Sub

    Beats iterating all object for a dictionary since it limits you to just
    MText and Text. You can add INSERT and then do a seperate iteration for
    HasAttributes and the dictionary name to catch fields in attributes, too.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 21, 2004
    #14
  15. Of course! Puns and sneaky innuendos are the spice o' life!
     
    R. Robert Bell, Oct 21, 2004
    #15
  16. Dan

    MP Guest

    I was waitin for someone to ask if you wanted that medium-rare
    :)

    ;-)
     
    MP, Oct 21, 2004
    #16
  17. Dan

    Dan Guest

    BRAVO MIKE!!
    I wasn't giving up, but I was nowhwere near your solution, nor do I
    completely understand it, but you have provided me with some new methods to
    learn and investigate. A big thanks again! I have been very eager to learn
    VB, and have been working on many tools to harness the power of FIELDS in
    A2005.

    Nice job,
    Dan
     
    Dan, Oct 21, 2004
    #17
  18. Mike, I believe this is not a good way of handling selections sets:
    Each new selection set takes up resources and you
    are creating a new one each time your sub is called.
    Sooner or later you'll get the
    "exceeded maximum number of selection sets" error

    I believe you should reuse the same one, if possible
     
    Jorge Jimenez, Oct 22, 2004
    #18
  19. True Jorge. It all depends upon how often you use them. My normal apps are
    configuration-based generators that use a db to create a drawing so I
    rarely use many selection sets. I never stopped to consider the
    consequences for someone who might use a lot of them and use the code I
    posted to generate the ssets.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 22, 2004
    #19
  20. My suggestion:

    Public Function CreateSSet(SSetName As String) As AcadSelectionSet
    Dim SSetObj As AcadSelectionSet
    Dim SSetExists As Boolean

    SSetExists = False
    For Each SSetObj In ThisDrawing.SelectionSets
    If SSetObj.Name = SSetName Then
    SSetExists = True
    Exit For
    End If
    Next
    If SSetExists = True Then ThisDrawing.SelectionSets.Item(SSetName).Delete
    Set CreateSSet = ThisDrawing.SelectionSets.Add(SSetName)
    End Function

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Oct 22, 2004
    #20
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.