Jump to content

Can´t load nested lispfiles from a DCL dialog


ripuz

Recommended Posts

Hello, i have a problem with dcl which i´m new at.

 

This is just an example to see my problem.

An easy DLC file called test.dlc :

 

 
test : dialog
{
label = "test dialog" ;
: button
{
label = "Ok" ;
key = "accepted" ;
height = 1 ;
width = 13 ;
is_default = true ;
}
}



;; The lisp file to run the dialog:

(defun test ( / flag dcl_id)
(setq dcl_id (load_dialog "test.dcl"))
(setq flag (new_dialog "test" dcl_id))
(if (null flag) (exit))

(action_tile "accepted" "(test_accepted)(done_dialog)")

(start_dialog)
(unload_dialog dcl_id)
)

(defun test_accepted ()
(load "SomeLispFile.lsp")
(princ "hello")
(alert "hello again")
(command "snap" "on")
)

 

When i run the test function everything works fine until it reaches an AutoCad command (in this case snap), then AutoCad stops responding.

It seems to be when a command is runned within the dialog function.

Anyone who know anything about this please help me!

 

Thanks in advance / Thomas

Edited by ripuz
Didn´t follow the Code Posting Guidline
Link to comment
Share on other sites

I´m sorry..

 

No worries Thomas . :)

 

Welcome to the forum first .

 

All the hanging comes from the command call of snap , so replace it with the system variable like this .

 

(setvar 'snapmode 1)

Besides that , your routine name which is SomeLispFile.lsp should be in the Acad support folder to be loaded and to let the routine running to end to put snap mode on also as well .

 

 

 

Hope this help .

 

Tharwat

Link to comment
Share on other sites

Each time a drawing is opened a lisp file i loaded and that one loads another and so on.

My goal is to reload this sequence when the ok button is pressed but that isn´t possible as long as there is command calls in the lisp files?

Link to comment
Share on other sites

Each time a drawing is opened a lisp file i loaded and that one loads another and so on.

My goal is to reload this sequence when the ok button is pressed but that isn´t possible as long as there is command calls in the lisp files?

Yes this is what I meant in my last post .

 

Anyway here it is completely .

 

(defun c:test ( / flag dcl_id)
(setq dcl_id (load_dialog "test.dcl"))
(setq flag (new_dialog "test" dcl_id))
(if (null flag) (exit))
(action_tile "accepted" "(test_accepted)(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
)
(defun test_accepted ()
(load "SomeLispFile.lsp")
(princ "hello")
(alert "hello again")
(setvar 'snapmode 1)
)

 

Tharwat

Link to comment
Share on other sites

I rewrote all regular commands with setvar or with vl-commands so now it works just fine. :)

 

The issue is not with using command calls, but rather that the focus remains with the modal dialog when the command is called.

 

Instead, consider this code:

 

DCL:

test : dialog { label = "test dialog" ;
   ok_only;
}

LISP:

(defun test ( / id )
   (cond
       (   (< 0 (setq id (load_dialog "test.dcl")))
           (cond
               (   (new_dialog "test" id)
                   (if (= 1 (start_dialog))
                       (test_accepted)
                   )
               )
           )
           (unload_dialog id)
       )
   )
   (princ)
)

(defun test_accepted nil
   (load "SomeLispFile.lsp")
   (princ "hello")
   (alert "hello again")
   (setvar 'SNAPMODE 0)
)

Link to comment
Share on other sites

Thank you Lee Mac!

It took me a while to understand but now I see that I can use whatever I want if I just close the dialog first.

Quite obvious when you know it... :)

 

Nice to get an answer from a legend of this site! 8) (I have seen your answers many times on this site before I registered myself.)

Link to comment
Share on other sites

Thank you Lee Mac!

It took me a while to understand but now I see that I can use whatever I want if I just close the dialog first.

Quite obvious when you know it... :)

 

Nice to get an answer from a legend of this site! 8) (I have seen your answers many times on this site before I registered myself.)

 

You're very welcome ripuz! I'm flattered that my reputation precedes me o:)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...