Extended Entity Data

Discussion in 'AutoCAD' started by iwafb, Mar 22, 2005.

  1. iwafb

    iwafb Guest

    Hi all,

    We are currently using extended entity data to "attach" size definition to entities within a model. So far, this has worked well when I assign group code 1000. The trouble starts when I want to add other definitions. I believe you can keep adding group codes (must be a limit) say 1041, 1042 etc. As such, I have written the following code to attach additional extended data, but autocad returns a bad DXF group error.

    The original dxf list for the entity is:

    ((-1 . <Entity name: 1c9f748>) (0 . "POLYLINE") (5 . "C81") (102 .
    "{ACAD_REACTORS") (330 . <Entity name: 1c9f800>) (102 . "}") (330 . <Entity
    name: 1c9e0f8>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
    "Auto-Purlins") (62 . 4) (100 . "AcDbPolygonMesh") (66 . 1) (10 0.0 0.0 0.0)
    (70 . 16) (40 . 0.0) (41 . 0.0) (210 0.0 0.0 1.0) (71 . 2) (72 . 6) (73 . 0)
    (74 . 0) (75 . 0) (-3 ("SECTION_SIZE" (1000 . "C15024"))))

    I then substitute the list to include the additional data by:

    (regapp "SECTION_SIZE")
    (setq elist (entget (ssname pursel 0) (list "*")))
    (setq olddata (assoc -3 elist))
    (setq data (cdr (assoc -3 elist)))
    (setq unisize (cdr (nth 1 (car data))))

    (setq EXDATA1 (list "SECTION_SIZE"
    (cons '1000 unisize)
    (cons '1041 pdpflag) ;pdpflag is set to "test"
    ))
    (setq EXDATA1 (cons -3 (list EXDATA1)))
    (setq NEWENT (subst EXDATA1 olddata elist))

    Newent now returns:

    ((-1 . <Entity name: 1c9f748>) (0 . "POLYLINE") (5 . "C81") (102 .
    "{ACAD_REACTORS") (330 . <Entity name: 1c9f800>) (102 . "}") (330 . <Entity
    name: 1c9e0f8>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
    "Auto-Purlins") (62 . 4) (100 . "AcDbPolygonMesh") (66 . 1) (10 0.0 0.0 0.0)
    (70 . 16) (40 . 0.0) (41 . 0.0) (210 0.0 0.0 1.0) (71 . 2) (72 . 6) (73 . 0)
    (74 . 0) (75 . 0) (-3 ("SECTION_SIZE" (1000 . "C15024") (1041 . "test"))))

    When I try and update the entity:

    (entmod NEWENT)

    I get the following error:

    ; error: bad DXF group: (-3 ("SECTION_SIZE" (1000 . "C15024") (1041 . "test")))

    I really can't see what I'm doing wrong. If anyone has any thoughts they would be really appreciated.

    Thanks
    John
     
    iwafb, Mar 22, 2005
    #1
  2. iwafb

    Jürg Menzi Guest

    Hi John

    1041 requires a real value (distance), from help:

    String:
    1000. Strings in extended data can be up to 255 bytes long (with the 256th byte
    reserved for the null character).

    Application Name:
    1001 (also a string value). Application names can be up to 31 bytes long (the
    32nd byte is reserved for the null character) and must adhere to the rules for
    symbol table names (such as layer names). An application name can contain
    letters, digits, and the special characters $ (dollar sign), - (hyphen), and _
    (underscore). It cannot contain spaces.

    Layer Name:
    1003. Name of a layer associated with the xdata.

    Database Handle:
    1005. Handle of an entity in the drawing database.

    3D Point:
    1010. Three real values, contained in a point.

    Real:
    1040. A real value.

    Integer:
    1070. A 16-bit integer (signed or unsigned).

    Long :
    1071. A 32-bit signed (long) integer. If the value that appears in a 1071 group
    is a short integer or real value, it is converted to a long integer; if it is
    invalid (for example, a string), it is converted to a long zero (0L).
    Note: AutoLISP manages 1071 groups as real values. If you use entget to retrieve
    an entity's definition list that contains a 1071 group, the value is returned as
    a real, as shown in the following example:
    (1071 . 12.0)
    If you want to create a 1071 group in an entity with entmake or entmod, you can
    use either a real or an integer value, as shown in the following example:
    (entmake '((..... (1071 . 12) .... )))
    (entmake '((..... (1071 . 12.0) .... )))
    (entmake '((..... (1071 . 65537.0) .... )))
    (entmake '((..... (1071 . 65537) .... )))
    But AutoLISP still returns the group value as a real:
    (entmake '((..... (1071 . 65537) .... )))
    The preceding statement returns the following:
    (1071 . 65537.0)
    ObjectARX always manages 1071 groups as long integers.

    Several other extended data groups have special meanings in this context (if the
    application chooses to use them):

    Control String:
    1002. An xdata control string can be either "{" or "}". These braces enable the
    application to organize its data by subdividing it into lists. The left brace
    begins a list, and the right brace terminates the most recent list. Lists can be
    nested.
    Note: If a 1001 group appears within a list, it is treated as a string and does
    not begin a new application group.

    Binary Data:
    1004. Binary data that is organized into variable-length chunks, which can be
    handled in ObjectARX with the ads_binary structure. The maximum length of each
    chunk is 127 bytes.
    Note: AutoLISP cannot directly handle binary chunks, so the same precautions
    that apply to long (1071) groups apply to binary groups as well.

    World Space Position:
    1011. Unlike a simple 3D point, the WCS coordinates are moved, scaled, rotated,
    and mirrored along with the parent entity to which the extended data belongs.
    The WCS position is also stretched when the STRETCH command is applied to the
    parent entity and when this point lies within the select window.

    World Space Displacement:
    1012. A 3D point that is scaled, rotated, or mirrored along with the parent, but
    not stretched or moved.

    World Direction:
    1013. A 3D point that is rotated or mirrored along with the parent, but not
    scaled, stretched, or moved. The WCS direction is a normalized displacement that
    always has a unit length.

    Distance:
    1041. A real value that is scaled along with the parent entity.

    Scale Factor:
    1042. Also a real value that is scaled along with the parent.

    Cheers
     
    Jürg Menzi, Mar 22, 2005
    #2
  3. Great info Jürg.
    John, I sometimes use more than one Application Name to attach addition
    Xdata to entities.
    Alan
     
    Alan Henderson @ A'cad Solutions, Mar 22, 2005
    #3
  4. iwafb

    iwafb Guest

    Thanks Juerg,

    I was not aware of the restrictions. I was reading from a book and it did not explain the different group codes. Your explanation has been very helful.


    Dardo
     
    iwafb, Mar 22, 2005
    #4
  5. iwafb

    Jürg Menzi Guest

    Hi John/Dardo?

    Glad to help...¦-)

    But the flowers are not belong to me. I copied this informations from AutoLISP
    help. There are more usefull informations around Xdata:
    AutoLISP Developer's Guide -> Using the AutoLISP Language -> Extended Data --
    xdata

    Cheeras
     
    Jürg Menzi, Mar 23, 2005
    #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.