Author Topic: Where's the OpenDCL documentation?  (Read 15974 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Where's the OpenDCL documentation?
« Reply #15 on: June 12, 2007, 02:20:51 AM »
.... and this was saved

(SETQ tmp (ODCL_WRITEBIN fnHandle (entget(car(entsel))'("ACAD")) ))

and read as ;


((-1 . <Entity name: 7efbc678>)
 (0 . "DIMENSION")
 (330 . <Entity name: 7efb7d18>)
 (5 . "B77")
 (100 . "AcDbEntity")
 (67 . 0)
 (410 . "Model")
 (8 . "ST-DIM")
 (100 . "AcDbDimension")
 (2 . "*D66")
 (10 773.851 4090.5 0.0)
 (11 573.384 4125.5 0.0)
 (12 0.0 0.0 0.0)
 (70 . 32)
 (1 . "")
 (71 . 5)
 (72 . 1)
 (41 . 1.0)
 (42 . 400.934)
 (73 . 0)
 (74 . 0)
 (75 . 0)
 (52 . 0.0)
 (53 . 0.0)
 (54 . 0.0)
 (51 . 0.0)
 (210 0.0 0.0 1.0)
 (3 . "STD35$0")
 (100 . "AcDbAlignedDimension")
 (13 372.917 3757.99 0.0)
 (14 773.851 3757.99 0.0)
 (15 0.0 0.0 0.0)
 (16 0.0 0.0 0.0)
 (40 . 0.0)
 (50 . 0.0)
 (100 . "AcDbRotatedDimension")
 (-3 ("ACAD" (1000 . "DSTYLE")
             (1002 . "{")
             (1070 . 40)
             (1040 . 10.0)
             (1070 . 179)
             (1070 . 1)
             (1002 . "}")
     )
 )
)
« Last Edit: June 12, 2007, 02:23:25 AM by Kerry Brown »
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8715
  • AKA Daniel
Re: Where's the OpenDCL documentation?
« Reply #16 on: June 12, 2007, 02:27:51 AM »
Thanks Kerry  :-)
I think I can fix the "reading twice crash"
 

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8715
  • AKA Daniel
Re: Where's the OpenDCL documentation?
« Reply #17 on: June 12, 2007, 03:32:48 AM »
here is another version  :-o
« Last Edit: June 12, 2007, 01:02:46 PM by Danielm103 »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Where's the OpenDCL documentation?
« Reply #18 on: June 12, 2007, 03:52:03 AM »
Thanks Dan,
I'm leaving to catch my train .. so I'll look tonight.
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Where's the OpenDCL documentation?
« Reply #19 on: June 12, 2007, 06:04:33 AM »
Works for me Dan !! 

Great Stuff. 

Can you send it to Owen please .. and become part of OpenDCL's history :-)

Michael may want to try to break it first though.


(SETQ fnHandle (ODCL_OPENBIN "c:\\testBinFile-1" "w"))
;;

(SETQ tmp (ODCL_WRITEBIN fnHandle nil (list nil) (cons nil nil)))
;;

(SETQ tmp (ODCL_CLOSEBIN fnHandle))

;; then read
;;=> (nil (nil) (nil))
« Last Edit: June 12, 2007, 06:05:36 AM by Kerry Brown »
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8715
  • AKA Daniel
Re: Where's the OpenDCL documentation?
« Reply #20 on: June 12, 2007, 01:00:50 PM »
This one seems to be pretty stable. One issue we should consider, is that importing a whole file into a single list has its limitations. I did a little performance testing, writing files is always extremely fast. Reading 10000 cons lists (cons 101 "1234567890" ) was pretty fast. Reading a 3 megabyte file will certainly fail. Personally I’m going to be working with small amounts of data, so this is perfect for me. But I can’t speak for all the ODCL users..
here is my latest version

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8715
  • AKA Daniel
Re: Where's the OpenDCL documentation?
« Reply #21 on: June 12, 2007, 11:03:40 PM »
I think I want to make one more modification.

(ODCL_READBIN fnHandle T) read the contents to a list
(ODCL_READBIN fnHandle ) read line by line as entered

Opinions?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Where's the OpenDCL documentation?
« Reply #22 on: June 12, 2007, 11:10:34 PM »
Daniel,
This will be VERY handy.
In the past I've saved values for dialogs an command line data input into a global association list .. and read the variable values whenever I called a new instance of the dialog.

The extended capability of WriteBIN and ReadBIN allows me to <in effect> serialize the dialog fields economically .. and reuse them tomorrow or nexr week or exchange them between users.  .. nice stuff.


PS the difference in file size between a debug version and release version is significant, yes !
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Where's the OpenDCL documentation?
« Reply #23 on: June 12, 2007, 11:14:56 PM »
I think I want to make one more modification.

(ODCL_READBIN fnHandle T) read the contents to a list
(ODCL_READBIN fnHandle ) read line by line as entered

Opinions?


Sounds like that may be usefull !

I'd use the T flag for line by line ... but I don't think it would matter .. either way would work provided we document it.
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.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Where's the OpenDCL documentation?
« Reply #24 on: June 13, 2007, 09:46:40 AM »
Very interesting discussion(s) but I must say I'm kinda vexed -- I had assumed with names like readbin, writebin etc. that these functions would allow me to read and write in full binary mode, so I could, for example, open a file and examine it byte for byte, or streams of bytes, not being tripped up by nulls or ascii z (eof trigger) etc.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8715
  • AKA Daniel
Re: Where's the OpenDCL documentation?
« Reply #25 on: June 13, 2007, 01:40:40 PM »
Very interesting discussion(s) but I must say I'm kinda vexed -- I had assumed with names like readbin, writebin etc. that these functions would allow me to read and write in full binary mode, so I could, for example, open a file and examine it byte for byte, or streams of bytes, not being tripped up by nulls or ascii z (eof trigger) etc.

You’re right, maybe the methods should have been called ReadArchive and WriteArchive.  Essentially it is reading writing in a binary stream format but it’s converting the data to and from types that lisp uses, or what can be put in a result buffer.
There really isn’t an EOF, so the code is writing both an EOL and an EOF marker, so the code knows where to stop and pass the result buffer back to lisp.

Is Reading and writing in a raw byte stream, a feature you would like to have included in ODCL?  Since we are using CArchive, we can use some of that class’s other methods see http://msdn2.microsoft.com/en-us/library/caz3zy5s(VS.80).aspx 

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Where's the OpenDCL documentation?
« Reply #26 on: June 14, 2007, 11:05:36 AM »
You’re right, maybe the methods should have been called ReadArchive and WriteArchive.  Essentially it is reading writing in a binary stream format but it’s converting the data to and from types that lisp uses, or what can be put in a result buffer.
There really isn’t an EOF, so the code is writing both an EOL and an EOF marker, so the code knows where to stop and pass the result buffer back to lisp.

Thanks for explaining the undercarriage Daniel.

Is Reading and writing in a raw byte stream, a feature you would like to have included in ODCL?

In a word yes, but don't front burner it merely for me. <Spock> The needs of the many outweigh the needs of the few -- or the one </Spock>.

Since we are using CArchive, we can use some of that class’s other methods see http://msdn2.microsoft.com/en-us/library/caz3zy5s(VS.80).aspx

I looked at said class and I don't think it would do what I'd want (tho I could be wrong). Essentially I'd like the ability to read and write binary data, probably as list of the ascii codes. While read-char will read a file a byte at a time (including nulls), it will stop on an false eof file marker (ascii 26). Worse, write-char won't let one write nulls, essential for binary I/O.

If one were to draft a quick signature for some of the functions (forgive me, I'm pounding this out real fast because I've only a few minutes) ...

(BinOpen filename "r" | "w" | "rw")

(setq handle (BinOpen "c:\\MyData.data" "rw")) ;; opened for read and write.

(BinGet handle address [length]) ;; optional length, if nil or not present read to true eof

(setq bigStream (BinGet handle 0)) ;; get entire file.

(BinPut handle address listOfAsciiCodes) ;; address is 0 based

(BinPut handle 0 (append '(0 87 111 111 116 33) bigStream)) ;; insert 6 new values to the beginning of the file, starting with a null value (0).

Hope this makes sense.



Like I said, this is just my own wish. Before tackling something like this it's probably advisable to poll the community and see if there's enough interest to warrant the efforts.

Thanks for your interest Daniel (and your most excellent efforts to support the OpenDCL community).

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8715
  • AKA Daniel
Re: Where's the OpenDCL documentation?
« Reply #27 on: June 19, 2007, 05:04:25 AM »
Ok, Try this one guys

Due to what I think might be a bug in AutoCAD, one should be careful of using doted pair lists that begin with a  DXF code.
Two buggy ones I have found are.

(odcl_writebin fnhandle (cons 5005 "Hello")); returns (“hello”)
(odcl_writebin fnhandle (cons 5001 "Hello")); returns junk

Other than that this is a really cool feature for archiving lisp data, entity lists, xdata

Changes:
(odcl_readbin fnhandle t) reads entry by entry
(odcl_readbin fnhandle ) reads everything
« Last Edit: June 21, 2007, 11:52:27 AM by Danielm103 »