OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: juniorolisp on February 12, 2015, 01:13:24 PM

Title: Open dwg file - error
Post by: juniorolisp on February 12, 2015, 01:13:24 PM
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.
Title: Re: Open dwg file - error
Post by: owenwengerd on February 12, 2015, 02:35:18 PM
Are you calling (command) from a synchronous event handler? If so, take a look at the last paragraph here (http://www.opendcl.com/HelpFiles/index.php?page=Concepts/Modality.htm).
Title: Re: Open dwg file - error
Post by: juniorolisp on February 14, 2015, 10:45:10 AM
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
Title: Re: Open dwg file - error
Post by: owenwengerd on February 14, 2015, 07:47:10 PM
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).
Title: Re: Open dwg file - error
Post by: juniorolisp on February 15, 2015, 02:28:04 AM
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.
Title: Re: Open dwg file - error
Post by: owenwengerd on February 15, 2015, 11:03:13 AM
Your lisp code and .odcl do not explain the problem. How are you loading your lisp code into the new drawing?
Title: Re: Open dwg file - error
Post by: juniorolisp on February 15, 2015, 11:51:04 AM
I use the file menu .cui and file .mnl
(load "i.lsp" "error")
Title: Re: Open dwg file - error
Post by: owenwengerd on February 15, 2015, 12:09:57 PM
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").
Title: Re: Open dwg file - error
Post by: juniorolisp on February 15, 2015, 12:19:42 PM
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.
Title: Re: Open dwg file - error
Post by: owenwengerd on February 15, 2015, 12:56:01 PM
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.
Title: Re: Open dwg file - error
Post by: owenwengerd on February 15, 2015, 01:23:54 PM
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]
Title: Re: Open dwg file - error
Post by: juniorolisp on February 15, 2015, 01:51:31 PM
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 ?
Title: Re: Open dwg file - error
Post by: owenwengerd on February 15, 2015, 02:35:06 PM
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.
Title: Re: Open dwg file - error
Post by: juniorolisp on February 15, 2015, 02:45:57 PM
if I close the window opendcl eg. "cross".
How do I open them again
Title: Re: Open dwg file - error
Post by: owenwengerd on February 15, 2015, 02:52:21 PM
I guess the same way you opened it in the first place, usually by a custom command. Is that what you're asking?
Title: Re: Open dwg file - error
Post by: juniorolisp on February 22, 2015, 11:55:02 AM
After a week of testing I find that everything works great.
There were, however, a new question:
How to open file "Read-only" (or is it at all possible?)?
Title: Re: Open dwg file - error
Post by: owenwengerd on February 22, 2015, 03:05:03 PM
One way to force a file to open read-only is to open it for writing with the lisp expression (open "<filepath>" "a") before issuing the OPEN command. I don't know how that will work in your scenario.
Title: Re: Open dwg file - error
Post by: juniorolisp on August 04, 2015, 12:25:35 PM
Hello,
After long trials, there was another problem.
If you open the file will get the message
QuoteThis file is already in use. Do you want to open it as read-only?
and click no.
All functions lisp stop working. Do you have any idea how to get around \ repair
Title: Re: Open dwg file - error
Post by: roy_043 on August 05, 2015, 01:47:04 AM
I think you will need to give more details.
If you open a dwg as read-only you can still run Lisp code in that drawing.
Title: Re: Open dwg file - error
Post by: juniorolisp on August 05, 2015, 08:37:38 AM
so then it works.
It stops working when you give up opening the file
Title: Re: Open dwg file - error
Post by: roy_043 on August 06, 2015, 07:38:10 AM
After many tests I find the problem is related to the undocked state of the palette. If the palette is docked before any double click action has occurred, things seem to work fine. In BricsCAD V14 this problem does not occur but even in that version there are still issues with palettes.
Title: Re: Open dwg file - error
Post by: juniorolisp on August 07, 2015, 02:51:00 AM
Do you have maybe an idea how to bypass this problem? Is the only solution is to update to a higher version of Bricscad?
Title: Re: Open dwg file - error
Post by: roy_043 on August 09, 2015, 05:22:27 AM
I have tried 3 alternative methods, but can't find a full proof approach to opening the drawings.

Method 1 can't be used because on_doc_load.lsp and .mnl files are not loaded in the new drawings.
Methods 2 and 3 suffer from the problem mentioned in posts #2 and #7. I think this problem is caused by a 'namespace issue'. The ODCL dialog is using functions that are defined in a different drawing from the current one. In my tests closing a drawing (after creating some entities) seems to be a trigger.

Note 1: BricsCAD V13 and ODCL 8.0.0.6 were used for testing.
Note 2: I have created a new ODCL project with a modeless dialog and have used the new 'dcl-' naming scheme.

Method 1: I_new_vla-open.lsp
Use (vla-open) to open drawings.
This is a strange one! In my tests I have used on_doc_load.lsp to load the project Lisp file. And even thought on_doc_load.lsp is not loaded in a dwg opened with (vla-open), the ODCL dialog works fine in the new drawing. This again points to a namespace issue.

Method 2: I_new_script.lsp
Use a temporary script to open drawings.

Method 3: I_new_sendkeys.lsp
Use the WSH sendkeys method to open drawings.
Title: Re: Open dwg file - error
Post by: owenwengerd on August 09, 2015, 04:43:45 PM
Roy, there was a bugfix in one of the BricsCAD V15 updates that addresses the problem with functions not being defined in the correct namespace.
Title: Re: Open dwg file - error
Post by: roy_043 on August 10, 2015, 11:44:07 PM
Quote from: owenwengerd on August 09, 2015, 04:43:45 PM
Roy, there was a bugfix in one of the BricsCAD V15 updates that addresses the problem with functions not being defined in the correct namespace.
I am using BricsCAD V14 at the moment. But good to know it has been fixed. Thanks.