Jump to content

Recommended Posts

Posted

Hello

I have a data structure as described in XData:

 

* Registered Application Name: LINK_POLIG

* Code 1002, Starting or ending brace: {

* Code 1000, ASCII string: EDITED

* Code 1002, Starting or ending brace:}

 

* Registered Application Name: LINK_VERT

* Code 1002, Starting or ending brace: {

* Code 1005, Database handle: F4D

* Code 1005, Database handle: F3E

* Code 1005, Database handle: EAE

* Code 1005, Database handle: F43

* Code 1005, Database handle: F48

* Code 1002, Starting or ending brace:}

 

* Registered Application Name: LINK_CENT

* Code 1002, Starting or ending brace: {

* Code 1005, Database handle: 31DA

* Code 1002, Starting or ending brace:}

 

* Registered Application Name: LINK_LIN

* Code 1002, Starting or ending brace: {

* Code 1005, Database handle: 3B1E

* Code 1005, Database handle: 3B21

* Code 1005, Database handle: 3B24

* Code 1005, Database handle: 3B27

* Code 1005, Database handle: 3B2A

* Code 1002, Starting or ending brace:}

 

This structure is defined for each block that defines a polygon (centroid) so the block have all the information of polygon. By limiting 16kb'm having trouble too large polygons, how do I build a structure in XRECORD to record the same information? The XRECORD updates the handles bound by the code 1005 in the same way as in the case of integration XDAT file?

 

Thanks

Posted

Well, as in another post already explained. XRecords don't mind what goes where really. And no they don't update handles automatically like in XData. I'd actually advise you to stick with XData unless you've got some other reason to go for XRecords.

 

Anyhow, you create an unattached XRecord entity. The only DXF codes which are always used is -1, 5, 0 and 100 (I didn't check what is necessary after 100). The types are in groups, e.g. from 1-9 are strings, 10-19 are 3d points:

(setq XRec (list '(0 . "XRECORD")
                '(100 . "AcDbXrecord")

                '(1 . "Any text value") ;Maximum of 250 charcters
                '(2 . "Any text value")
                 '(3 . "Any text value") ;Repeat code 3 as many times as you want
                ;; ...
                '(8 . "Any text value")
                '(9 . "Any text value")

                '(10 5.7 3.4 8.9) ;3d point
                '(11 5.7 3.4 8.9)
                '(12 5.7 3.4 8.9)
                ;; ...
                '(19 5.7 3.4 8.9)

                '(20 . 1) ;Real or integer
                '(21 . 1.0)
                ;; ...
                '(59 . 1.0)

                '(60 . 1) ;Integer only
                ;; ...
                '(99 . 0)
               )
)
(setq XRecEName (entmakex XRec))

Do your own testing, the entmakex will fail and give nil if you're trying to apply the wrong type to a code.

 

Next you attach it to the entity's dictionary. Say the entity's ename is stored in ent:

(setq dict (vlax-vla-object->ename (vla-GetExtensionDictionary (vlax-ename->vla-object ent))))
(dictadd dict "LINK_POLIG" XRecEName)

I'm using the AxtiveX GetExtensionDictionary method, since it's a lot less hassles. Otherwise you first need to check if the entity already has an extension dictionary - by checking if it's got a (360 . ) item directly following a (102 . "{ACAD_XDICTIONARY") item. If not you then have to entmakex a '((0 . "DICTIONARY") (100 . "AcDbDictionary)). Then link that to the entity ... aaaagggghhh I'm getting fed up already

 

Anyhow ... Now to get hold of that xrecord:

(setq dict (vlax-vla-object->ename (vla-GetExtensionDictionary (vlax-ename->vla-object ent))))
(setq xrec (dictsearch dict "LINK_POLIG"))

 

However, I don't like the immense amount of coding you need to perform to get this. I prefer just using the built-in ldata functions:

(vlax-ldata-put ent "LINK_VERT" '("Any lisp value you can think of" 1 3000000 3453.0 (23.5 6.7 8.9)))

And then to list all the ldata of an entity:

(setq datalist (vlax-ldata-list ent))

This returns an association list so you can use assoc to get the item associated to "LINK_VERT".

(setq yourdata (cdr (assoc "LINK_VERT" datalist)))

Or you can use:

(setq yourdata (vlax-ldata-get ent "LINK_VERT"))

And then to erase the data:

(vlax-ldata-delete ent "LINK_VERT")

The ldata basically does the same thing for you, just uses a VLO-VL entity instead of a XRecord entity. It's just a lot more automatic and less coding.

 

But as explained, neither way would have the "automatic" handle updates as you get with XData. If you need those (or the auto scaling, and point updates), then stick with XData - which IMO is easier to use than XRecords.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...