Discussion:
Wanted: filter fields out in a selection set. DXF Code for FIELDS?
(too old to reply)
Dan
2004-10-20 19:27:04 UTC
Permalink
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
Ed Jobe
2004-10-20 19:58:04 UTC
Permalink
I havn't tried filtering for fields but, to answer your question:
Help>Developer Help>Dxf Reference>Objects>Field.
--
----
Ed
----
Post by Dan
I wish to be able to filter fields out in a selection set. Any ideas?
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
TomD
2004-10-20 20:02:41 UTC
Permalink
Post by Dan
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.
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.
Dan
2004-10-20 21:21:39 UTC
Permalink
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)
Post by TomD
Post by Dan
I am now diving into DXF codes....LOOK OUT!
Been learning alot from this group, but could not find any info on this.
If
Post by Dan
you know of a way, please enlighten me.
(entget (car (entsel)))
and select a FIELD object. What you see will be the DXF data in lisp
format, so to speak.
TomD
2004-10-21 13:29:29 UTC
Permalink
Post by Dan
Thanks for your assistance.
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) = ????
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.
Dan
2004-10-21 15:51:47 UTC
Permalink
Thanks very much for the lead Tom!

Dan
Post by TomD
Post by Dan
Thanks for your assistance.
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
Post by TomD
.
Post by Dan
"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
Post by Dan
.
0.0) (73 . 1) (44 . 1.0))
I want to figure out what the following would be.
FilterType(0) = ????
FilterData(0) = ????
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
(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.
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.
R. Robert Bell
2004-10-20 21:10:56 UTC
Permalink
Fields aren't a separate object. They are part of text-based objects. You
are out of luck for DXF codes.
--
R. Robert Bell


"Dan" <***@nospamculpandtanner.com> wrote in message news:4176bc0f$***@newsprd01...
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
Ed Jobe
2004-10-20 21:18:46 UTC
Permalink
However, since they can only be in mtext, you could get closer by filtering
mtext. You could then iterate through the mtext objects.
--
----
Ed
----
Post by R. Robert Bell
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?
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
2004-10-20 21:59:30 UTC
Permalink
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
Post by Ed Jobe
However, since they can only be in mtext, you could get closer by filtering
mtext. You could then iterate through the mtext objects.
--
----
Ed
----
Post by R. Robert Bell
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?
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
Post by R. Robert Bell
you know of a way, please enlighten me.
Thanks!
Dan
R. Robert Bell
2004-10-20 23:49:11 UTC
Permalink
And they *can* be in Attribs.
--
R. Robert Bell


"Ed Jobe" <***@hotmail.com> wrote in message news:4176d636$***@newsprd01...
However, since they can only be in mtext, you could get closer by filtering
mtext. You could then iterate through the mtext objects.
--
----
Ed
Ed Jobe
2004-10-21 14:35:16 UTC
Permalink
Are you trying to say I made a misteak? :-)
--
----
Ed
----
Post by R. Robert Bell
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.
--
----
Ed
R. Robert Bell
2004-10-21 16:20:39 UTC
Permalink
Umm... no. Just a _slight_ overstatement. <esg>
--
R. Robert Bell


"Ed Jobe" <***@hotmail.com> wrote in message news:4177c924$***@newsprd01...
Are you trying to say I made a misteak? :-)
Ed Jobe
2004-10-21 17:13:22 UTC
Permalink
You did catch that was with tongue-in-cheek, right? misteak vs mistake? ;-)
--
----
Ed
----
Post by R. Robert Bell
Umm... no. Just a _slight_ overstatement. <esg>
--
R. Robert Bell
Are you trying to say I made a misteak? :-)
R. Robert Bell
2004-10-21 19:44:55 UTC
Permalink
Of course! Puns and sneaky innuendos are the spice o' life!
--
R. Robert Bell


"Ed Jobe" <***@hotmail.com> wrote in message news:4177ee32$***@newsprd01...
You did catch that was with tongue-in-cheek, right? misteak vs mistake? ;-)
MP
2004-10-21 20:11:46 UTC
Permalink
I was waitin for someone to ask if you wanted that medium-rare
:-)
Post by Ed Jobe
You did catch that was with tongue-in-cheek, right? misteak vs mistake? ;-)
Mike Tuersley
2004-10-21 17:16:47 UTC
Permalink
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...
Dan
2004-10-21 20:30:50 UTC
Permalink
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
Post by Mike Tuersley
Well, you can't filter for a FIELD but you can filter for a dictionary then
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...
Jorge Jimenez
2004-10-22 07:26:14 UTC
Permalink
Post by Mike Tuersley
Set oSS = SelectionSets.Add(CStr(timeGetTime))
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
--
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica
Post by Mike Tuersley
Well, you can't filter for a FIELD but you can filter for a dictionary then
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
2004-10-22 13:56:07 UTC
Permalink
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...
Maksim Sestic
2004-10-22 14:21:41 UTC
Permalink
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
Post by Mike Tuersley
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...
Jorge Jimenez
2004-10-22 16:39:44 UTC
Permalink
Why not just

On Error Resume Next
ThisDrawing.SelectionSets.Item(SSetName).Delete
err.Clear
Set CreateSSet = ThisDrawing.SelectionSets.Add(SSetName)
--
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica

"Maksim Sestic" <***@geoinova.com> wrote in message news:***@newsprd01...
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
Post by Mike Tuersley
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...
Jorge Jimenez
2004-10-22 16:42:30 UTC
Permalink
It happens more often than we think it will
specially if the user is running other apps
that apply the same technique
--
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica
Post by Mike Tuersley
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...
Nathan Taylor
2004-10-24 05:05:54 UTC
Permalink
Here's my 2 cents. I always use the delete method of the selection set when I have finished with it. I also have a Selection Set Function I use for simplification of creating selection sets. This function always creates a new selection set and I have never had any problems simply because I delete selection sets as soon as I am finished with them.
Regards - Nathan

Loading...