duke Posted May 4, 2024 Posted May 4, 2024 Hello friends !! I was wondering about XDATA, What is it for and how does it work within AUTO-LISP Because I don't know exactly if it works for what I'm thinking. Maybe you can create objects, for example: CIRCLES and internally assign each circle an internal data to each one, so that each and every one of the circles has a unique and unrepeatable and totally identifiable "NAME" Example: To join all the circles with a polyline, in a specific order, say from the circle called internally with a number 1 (ONE), to the circle number 5 (FIVE). Or XDATA is not used like that I put that as an example, but if it is used for other things, could you write me a small example code to understand how XDATA works, please Something very simple and small, you can And in advance, thank you very much ‼‼ Quote
Steven P Posted May 4, 2024 Posted May 4, 2024 XData is essentially an additional bit of information added to the entity definition, it doesn't change how the entity is shown on the screen. What you want to do can be done, and this link is a good description https://www.afralisp.net/autolisp/tutorials/extended-entity-data-part-1.php 1 Quote
duke Posted May 4, 2024 Author Posted May 4, 2024 8 hours ago, Steven P said: XData is essentially an additional bit of information added to the entity definition, it doesn't change how the entity is shown on the screen. What you want to do can be done, and this link is a good description https://www.afralisp.net/autolisp/tutorials/extended-entity-data-part-1.php Great !!! i am going to read Thanks bro ‼‼‼ Quote
BIGAL Posted May 5, 2024 Posted May 5, 2024 (edited) "Joining circles via creation order", using ssget can most times do this, try it, but as was posted somewhere else doing a sort on the "Handle ID" of the objects is creation order. I seem to remember must change to a number not hex. Quick and dirty (defun wow ( / ss x) (setq ss (ssget '((0 . "CIRCLE")))) (command "pline") (repeat (setq x (sslength ss)) (command (cdr (assoc 10 (entget (ssname ss (setq x (1- x))))))) ) (command "") ) (wow) Edited May 5, 2024 by BIGAL 1 Quote
duke Posted May 5, 2024 Author Posted May 5, 2024 (edited) 1 hour ago, BIGAL said: "Joining circles via creation order", using ssget can most times do this, try it, but as was posted somewhere else doing a sort on the "Handle ID" of the objects is creation order. I seem to remember must change to a number not hex. Quick and dirty (defun wow ( / ss x) (setq ss (ssget '((0 . "CIRCLE")))) (command "pline") (repeat (setq x (sslength ss)) (command (cdr (assoc 10 (entget (ssname ss (setq x (1- x))))))) ) (command "") ) (wow) ty BIGAL beauty example for creating a pline ‼‼‼‼‼ Edited May 5, 2024 by duke Quote
Jonathan Handojo Posted May 5, 2024 Posted May 5, 2024 (edited) There aren't really many applications in which you would use xdata. I can only imagine needing one when you create your own applications like you would with a dictionary, in which you would like the objects to behave and "react" differently in respond to several commands. Again, what do I know... Here is one example of one of my programs in which xdata is used. (I hardly ever use this because I hardly see its use, but I just created it as practice for myself. Hence, I stopped enhancing it.) Edit: Apologies for the complex example, I didn't read the OP that it was intended to be simple... ObjectPropertySync.lsp Edited May 6, 2024 by Jonathan Handojo 1 Quote
BIGAL Posted May 6, 2024 Posted May 6, 2024 A good tutorial and description about using XDATA. https://www.afralisp.net/autolisp/tutorials/extended-entity-data-part-1.php 1 Quote
АлексЮстасу Posted September 1, 2024 Posted September 1, 2024 XData are for additional non-graphical descriptive information (< 16K) that can be attached to objects. This information can be divided into two parts - for two different main tasks: 1. For programming purposes. As in your example with the numbers of circles defining the order in which they are connected. Or in Jonathan Handojo's ObjectPropertySync.lsp. Etc. AutoCAD itself uses XData for primitive's additional data - in Dimensions, Hatches, Viewports, and so on. 2. For users - to turn their graphical models into object models. In XData, you can define the names (or codes) of the real world entities (features) represented by your graphical primitives. For example, your circles can be defined as ‘fire hydrant’ or ‘storm well’, etc. And in XData, you can define characteristics (attributes, properties) of reality objects (features). For example, depth, material, belonging, purpose, etc. After that, it becomes possible to analyse the drawing as a model of reality and transfer such a model to information systems. To work with XData, we made a set of users tools - XDTOOLS. 1 Quote
АлексЮстасу Posted September 1, 2024 Posted September 1, 2024 On 5/6/2024 at 2:53 AM, Jonathan Handojo said: Here is one example of one of my programs in which xdata is used. I haven't understood anything yet, but the idea of linking object properties seems interesting in principle. Can you give me a very simple example of such a link? Quote
Jonathan Handojo Posted September 1, 2024 Posted September 1, 2024 (edited) 7 hours ago, АлексЮстасу said: I haven't understood anything yet, but the idea of linking object properties seems interesting in principle. Can you give me a very simple example of such a link? This isn't really the most user-friendly command or approach... like I mentioned before, this was only used for my practice because I hardly see its practical use. But this is more or less how it works. If you're keen to use it, I can look to make some adjustments and improvements to make it more user-friendly. For more proficient AutoLISP users, there are already sub-functions which can be called to initialise OS-ADD, OS-REM between any two objects and refreshing with OSYNC, allowing them to create their own custom commands and add them as they see fit. ObjectSync.mp4 Edited September 1, 2024 by Jonathan Handojo Quote
АлексЮстасу Posted September 2, 2024 Posted September 2, 2024 (edited) 1 hour ago, Jonathan Handojo said: But this is more or less how it works. The video made it clearer. Thank you! Need to think about what it might be useful for. Or similar to this... I've been interested in the topic of object linking in AutoCAD for a long time. We've done two experimental projects using XData for linkage information: XDLabel - to link inscriptions (Texts, MTexts, Leaders, MLeaders) to objects for which the inscriptions are needed, XDPoint - for linking point objects (Blocks, Circles, Lines, 3dSolids, Tables and Points) to the objects for which they are created. Can create inscriptions and point objects with the desired properties at the base objects. Can link existing inscriptions and point objects to the objects they belong to. Can restore the position, properties, and content of inscriptions and point objects relative to the underlying objects, or update the links. I am not at all sure that we have found the optimal solution. And we are doing it as amateurs, being completely inexperienced programmers. I'm not a programmer at all. But in principle, it works well enough. These projects are largely finishe, and I am now thinking how the theme of links could be continued. But with a practical use! Edited September 2, 2024 by АлексЮстасу Quote
Jonathan Handojo Posted September 2, 2024 Posted September 2, 2024 (edited) 2 hours ago, АлексЮстасу said: The video made it clearer. Thank you! Need to think about what it might be useful for. Or similar to this... I've been interested in the topic of object linking in AutoCAD for a long time. We've done two experimental projects using XData for linkage information: XDLabel - to link inscriptions (Texts, MTexts, Leaders, MLeaders) to objects for which the inscriptions are needed, XDPoint - for linking point objects (Blocks, Circles, Lines, 3dSolids, Tables and Points) to the objects for which they are created. Can create inscriptions and point objects with the desired properties at the base objects. Can link existing inscriptions and point objects to the objects they belong to. Can restore the position, properties, and content of inscriptions and point objects relative to the underlying objects, or update the links. I am not at all sure that we have found the optimal solution. And we are doing it as amateurs, being completely inexperienced programmers. I'm not a programmer at all. But in principle, it works well enough. These projects are largely finishe, and I am now thinking how the theme of links could be continued. But with a practical use! That's good on you. I normally can't think of any applications in which I would rely on xdata. Probably if you are literally trying to make an entirely new application, then you'd go about using it. In my case here, it's only between literally ANY two object properties which the AutoCAD FIELD can extract from any object... be it an insertion point, layer, text style, etc. so the ideas are boundless. What's more, the properties can be "chained" from one object that was previously linked, to another. My program enhances a little further, which would allow extracting and modifying: The X, Y and Z values of a 3d-point individually A table cell Block Attributes Edited September 2, 2024 by Jonathan Handojo Quote
Tsuky Posted September 3, 2024 Posted September 3, 2024 A concrete example of the use of XDATA For example, set up these entities by copying and pasting the following lines into a new command line drawing: (entmake '( (0 . "LINE") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbLine") (10 4.1142e+06 1.95551e+06 0.0) (11 4.11734e+06 1.9574e+06 0.0) (210 0.0 0.0 1.0) ) ) (entmake '( (0 . "CIRCLE") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbCircle") (10 4.11683e+06 1.95826e+06 0.0) (40 . 800.0) (210 0.0 0.0 1.0) ) ) Make an extended zoom and apply the following routine (it's in French, I didn't translate it for the example) Clothoide You get a simple polyline, but with this you will get the technical information that was used to build it. IdClo clothoide.lsp idclo.lsp Quote
Rakaryan Posted January 2 Posted January 2 On 9/2/2024 at 4:13 AM, АлексЮстасу said: The video made it clearer. Thank you! Need to think about what it might be useful for. Or similar to this... I've been interested in the topic of object linking in AutoCAD for a long time. We've done two experimental projects using XData for linkage information: XDLabel - to link inscriptions (Texts, MTexts, Leaders, MLeaders) to objects for which the inscriptions are needed, XDPoint - for linking point objects (Blocks, Circles, Lines, 3dSolids, Tables and Points) to the objects for which they are created. Can create inscriptions and point objects with the desired properties at the base objects. Can link existing inscriptions and point objects to the objects they belong to. Can restore the position, properties, and content of inscriptions and point objects relative to the underlying objects, or update the links. I am not at all sure that we have found the optimal solution. And we are doing it as amateurs, being completely inexperienced programmers. I'm not a programmer at all. But in principle, it works well enough. These projects are largely finishe, and I am now thinking how the theme of links could be continued. But with a practical use! I use Xdata when drawing a Clothoid for a Horizontal Alignment. The representation of a Clothoid (Spiral - Circle - Spiral. Spiral-Spiral) is drawn with a Polyline, so I need to save the Clothoid parameters into that Polyline. Here is as an example: (setq oldlist (entget elast)) (regapp "AcDb2dAHSClothoid") (setq curtype "SCS") ;; CURVE Type SCS/SC/CS/SS (setq thedata (list (list -3 (list "AcDb2dAHSClothoid" (cons 1000 curtype) ;; CURVE Type SCS/SC/CS/SS #1 (cons 1000 LR_turn) ;; Direction: Left/Right Turn #2 (cons 1040 v_renc) ;; Design Speed: V #3 (cons 1000 spe) ;; Superelevation #4 (cons 1040 Ls) ;; Ls in (meter) #5 (cons 1040 RC) ;; Rc (meter) #6 (cons 1040 LC) ;; Lc (meter) #7 (cons 1040 Ls) ;; Ls Out (meter) #8 (cons 1040 Alpha1) ;; Alpha1 (Radial) #9 (cons 1040 Alpha2) ;; Alpha2 (Radial) #10 (cons 1040 Delta_T) ;; Delta of 2 Tangencies (Radial) #11 (cons 1040 Delta_S) ;; Center Angle of Spiral (Radial) #12 (cons 1040 Delta_C) ;; Center Angle of Circle (radial) #13 (cons 1040 Tt) ;; Dist TS - PI (meter) #14 (cons 1040 Et) ;; Dist PI - MidChord (meter) #15 (cons 1010 pt_PI) ;; PI #16 (cons 1010 pt_TS) ;; PS #17 (cons 1010 pt_SC) ;; SC #18 (cons 1010 pt_CS) ;; CS #19 (cons 1010 pt_ST) ;; ST #20 (cons 1010 ctr_scs) ;; Center of Circle or 'Center' of SCS #21 ))) ) (setq newlist (append oldlist thedata)) ;; Modify List (entmod newlist) ;; Modify Entity ;;String 1000. A string of up to 255 characters. ;;Application Name 1001. An Application Name. ;;Layer Name 1003. The name of a Layer. ;;3D Point 1010. A 3D Coordinate value. Must be 3D ;;Real 1040. A real value. Must Be real. Otherwise U'll get wrong Value Quote
Recommended Posts
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.