Scientific notation in entity handles

Scientific notation in entity handles

Anonymous
Not applicable
1,428 Views
7 Replies
Message 1 of 8

Scientific notation in entity handles

Anonymous
Not applicable

Hi.

 

This question exists on the forums https://forums.autodesk.com/t5/vba/handles-getting-modified-when-put-in-excel/m-p/1865322#M79968
which details the problem with hex handles being exported and converted to scientific notation.

My problem is not exporting to excel, but directly in autocad.

 

(vl-prin1-to-string 124E4)
(vl-princ-to-string 124E4)

 

I store a structure on a DXF record in an xdictionary on an entity.
These structures have an entity handle reference.

The structure is a list, or list of lists that are stored as a string in the record, and (read) back into the lisp runtime to be manipulated and then stored back as a string.

I have to do a (vl-prin*) to put the structure into a string and be able to read it back.

My question is: can I set the lisp reader to ignore that conversion for the function in question?

Do I even have access to the lisp reader in autolisp?

 

Thnaks

0 Likes
Accepted solutions (1)
1,429 Views
7 Replies
Replies (7)
Message 2 of 8

Sea-Haven
Mentor
Mentor

1st hex is 2 characters 124E4 is only 5 not 6 ? If you export as "ABAEE4" in csv file will work you need to make the string a double "\"ABAEE4\"" so it appears as a string.

Message 3 of 8

Anonymous
Not applicable

Thanks for the reply; but the problem is a little more fundamental than that.

(setq A '(1 "just" "a" "list" "124E4") ;; even "12E44" and so forth
      A1 (cons 1 (vl-princ-to-string A))
      A2 (read (cdr A1)))

 A2 now holds a converted SN symbol.

 

If I was to build the stringify and read functions using (vl-prin1-to-string), the read back structure breaks in interesting ways since the prin1 function is compatible with (load) function, and not (read) function.
I have discovered why prin1 is not useful, but call me stumped if I could find the reason in the reams of code I have. It just breaks something even more important.

 

My last resort is handling entity handles differently, as you suggest, breaking the notational representation by maybe replacing 'E' with '-' in those string handles passing through the structure handler functions.

But come on, do I not have access to the reader?

0 Likes
Message 4 of 8

Sea-Haven
Mentor
Mentor

(handent handle)

0 Likes
Message 5 of 8

hak_vz
Advisor
Advisor
Accepted solution
(setq 
	A (list 1 "just" "a" "list" (strcat "\"" "124E4" "\""))
	A1 (cons 1 (vl-princ-to-string A))
	A2 (read (cdr A1))
)
A --> (1 "just" "a" "list" "\"124E4\"")
A1 --> (1 . "(1 just a list \"124E4\")")
A2 --> (1 JUST A LIST "124E4")

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 6 of 8

Anonymous
Not applicable

Thank you.

0 Likes
Message 7 of 8

hak_vz
Advisor
Advisor

Not a problem. I hope you understand how it works.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 8 of 8

Anonymous
Not applicable

Oh yes, quoting the contents of the string redirects the reader to dump a string, not a symbol it believes is a representation of scientific notation.
I missed that obvious nugget.