OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Cornelis on September 25, 2015, 01:29:35 PM

Title: Total Newby
Post by: Cornelis on September 25, 2015, 01:29:35 PM
Hello OpenDCL Forum.

I am Cornelis and in my 50 Years never joined any forum, so please bear with me Normally I only read a lot of them.

Hope I will not do any stupid things.

I am new to OpenDCL but not new to Autocad, I am here to get some help with the following.

I wrote a little lisp program and wanted a new and good looking Interface witch stays on top and is drag able round the screen to place it out of the way.

If I understood it wright, I need a modeless form, for interaction with AutoCAD while the form stays on top or open

Standard DCL boxes are made to dis a peer and then interact with Autocad

I have a demo project where I can start by a click on a button a lisp like

(command "line" pause)              ;form stays open

But if I push another button on my form while the original command is still waiting for user input. I want the new chosen command to cancel the running command and start the new one like:

(command "circle" pause)

So the user don’t have to enter Escape Escape to cancel
I managed at first by setting 

(dcl-Control-SetEventInvoke AD_Form1 1)
(dcl-Control-SetEventInvoke AD_Form1_TreeC1 1)

And I tried this, both worked
(dcl-Invoke "c:lispCircle")
(dcl-SendString "(c:lispCircle)" )

in the first test it worked superb in a treeview flawlessly, so I started programming the UI but I can’t get it to work with immagebuttons.

And if I change for example a click or any other  event of the treeview and save the project then it doesn’t work that way anymore. The it says “Point or option keyword required.”

And that is the way Autolisp is supposed to work saying cant re-enter autolisp

I do provide 2 exactly the same sample project to clarify.

Sorry for my bad English.

Thanks in advance

Regards

Cornelis









   
Title: Re: Total Newby
Post by: roy_043 on September 25, 2015, 03:25:42 PM
You have not include the NotOke3.odcl file.

1.
I don't understand the problem you have with image buttons. But you should check if their event invoke property is set to asynchronous.
2.
To cancel running commands you can try this:
Code (autolisp) Select
(progn (dcl-sendstring (strcat (chr 27) (chr 27) "circle ")) (princ))
See discussion here: http://www.opendcl.com/forum/index.php?topic=2280.msg11475#msg11475.
3.
When you update the caption with "Done with circle" etc. The command is actually still running.
4.
In the Lisp files you refer to a problem with event names after saving the .odcl file under a new name. There is a tool to reset event names: Menu > Tools > Reset Event Names.
Title: Re: Total Newby
Post by: roy_043 on September 26, 2015, 03:30:08 AM
...
5.
The form does not have a title bar and initially I did not know how to move it around on screen. Other users may be confused as well.
6.
In the code to handle the tree you supply image indices. But the tree control does not have an image list.
7.
You are using both the old and the new ODCL naming scheme. In new projects I would use only the new scheme.

Attached are two new files. Note: I have removed the (big) images from the .odcl file.
Title: Re: Total Newby
Post by: Cornelis on September 26, 2015, 07:51:34 AM
Hi Roy

Thank you for your reply's and editing my files

1) I dont have the time to test your files right know but will come back to you on Teuasday.

2) I tried every thing, but I will try this also.

3) this is just to check what is happening

4) I am glad you explained

"There is a tool to reset event names: Menu > Tools > Reset Event Names."

Nice such a tool ;-)

5)Sorry This is just a demo to explain my problem no actual users here, but thanks
6)Thanks I copied a piece of code from the examples, didn't know the exact meaning of the numbers
7)Did not know how to change them but with your point 4 i will try

How did you removed the images, i couldnt find them in the RAD (OpenDCL or the program you edit the dialogs with)  anymore?


Have a nice weekend

Cornelis

Title: Re: Total Newby
Post by: roy_043 on September 26, 2015, 08:19:53 AM
...
Ad. 7.
I have not explained sufficiently. Recently the ODCL naming scheme was revised.
See: http://www.opendcl.com/forum/index.php?topic=2084.0
In your code you are mixing old and new names.

Example 1:
Code (autolisp) Select
(dcl-Control-SetEventInvoke AD_Form1 1)
dcl-Control-SetEventInvoke = NEW
AD_Form1 = OLD

Example 2:
Code (autolisp) Select
(dcl_Tree_AddParent AD/Form1/TreeC1  "Houtafscheider" 10 -1 10))
dcl_Tree_AddParent = OLD
AD/Form1/TreeC1 = NEW
Title: Re: Total Newby
Post by: Cornelis on September 29, 2015, 03:21:48 AM
Hi Roy, I looked at your edited file.

I changed it a little to reproduce the problem I have and renamed them to Roy.lsp and Roy.odcl.

What I want: I need to get points distances and user input etc. and then execute my piece of lisp code to insert blocks explode them and do things with them. Other commands lets user select items lets user select points and I move and copy them etc. etc.
This is the problem point: But while still getting this user input I want the user to make a different choice, so cancel what he is doing and execute the other new chosen command not by ESCAPE ESCAPE but thus bij pushing another button or treeview choice on the form.

Why? “Because all Autocad works that way”.

I simplified the problem by only using (Getpoint "And then the specific question") 

This happens In your files: Roy.lsp and Roy.odcl 
(These are your Edited Oke3 files with I downloaded and modified the commands in to get the problem clear.)
When I Click in the Treeview (Roy.odcl) on DrawCircle and do not pick a point but click on DrawLine in the Treeview, it says:

Can't reenter LISP.
Invalid point.

This is standard AutoCAD behaviour you can’t answer a lisp user input by another piece of lisp.
So  (chr 27) won't work here. (Just type (getpoint) and try to cancel that by lisp)

But somehow in my files: Oke3.lsp and Oke3.dcl
Witch I Modified to execute the exact same commands as I placed in your Roy.lsp and Roy.odcl

1) When I Click in the Treeview  (from Oke3.dcl ) on DrawCircle and do not pick a point but click on DrawLine in the Treeview, it just executes the new chosen command (DrawLine) just fine.

I reached this behaviour(1) by accident, just fooling around a few weeks ago, it even works without the (chr 27) (chr 27).
But this is exact the way I like my dialog to perform but I cannot get other elements to work this way.

So I am aware that my oke3.lisp code is not changed according to your comments. But this lisp file is doing exactly what I want in the treeview but not in the Image buttons. (If I change it to much the behaviour(1) is gone)

So my question is can you tell me how to get this behaviour in the files you edited so nice both in the treeview and Image Buttons.

I really hope you I explained it this time well enough and that the examples are clear.

Note that these Oke3 Files are new versions.

Regards Cornelis







Title: Re: Total Newby
Post by: roy_043 on September 29, 2015, 04:48:35 AM
If I load your last Oke3 project and click items in the tree view, Lisp code that was previously sent to the CAD program is indeed cancelled. But I don't know why this works. There is something strange going on.

While analysing the project I changed 3 things:
1. Reset the event names in the .odcl file.
2. Removed "(chr 27) (chr 27) " in the .lsp file (4x).
3. Replaced "PicTest" with "Oke3" in the .lsp file (6x).
After this set of changes, which I think should not alter the functionality of the project in any way, the 'automagic' cancel effect is gone!

Maybe Owen can look into this.
Title: Re: Total Newby
Post by: Cornelis on September 29, 2015, 05:06:54 AM
1) After this set of changes, which I think should not alter the functionality of the project in any way, the 'automagic' cancel effect is gone!

Thanks Roy, thats why I didn't change all that.

I hope you understand that I am looking for that Automatic Cancel Effect, it is awesom.

Do i have to do something to let Owen Look at this?
Title: Re: Total Newby
Post by: roy_043 on September 29, 2015, 05:07:32 AM
Cornelis, I don't think you are completely right when you say:
Quote from: Cornelis on September 29, 2015, 03:21:48 AM
This is standard AutoCAD behaviour you can’t answer a lisp user input by another piece of lisp.
I can't be sure because I use BricsCAD instead of AutoCAD.

Two examples that work in BricsCAD:

Example 1:
: (setq pt (getpoint "\nPoint please: "))
Point please: (list 1.1 2.2 3.3)
(1.1 2.2 3.3)
Point please: (1.1 2.2 3.3)
: !pt
(1.1 2.2 3.3)


Example 2:
: (setq i (getint "\nInteger please: "))
Integer please: (* 2 3)
6
Integer please: 66
: !i
6
Title: Re: Total Newby
Post by: Cornelis on September 29, 2015, 05:11:02 AM
Might be Roy, but that is from the command line I gues?
Title: Re: Total Newby
Post by: Cornelis on September 29, 2015, 05:15:35 AM
Autocad 2014 :

(setq i (getint "\nInteger please: "))

Integer please: !i
Can't reenter LISP.

Requires an integer value.



Command: (setq pt (getpoint "\nPoint please: "))

Point please: !pt

Can't reenter LISP.
Invalid point.

Maybe a setting? But this ia also what I red on the net.
Title: Re: Total Newby
Post by: roy_043 on September 29, 2015, 05:19:36 AM
Quote from: Cornelis on September 29, 2015, 05:15:35 AM
Autocad 2014 :

(setq i (getint "\nInteger please: "))

Integer please: !i
Can't reenter LISP.

Requires an integer value.



Command: (setq pt (getpoint "\nPoint please: "))

Point please: !pt

Can't reenter LISP.
Invalid point.

Maybe a setting? But this ia also what I red on the net.
You are not following my example.
Title: Re: Total Newby
Post by: Cornelis on September 29, 2015, 05:21:02 AM
to be complete

Command: (setq i (getint "\nInteger please: "))
Integer please: 6
6
Command: (setq i (getint "\nInteger please: "))
Integer please: !i
Can't reenter LISP.
Requires an integer value.


and

Command: (setq pt (getpoint "\nPoint please: "))
Point please: (16.7359 7.10615 0.0)
Command: (setq pt (getpoint "\nPoint please: "))
Point please: !pt
Can't reenter LISP.
Title: Re: Total Newby
Post by: Cornelis on September 29, 2015, 05:22:08 AM
Sorry reading is difficult, try that.
Title: Re: Total Newby
Post by: Cornelis on September 29, 2015, 05:24:42 AM
Command: (setq pt (getpoint "\nPoint please: "))
Point please: (list 1.1 2.2 3.3)
Can't reenter LISP.
Invalid point.
Title: Re: Total Newby
Post by: roy_043 on September 29, 2015, 05:30:02 AM
Quote from: Cornelis on September 29, 2015, 05:24:42 AM
Command: (setq pt (getpoint "\nPoint please: "))
Point please: (list 1.1 2.2 3.3)
Can't reenter LISP.
Invalid point.
Maybe you have to change the TEXTEVAL variable in AutoCAD or this, indeed, does not work in AutoCAD. As I said I use BricsCAD.
Title: Re: Total Newby
Post by: roy_043 on September 29, 2015, 05:31:34 AM
Finally, Cornelis, you interpretation of my 'escape' example is not correct.

My suggestion:
Code (autolisp) Select
(dcl-SendString (strcat (chr 27) (chr 27) "_ellipse "))
Your code:
Code (autolisp) Select
(dcl-SendString "(chr 27) (chr 27) (setq p1 (getpoint \"Getpoint (Ellipse)\")) ")

I have used (strcat) for a reason. My code sends 2 escape characters your code does not.

Your code should be:
Code (autolisp) Select
(dcl-SendString (strcat (chr 27) (chr 27) "(setq p1 (getpoint \"Getpoint (Ellipse)\")) "))
This works in BricsCAD, and judging by the discussion I have previously linked to, should also work in AutoCAD.
Title: Re: Total Newby
Post by: Cornelis on September 29, 2015, 05:45:23 AM
Enter new value for TEXTEVAL <0>: 1
Command: (setq pt (getpoint "\nPoint please: "))
Point please: (list 1.1 2.2 3.3)
can't reenter LISP.
Invalid point.
Command: texteval
Enter new value for TEXTEVAL <1>: 0
Command: (setq pt (getpoint "\nPoint please: "))
Point please: (list 1.1 2.2 3.3)
Can't reenter LISP.
Invalid point.

texteval has no influence.

Sorry for the (strcat ,wil look into that.
Title: Re: Total Newby
Post by: Cornelis on September 29, 2015, 06:34:53 AM
I changed in Roy.lsp to this
Code (autolisp) Select
(defun DrawEllipse ()
  (dcl-Control-SetCaption Roy/Form1/LblStatus "Select Ellipse")
  (dcl-SendString (strcat (chr 27) (chr 27) "(setq p1 (getpoint \"Getpoint (Ellipse)\")) "))
)

(defun DrawRectangle ()
  (dcl-Control-SetCaption Roy/Form1/LblStatus "Select Rectangle")

(dcl-SendString (strcat (chr 27) (chr 27) "(setq p1 (getpoint \"Getpoint (Rectangle)\")) "))
)

(defun DrawCircle ()
  (dcl-Control-SetCaption Roy/Form1/LblStatus "Select circle")

   (dcl-SendString (strcat (chr 27) (chr 27) "(setq p1 (getpoint \"Getpoint (Cirlce)\")) "))
)

(defun DrawLine ()
  (dcl-Control-SetCaption Roy/Form1/LblStatus "Select Line")
  (dcl-SendString (strcat (chr 27) (chr 27) "(setq p1 (getpoint \"Getpoint (Line)\")) "))
)


but same result. Texteval 1
Title: Re: Total Newby
Post by: roy_043 on September 29, 2015, 07:37:28 AM
That is disappointing. I don't think I can be of further assistance.

BTW: You have never confirmed if my code in post #2 works.
Title: Re: Total Newby
Post by: owenwengerd on September 29, 2015, 07:50:30 AM
I'm not sure I understood the problem, but if your modeless form's event invoke property is set to 'Asynchronous', you should go to the button's OnClicked event and click the [Add Cancel] button to add a ^C^C prefix to your event handler string. This cancels any running commands before executing the event handler.
Title: Re: Total Newby
Post by: roy_043 on September 29, 2015, 10:54:42 AM
Quote from: owenwengerd on September 29, 2015, 07:50:30 AM
I'm not sure I understood the problem, but if your modeless form's event invoke property is set to 'Asynchronous', you should go to the button's OnClicked event and click the [Add Cancel] button to add a ^C^C prefix to your event handler string. This cancels any running commands before executing the event handler.
Owen, you are completely right. That is indeed the difference between the two projects. Resetting the event names removes this prefix. Both the OP and I have completely overlooked this. Good to know that it is so easy to accomplish this. Thank you.
Title: Re: Total Newby
Post by: Cornelis on October 02, 2015, 12:16:47 AM
Wow that works the clicking the add Cancel button is the solution!!! I am a happy camper now.

Thank you so much Owen and Roy