Jump to content

Recommended Posts

Posted

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 ‼‼

Posted (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)

 

image.png.9b939f0fa886bacc09a87e51432d59ea.png

Edited by BIGAL
  • Like 1
Posted (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)

 

image.png.9b939f0fa886bacc09a87e51432d59ea.png

ty BIGAL
beauty example for creating a pline 👌👌👌👌👌👌👌‼‼‼‼‼

Edited by duke
Posted (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 by Jonathan Handojo
  • Like 1
  • 3 months later...
Posted

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.

  • Like 1
Posted
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?

Posted (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. 

Edited by Jonathan Handojo
Posted (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 by АлексЮстасу
Posted (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 by Jonathan Handojo
Posted

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

  • 3 months later...
Posted
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

 

 

image.thumb.png.200075f2a4de5fade29e0e2073ab3897.png

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...