Alternative for dos_editbox?

Alternative for dos_editbox?

roland.r71
Collaborator Collaborator
1,438 Views
14 Replies
Message 1 of 15

Alternative for dos_editbox?

roland.r71
Collaborator
Collaborator

I'm almost done (re)creating my multifile tool, but I came up with one more addition to it.

 

In short: I'm creating a tool allowing users to select drawings in various ways for processing.

Currently user can select a lisp file to be loaded with each drawing. This alone allows users to do virtually anything to a selection of drawings.

 

However, as lisp's can be auto loaded with each drawing, or a lisp is not always required, running a single command (or an entire batch) might be enough in many cases.

 

For this I wish to add the option to add commands (to a script) and run that with each drawing. For the edit-box I'm currently using the DOSLIB dos-editbox function (see picture), as it's the only one I can find to do the trick.

 

dos_editboxdos_editbox

I read a fixed script file (used by the function), feed it's content to the dos-editbox and upon close (by pressing OK) the (new) content will be saved to that same script file.

 

However, it comes with a few drawbacks.

- There is no 'clear' option.

- I'm missing an Export.../Save as... button. Would be nice to be able to export it to a file.

- The Import button defaults to .txt files, with all files (*.*) as an extra option. I'd love to add .scr and .lsp to the files...

...but the editbox is fixed when it comes to all that.

 

Does anybody here know of any alternative, that will do the same (allowing to edit a multiline string in a window (containing script and/or lisp code)), including the above mentioned extra options? (one that does not require another .arx or add-on prefered)

 

I've done some searching, but can't find any. So I don't think there is an alternative (& I'll have to settle for what it is now), but I've been proven wrong before here Smiley Tongue

0 Likes
1,439 Views
14 Replies
Replies (14)
Message 2 of 15

doaiena
Collaborator
Collaborator

I know you said you don't want to add more *.arx files, but i would strongly suggest you take a look at OpenDCL. It's very flexible and allows for a wide range of functionality.

0 Likes
Message 3 of 15

roland.r71
Collaborator
Collaborator

Although I wouldn't mind personally, the idea is to share it, with who ever wants it, right here on the forum (& beyond)

 

It already depends heavily on DOSlib as a must have requirement, and I did my best to completely avoid using anything acetutil.arx.

 

So vanilla ACAD + DOSlib & your good to go for my tool. Adding another .arx requirement will only make it less accessible to other people.

0 Likes
Message 4 of 15

doaiena
Collaborator
Collaborator

Well, in that case i suppose you could give dos_htmldialog a try, but it's going to require a lot more work.

0 Likes
Message 5 of 15

roland.r71
Collaborator
Collaborator

@doaiena wrote:

Well, in that case i suppose you could give dos_htmldialog a try, but it's going to require a lot more work.


Yeah, I already thought about that one, for about 30sec.

Way to much & complicated for now. Maybe for a next version.

& as standard DCL won't cut it, afaik, I don't see many options for the moment. Just hoping I'm missing something.

0 Likes
Message 6 of 15

doaiena
Collaborator
Collaborator

If sharing to the community is the idea behind this project, i wouldn't mind helping out if i can. I have taken the liberty to prepare an OpenDCL dialog for you, even though you said you weren't interested in adding more dependencies. If not you, maybe someone else in the forum will make use of this code.

 

- All the files must be extracted to an AutoCAD Support File Search Path

- ScriptEditor.lsp is the ODCL dialog (it can be embedded in the lisp code if needed)

- Editor.lsp contains the code behind the dialog and an autoloader for the ODCL runtime (you can use the autoloader function as a template to load DOSLib if needed)

- All other files are related to OpenDCL

- The dialog should work on all versions of AutoCAD from 2007 up to 2018 (2019 not included)

- You said that DOSLib is part of this project, so i have made use of some DOSLib functions in my lisp

 

Here is a preview of the lisp:

(defun c:test ( / )

(if (LoadODCL)
(progn

;Import
(defun c:dcl_import_OnClicked ( / file text )
  (if (setq file (dos_getfiled "Select a file" "C:\\" "Lisp files (*.lsp)|*.lsp|Script files (*.scr)|*.scr|All files (*.*)|*.*||"))
  (progn
    (setq text (apply 'strcat (mapcar '(lambda (x) (strcat (if (equal x nil) "\r\n" x) "\r\n")) (dos_readtextfile file nil nil))))
    (dcl_Control_SetText dcl_textBox text)
  ))
)

;Export
(defun c:dcl_export_OnClicked (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:dcl_export_OnClicked" "To do")
)

;Clear
(defun c:dcl_clear_OnClicked (/)
  (dcl_Control_SetText dcl_textBox "")
)

;OK
(defun c:dcl_ok_OnClicked (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:dcl_ok_OnClicked" "To do")
  (dcl_Form_Close Form_Editor 1)
)

;Cancel
(defun c:dcl_cancel_OnClicked (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:dcl_cancel_OnClicked" "To do")
  (dcl_Form_Close Form_Editor 2)
)


(dcl_Project_Import (load "ScriptEditor.lsp"))
(dcl_Form_Show Form_Editor)
)
(alert "The proper OpenDCL runtime for your version of AutoCAD was not found.")
);if ODCL is loaded

(princ)
);defun



(defun LoadODCL ( / platform odcl )

(if (vl-string-search "(x64)" (getvar "platform"))
(setq platform ".x64")
(setq platform "")
)

(setq odcl (strcat "OpenDCL" platform "." (substr (getvar "acadver") 1 2) ".arx"))
(if (and (not (member odcl (arx))) (findfile odcl))
(progn
(arxload (vl-string-trim "." odcl))
(vl-arx-import odcl)
T
)
nil
)
);defun
Message 7 of 15

scot-65
Advisor
Advisor

I started something (DCL interface only) back in 2013 for someone else that had a similar inquiry:

 

EditList01.gif

 

I have since recreated the above in part for another program that I am currently developing.

However, at this time, the storage/retrieval parser of the list is not yet developed

(current thought is CSV in a INI or registry?)

 

???

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 8 of 15

roland.r71
Collaborator
Collaborator

That's exactly the same technique I'm currently implementing for my "filelist". Found some Lee Mac tutorials to do it 🙂

 

I'm using a regular textfile for the list. Much like a csv with only one column. My settings, or user preference, I store inside a ini file.

 

Works like a charm 😉

0 Likes
Message 9 of 15

DGRL
Advisor
Advisor

@roland.r71

 

Instead if using DOSLIB dos-editbox function why not making your own edit box?

It is not that hard to do in Visual lisp right?

Maybe i dont know enough about your program but for me it looks like you could make your own dcl edit box

 

 

If this was of any help please kudo and/or Accept as Solution
Kind Regards
0 Likes
Message 10 of 15

dlanorh
Advisor
Advisor

Take a look HERE

I am not one of the robots you're looking for

0 Likes
Message 11 of 15

roland.r71
Collaborator
Collaborator
Afaik, there is no DCL edit box which allows loading & editing (incl.
CTRL+C & CTRL+V) of a multiline text file (or .scr file in this case)

For a better understanding of what I need it for, you can check my "need
help testing ..." topic, where it is discussed in depth
0 Likes
Message 12 of 15

roland.r71
Collaborator
Collaborator

I did, but I get only a warning.

 

"The topic or board you are looking for appears to be either missing or off limits to you."

0 Likes
Message 13 of 15

dlanorh
Advisor
Advisor

listbuild pic.PNG

 

I'll assume you need to be a member to access the particular board at the Swamp. I've included the png so you can see if it is useful. Membership is free, you just need to register.

I am not one of the robots you're looking for

0 Likes
Message 14 of 15

roland.r71
Collaborator
Collaborator

Looks perfect for collecting info from blocks, but what I'm looking for is more like a multiline text editor. One where you could copy a piece of code from a script and paste it into the editor, move around the cursor, etc. as if your using notepad. It's very purpose being to enter a (short) script.

 

Using any kind of list type editing would make some of that impossible or at least extremely difficult, and brings a few problems of its own.

 

I'm using DOSlib extensively within the bigger function this is part off, so that's not the problem. The edit box used fits & performs quite nicely, but it lacks a few features.

 

Unless I am missing something, it would require a lot of complex coding to come close to what I want, using any list based editor. Such code might be out there, in which case I would gladely take look, but I'm inclined to settle for the lack in options instead of going on a mission impossible. (for me & my limited knowledge on visual lisp)

0 Likes
Message 15 of 15

dlanorh
Advisor
Advisor
OK. I don't use DOSlib so I can't help, but I'll keep my eyes open.

I am not one of the robots you're looking for

0 Likes