Author Topic: add XDATA on simple rectangle  (Read 2930 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
add XDATA on simple rectangle
« on: December 01, 2006, 02:57:21 PM »
Hi all..

i'm trying to add an information on simple rectangle...

Code: [Select]
(setq i1 (entget (car (entsel))))
(setq idata (list (list -3 (list "test1"
            (cons 1000 "test2")
            )
)))
(setq i1 (append i1 idata))
(entmod i1)

this seem to work.....but not true...
because if i re-select the same rectangle buy using...

Code: [Select]
(setq i1 (entget (car (entsel))))
it return me all the data without the new XDATA added...

seem that entmod is not working...

do i'm right ?
Keep smile...

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: add XDATA on simple rectangle
« Reply #1 on: December 01, 2006, 03:45:59 PM »
Try this to get the XDATA:
Code: [Select]
(setq i1 (entget (car (entsel)) '("*")))

Patrick_35

  • Guest
Re: add XDATA on simple rectangle
« Reply #2 on: December 01, 2006, 04:34:37 PM »
Why you don't use Vla-SetXData Mon_Rectangle

SetXData (XDataType, XDataValue)

@+

Andrea

  • Water Moccasin
  • Posts: 2372
Re: add XDATA on simple rectangle
« Reply #3 on: December 01, 2006, 10:01:48 PM »
Thanks PAT...

but,.....can you give me an example ?


Thanks Jeff....but what "*" mean ?  search all Xdata for the selected item ?
Keep smile...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: add XDATA on simple rectangle
« Reply #4 on: December 02, 2006, 12:51:46 AM »
get the dxf xdate straight in your head before you venture into the ActiveX version ..

In Jeff's code the '("*") represents return ALL Xdata Application Names

in your case you could use
(setq i1 (entget (car (entsel)) '("test1")))
since "test1" was your xdata APPName

Have a play with something like these to learn ...
Code: [Select]
(defun put-xdata (appName Data / elst exdata)
   ;; codehimbelonga kwb@theSwamp
    (regapp appName)
    (setq elst   (entget (car (entsel "\nSelect graphical entity: ")))
          exdata (list (list -3 (cons appName Data)))
          elst   (append elst exdata)
    )
    (entmod elst)
)

Code: [Select]
(defun c:put-xdata1 (/ )
   ;; codehimbelonga kwb@theSwamp
    (setq entityList (put-xdata "TEST-APPLICATION-NAME" (list (cons 1000 "Test Data"))))
)
Code: [Select]
(defun c:put-xdata2 (/ )
   ;; codehimbelonga kwb@theSwamp
    (setq entityList (put-xdata "TEST-APPLICATION-NAME" (list (cons 1070 2))))
)
Code: [Select]
(defun c:put-xdata3 (/ )
   ;; codehimbelonga kwb@theSwamp
    (setq entityList (put-xdata "TEST-APPLICATION-NAME"
                                (list
                                      (cons 1000 "DataList3")
                                      (cons 1002  "{")
                                      (cons 1070 3)
                                      (cons 1000 "Test String 3")
                                      (cons 1002  "}")
                                     
                                )
                     )
    )
)
Code: [Select]
(defun c:put-xdata4 (/)
   ;; codehimbelonga kwb@theSwamp
    (setq entityList (put-xdata "TEST-APPLICATION-NAME"
                                (list
                                      (cons 1000 "DataList4")
                                      (cons 1002  "{")
                                      (cons 1070 4)
                                      (cons 1000 "Test String 4 ")
                                      (cons 1002  "}")
                                     
                                     (cons 1000 "DataList4a")
                                      (cons 1002  "{")
                                      (cons 1070 44)
                                      (cons 1000 "Test String 4a")
                                      (cons 1002  "}")                                     
                                )
                     )
    )
)


Code: [Select]
(defun get-xdata (appName / myData)
   ;; codehimbelonga kwb@theSwamp
    (setq myData
             (cadr
                 (assoc
                     -3
                     (entget
                         (car
                             (entsel
                                 "\nSelect graphical entity to extract Data : "
                             )
                         )
                         (list appName )
                     )
                 )
             )
    )
    myData
)

Code: [Select]
(defun c:get-xdata (/ )
    (setq entityData (get-xdata "TEST-APPLICATION-NAME" ))
)
(defun c:get-ACADxdata (/ )
    ;; for dimensions, etc
    (setq entityData (get-xdata "ACAD" ))
)
(defun c:get-ALLxdata (/ )
    (setq entityData (get-xdata "*" ))
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Patrick_35

  • Guest
Re: add XDATA on simple rectangle
« Reply #5 on: December 02, 2006, 03:52:33 PM »
Quote
but,.....can you give me an example ?

You have an answer here

@+

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: add XDATA on simple rectangle
« Reply #6 on: December 06, 2006, 05:36:12 AM »
And once you've assimilated the posts above, Have a look here ...

http://www.theswamp.org/index.php?topic=4395.msg53028#msg53028
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: add XDATA on simple rectangle
« Reply #7 on: December 06, 2006, 02:00:34 PM »
Thanks guys,,,, :-)
Keep smile...