Open dwg file - error

Started by juniorolisp, February 12, 2015, 01:13:24 PM

Previous topic - Next topic

juniorolisp

hi,
I'm a new user opendcl  and encountered the first problem.
When using a listbox-and I call the function "(command" _.OPEN" name)".
The file opens, but double-click stops working.
Of course, the next time you load the Lisp works, what am I doing wrong?
Bricscad V13 use.
Sorry for my English.

owenwengerd

Are you calling (command) from a synchronous event handler? If so, take a look at the last paragraph here.

juniorolisp

#2
Unfortunately, we still something I'm doing wrong
Code (autolisp) Select
(defun c:I_im_DrawingsListBox_OnDblClicked (/  )
( setvar "SDI" 0 ) ; turn on multiple document interface
(setvar "FILEDIA" 0)
(dcl_SendString (strcat "(command " "\"_.OPEN\"" "\"" "C:/001.dwg" "\"" ")" " "))
(setvar "filedia" 1)
)


the first call to work correctly. After opening the file, double-click it returns an error:
Code (autolisp) Select
; ----- Error around expression ----
(DCL_LISTBOX_GETSELECTEDITEMS I_Im_DRAWINGSLISTBOX)

; error : no function definition <DCL_LISTBOX_GETSELECTEDITEMS> ; expected FUNCTION at [EVAL]
;
; error : during LISP function [c:I_Im_DrawingsListBox_OnDblClicked] invoke from BRX/SDS interface,
          please check Lisp function definition and call arguments.


Please Help Me

owenwengerd

Both (setvar "FILEDIA") calls are not doing what you expect and can be removed from your code without changing anything. The error indicates that an event handler is not defined. When you open a new document, you need to make sure your event handlers are defined in the new document before they are fired. There are various way of doing so. One way is to load your functions via (vl-load-all).

juniorolisp

Thank you for your help, however, still do not know how to do it.
I attach a file odcl plus lsp file maybe somewhere else is an error.

owenwengerd

Your lisp code and .odcl do not explain the problem. How are you loading your lisp code into the new drawing?

juniorolisp

I use the file menu .cui and file .mnl
(load "i.lsp" "error")

owenwengerd

I am able to reproduce the problem in Bricscad V15 64-bit. Strangely, if I switch documents then switch back, the control symbol is suddenly defined as expected. I will investigate.

By the way, I recommend to remove your very complex function to load OpenDCL runtime and replace it with simply (command "OPENDCL").

juniorolisp

Feature written by Leemac working properly:
http://www.lee-mac.com/open.html
However, I have time after a long activity that Bricscad also stopped working.
I would therefore run the simple OPEN.

owenwengerd

This appears to be a bug in Bricscad. I will report the bug and see what they say. You could work around the problem by using the alternate method of "<project>" "<form>" "<control>" instead of the control symbol.

owenwengerd

This works for me:
Code (autolisp) Select
[/(defun C:Iii ( / wersja)
(command "OPENDCL")
(dcl_Project_Load "I")
(dcl_Form_Show I_IM 30 150)
(dcl_Control_SetDockableSides I_IM 0)
(princ)
)

(defun c:I_Im_DrawingsListBox_OnDblClicked (/ %nazwa acApp acDocs Nazwa)
  (setq %nazwa (car (dcl_ListBox_GetSelectedItems I_Im_DrawingsListBox)))
(setq  %nazwa (strcat (getvar "dwgprefix")  %nazwa ".dwg"))
(setq  %nazwa (vl-string-translate "\\" "/" %nazwa))
(setvar "SDI" 0 ) ; turn on multiple document interface
(dcl_SendString (strcat "FILEDIA 0\n_.OPEN \"" (vl-princ-to-string %nazwa) "\"\nFILEDIA 1 "))
)
(defun c:I_Im_DrawingsRefresh_OnClicked (/  %DrawingsListComplete %DrawingsListCompleteDWG)
(setq %DrawingsListComplete (vl-directory-files (strcat (getvar "dwgprefix"))  "*.dwg"))
(foreach % %DrawingsListComplete
(setq %DrawingsListCompleteDWG (cons (substr % 1 (- (strlen %) 4)) %DrawingsListCompleteDWG))
)
(dcl_ListBox_Clear I_Im_DrawingsListBox)
(dcl_ListBox_AddList I_Im_DrawingsListBox %DrawingsListCompleteDWG)
)
code]

juniorolisp

Thank you very much, it works.
So it was a mistake to send "command" to the command line ?

Maybe not to assume the new post I have a question
As the closure of the palette to call it again ?

owenwengerd

Quote from: juniorolisp on February 15, 2015, 01:51:31 PM
So it was a mistake to send "command" to the command line ?

I'm not sure I would call it a mistake, but it does create an unusual situation since lisp evaluation is confined to each document. In AutoCAD that approach does not work at all to open a new drawing.


Quote from: juniorolisp on February 15, 2015, 01:51:31 PM
As the closure of the palette to call it again ?

Sorry, I don't understand the question.

juniorolisp

if I close the window opendcl eg. "cross".
How do I open them again

owenwengerd

I guess the same way you opened it in the first place, usually by a custom command. Is that what you're asking?