Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Adding modify data to dxf code

  1. #11
    100 Club
    Join Date
    2003-06
    Location
    North Dallas
    Posts
    163

    Default Re: Adding modify data to dxf code

    Quote Originally Posted by dgorsman View Post
    Not that I know of, directly anyways. XDATA and XRECORDs do just that, but handle the interfacing for you. Have a couple of read-throughs in the LISP help on both types, its laid out well.
    I read through the XDATA and XRECORDS but couldn't really see where it was attaching additional data to an entity. I would use a group code -3 for xdata and then use 1001 and so one for the data I want to add? When I read XRECORD it just seems like a dictionary addition and I'm not sure how that is added to an entity. This stuff is just going over my head. I'll just go back through help and reread until I get it. Thanks for the help.

  2. #12
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2007-07
    Location
    Jo'burg SA
    Posts
    4,348

    Default Re: Adding modify data to dxf code

    I'm only going to show the "normal" lisp way ... not the ActiveX methods. In some cases the ActiveX may be a bit simpler though, but you can swot-up on that on your own

    XData

    Basically if you go the older XData route, you can do the following. Add a new list item starting with -3 containing a sub-list:
    Code:
    '(-3 ("YourAppName" ;Change to whatever you want to identify your data to - not longer than 31 characters
          (1000 . "Any string value")
          (1002 . {") ;Start a nested list
          (1005 . "34E567") ;A handle link to another entity, automatically updated if changed
          (1005 . "34A876") ;A handle link to another entity, automatically  updated if changed
          (1005 . "34B234") ;A handle link to another entity, automatically  updated if changed
          (1002 . "}) ;End the nested list
          (1010 . 100.0) ;X value in floating point "real"
          (1020 . 100.0) ;Y value in floating point "real"
          (1030 . 100.0) ;Z value in floating point "real"
          (1040 . 12345.67) ;An arbitrary real number
          (1041 . 123.45) ;A real number "distance" which gets mutiplied by the factor to which the host entity is scaled
    ))
    You need to register the name you've decided on by issuing (regapp "YourAppName") after ensuring that it's not already registered by using (tblsearch "APPID" "YourAppName").

    After adding it to the entity data list (as obtained from entget), simply do an entmod and your data is saved to the entity.To see all the various XData group types look in the Dev help (DXF Reference > Advanced DXF Issues > Extended Data).

    To later retrieve your data you need to tell entget that you also want the XData list(s). You do this by adding the optional application names list. So, assuming the ename of the entity is saved in variable ename:
    Code:
    (setq edata (entget ename '("YourAppName")))
    Then you get the (assoc -3 edata). Inside which is(are) a sublist(s) starting with YourAppName, followed by whatever data you added to it.

    XRecord
    XRecords are "slightly" simpler. You create a new XRecord (see the Developer Help: DXF Reference > OBJECTS Section > XRECORD) object by using the entmakex (instead of entmake) so you first make a non-visual entity of (0 . "XRECORD") type, which is not (yet) owned by anything. Then you attach it to the entity, assume ename is the entity name of the host entity and xname the entity name obtained from entmakex:
    Code:
    (dictadd ename "YourDictionaryName" xname)
    Then to obtain the XRecord entity you use:
    Code:
    (setq xlist (dictsearch ename "YourDictionaryName"))
    LData
    As alanjt's hinted at, this is not "really" recommended, there's some issues with sharing LData to other customization languages ... in particular VBA. However, this is probably the simplest way to get what you want.

    To save any value(s) which is inside a variable to an entity you use:
    Code:
    (vlax-ldata-put ename "YourKeyName" data)
    To retrieve the data:
    Code:
    (setq data (vlax-ldata-get ename "YourKeyName"))
    data can contain any lisp value from t(true) or nil(false) through to a list of values.

    Basically LData just generates dictionary objects and link this through XRecords to the entity(ies). Unfortunately the way it does so makes it not so easy for other API's to work with the data. So if you ever decide to change to another API (e.g. DotNet) it may be a good idea to rather go with XData/XRecord directly.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  3. #13
    100 Club
    Join Date
    2003-06
    Location
    North Dallas
    Posts
    163

    Default Re: Adding modify data to dxf code

    Irneb,
    Thank you so much for that info. That really helped out. XData is much much clearer to me. And in my way of thinking, makes the most sense for in this particular situation. I really appreciate you taking the time to explain the difference and show the use. I'm sure it'll be just as helpful to others. Thank you, thank you, thank you.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Adding code generated entities to a selection set
    By lambwill in forum Dot Net API
    Replies: 3
    Last Post: 2010-08-19, 05:51 AM
  2. Replies: 2
    Last Post: 2009-02-10, 01:25 PM
  3. Courtesy, adding comments to code
    By artisteroi in forum VBA/COM Interop
    Replies: 8
    Last Post: 2007-05-25, 01:56 AM
  4. Modify deployment (by adding Service Pack 1)
    By jgratton in forum CAD Management - General
    Replies: 11
    Last Post: 2005-12-09, 02:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •