A few questions from a OpenDCL novice

Started by Carsten, October 30, 2009, 07:57:28 AM

Previous topic - Next topic

Carsten

Hi,

After having struggled with ACAD dcl for almost a decade, I am just now exploring the brave new world of OpenDCL.
It looks like a great tool, which can do all I ask for and much more.

However, as always when you start something new, there is a bit of confusion, even though I try to move forward in very small and simple steps.
I can see that I must be making some mistakes, but I just cannot figure how to detect them.
Maybe some of you have "been there, done that" so guidance is highly appreciated.

1) Event functions in lsp don't seem to trigger.
The code below does put the form on the screen, but neither the "oninitialize" or the "onclick" functions seem to be called.

(defun C:o7R2 (/ Result)
  (command "_OPENDCL") ; Load OpenDCL Runtime
  (if (dcl_Project_Load (strcat Logdir "\\Log_Cad"))
    (progn
      (setq Result (dcl_Form_Show Log_Cad_WDU))
      ; Note that this code does not execute until *after* the dialog is closed!
      ;(if (= Result 1) (DoSomething))
    )
  )
  (princ)
)

(defun c:Log_Cad_WDU_OnInitialize (/ sFilename)

  (setq sFilename "C:\\Documents and Settings\\ct\\Dokumenter\\My Pictures\\Robert i Muddergrøften Small.jpg")
  (if (/= sFileName nil)
    (dcl_PictureBox_LoadPictureFile
     Log_Cad_WDU_MainPic
     sFilename
     T
    )
  ) 
)

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


2) Maybe this applies more to the Studio forum but anyway:
- Can a Form be moved from one project to another?
- Can a project name be changed within an existing project?

Thanks & regards
Carsten
   

owenwengerd

  The first problem is usually a mistake in naming.  Open your form in Studio (and make sure you're opening the same project that you're loading in AutoCAD).  Open the form.  Go to the events pane, amd make sure OnInitialize is checked.  Copy the function name from the displayed name at the bottom of the events pane, then paste it intop your lisp code.  This ensures that the code matches what is in the project file.  Next, select the "MainPic" control and do the same for the OnClicked event.

  Forms cannot be moved, but their controls can be copied and pasted en masse.  The "project name" is the filename, so just change the filename.  This does not affect or change the names of event handlers that are already enabled.

Carsten

Hi Owen,

Thanks for your response, it clarifies a few things.
I see now that I got some of the basic concepts wrong and therefore "fumbled."
I think I can get it straigth now.

Regards
Carsten