Using Variables When Creating XDATA

Using Variables When Creating XDATA

mgorecki
Collaborator Collaborator
1,699 Views
6 Replies
Message 1 of 7

Using Variables When Creating XDATA

mgorecki
Collaborator
Collaborator

Hello,

I'm trying my hand at using XDATA.  I want to attach a variable text to a polyline.  The text value will change, it's not static.

 

I have seen examples where they use quoted strings for use in the entmod.

(setq exdata '((-3 ("PolyXdata" (1000 . "DETAILVIEW")))))

(setq newEnt (append selectedEnt exdata))

(entmod newEnt)

 

What I want to do is use a variable value in place of the quoted string.

(setq netNameXdata (cons 1000 xdataText))

(setq exdata '((-3 ("DocProXdata" netNameXdata))))

 

But that only gets me:

((-3 (CONS ("DocProXdata" NETNAMEXDATA))))

 

How can I use a variable value instead of a hard coded static string for this type of thing?

 

Thanks,

Mark

0 Likes
Accepted solutions (1)
1,700 Views
6 Replies
Replies (6)
Message 2 of 7

Ranjit_Singh
Advisor
Advisor
Accepted solution

Maybe start with something like below function

(defun somefunc (x y)
(entmod (append y (list (list -3 (list (if (tblsearch "appid" x) x (regapp x)) '(1000 . "DETAILVIEW")))))))

new_appname.gif

 Above is just a basic structure to pass variable appid name. The rest of the data can be a variable as well. I am using the extended data as a variable in the below function but it could be passed as an argument to the main function as well. You get the idea.

(defun somefunc (x y / netnamexdata xdatatext)
(setq xdatatext "DETAILVIEW" netNameXdata (cons 1000 xdataText)) (entmod (append y (list (list -3 (list (if (tblsearch "appid" x) x (regapp x)) netnamexdata))))))

 

0 Likes
Message 3 of 7

dgorsman
Consultant
Consultant

Expand on the XDATA you have as you would with LISP expressions, indenting with each consecutive open/close bracket.  Note the nested matching parenthesis after the single-quote/literal - it's constructing a list, "literally".  Use normal list-construction techniques with calls to (list ...) (cons ...) and so on to build the data in the same format.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 4 of 7

mgorecki
Collaborator
Collaborator

Hello Ranjit,

Thank you for that bit of code, it really helped me understand the sequence for the lists.

 

Best regards,

Mark

0 Likes
Message 5 of 7

mgorecki
Collaborator
Collaborator

Hello dgorsman,

Thank you for your input.  I had tried a number of ways to write it before, but your post helped me stop, break it down, and take a look at where to use the lists.

This is what I have now and it works great.  Thank you both. 

 

 ;Sets the variable exdata equal to the new extended data in this case, a text string.
 (setq netNameXdata (cons 1000 xdataText))
 (setq exdata (list (list -3 (list "DocProXdata" netNameXdata))))

 

Best regards,

Mark

0 Likes
Message 6 of 7

Ranjit_Singh
Advisor
Advisor

Don't forget that the piece of string (caadr (assoc -3 extendedentitydatalist)) needs to be a registered app. I will add the (tblsearch "appid" variablename) to your piece of code.

0 Likes
Message 7 of 7

mgorecki
Collaborator
Collaborator

I had already registered "DocProXdata" as the app.

0 Likes