entmake problem

Started by vladimirzm, February 24, 2009, 10:57:32 AM

Previous topic - Next topic

vladimirzm

i don't know what's the problem with this code.
ENTMAKE returns error, i have to draw the line and save it LN var, then the code works fine.
see attached.

;;; Ensure the appropriate OpenDCL ARX file is loaded
(COMMAND "_OPENDCL")

(DEFUN C:mgrread ()
 
  (dcl_Project_Load "modeless-grread" t)

  (dcl_Form_Show modeless-grread_Form1)
 
  (PRINC)
)

(defun c:modeless-grread_Form1_OnInitialize (/)
  (dcl_Control_SetCaption modeless-grread_Form1_Label3 "0 , 0 , 0")
  (dcl_Control_SetCaption modeless-grread_Form1_Label4 "0.00")
)


(defun c:modeless-grread_Form1_GraphicButton1_OnClicked (/ p1 cont grr)
 
  (setq p1 (getpoint "\nFirst point: ")
        cont t
  )

;;;  (ENTMAKE (LIST '(0 . "LINE") (CONS 10 p1) (CONS 11 p1)))  <---- HERE IS THE PROBLEM
;;;  (setq ln (vlax-ename->vla-object
;;;             (entlast)             
;;;           )
;;;  )
 
  (while cont
    (setq grr (grread t 14))
    (cond
      ( (= 5 (car grr)) ;aqui solo mueve el cursor
        (vla-put-endpoint ln (vlax-3d-point (cadr grr)))
       
        (dcl_Control_SetCaption
          modeless-grread_Form1_Label3
          (strcat (rtos (caadr grr) 2 2) " , " (rtos (cadadr grr) 2 2) " , " (rtos (car (cddadr grr)) 2 2))
        )
        (dcl_Control_SetCaption
          modeless-grread_Form1_Label4
          (rtos (vla-get-Length ln) 2 2)
        )
      )
      ( (= 2 (car grr))
        (if (= 13 (cadr grr))
    (progn
              (dcl_MessageBox "ENTER. \nMGRREAD ends" "MGRREAD Message")      
              (dcl_Form_Close modeless-grread_Form1)
      (setq cont nil)
    )
    (dcl_MessageBox (strcat "Key: " (chr (cadr grr))) "MGRREAD Message")
)
      )
      ( (= 3 (car grr))
        (dcl_MessageBox "left click" "MGRREAD Message")       
      )
      ( (= 25 (car grr))
        (dcl_MessageBox "right click" "MGRREAD Message")
       
      )
    )
  )
)


AutoCAD 2008
OpenDCL [5.0.1.6]

BazzaCAD

I think (entmake) has the same issues as (command).

Select the Button & have a look at the "Event Invoke" property & change it to 1

Quote
This property controls whether event handlers are called synchronously or asynchronously. A synchronous call causes the dialog code to wait until the event handler returns before resuming; an asynchronous event call allows the dialog code to continue running, and the event handler is not executed until AutoCAD is ready to process commands. This property is hidden and ignored for controls on modal forms.

Value Meaning
0 Synchronous
1 Asynchronous

Event handlers that are called synchronously are limited in what they can safely do, because they run while the dialog code is in a suspended state and AutoCAD is unable to process commands. For example, it is not possible to call the AutoLISP (command) function from a synchronous event handler.

Asynchronous event handlers in most cases will not execute until after the event that triggered it has passed, however an asynchronous event handler can safely call the AutoLISP (command) function to process AutoCAD commands. When a modeless dialog control's event handlers need to use the AutoLISP (command) function, the Event Invoke property for the control must be set to 1.

Any events that have return values are always called synchronously (otherwise the return value would be lost). Events called from modal forms are always called synchronously, since modal forms by their nature prevent AutoCAD from executing commands while they are active. Event handlers in these cases must conform to the requirements for synchronous events regardless of the Event Invoke property setting.

a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

owenwengerd

As Barry said, the problem is that your event handler executes in the application context. You need to call document-specific functions from the document context. See the last paragraph in the help file topic on Modal vs. Modeless dialog programming (http://www.opendcl.com/HelpFiles/Concepts/Modality.htm) for more on the problem.
Owen Wengerd (Outside The Box) / ManuSoft

BazzaCAD

Wow isn't it nice being able to link directly to the help file now :)
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Fred Tomke

Yes, and how can I link to the German help files?
(I don't mean the automatic translation by google.)

  :)
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

It is nice, but it would be nicer if you could link to the frames page with the correct topic opened. And, as Fred says, if the actual German files were available.
Owen Wengerd (Outside The Box) / ManuSoft

Fred Tomke

Quoteif you could link to the frames page with the correct topic opened

That will be heavy, I feel.  :-\
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

vladimirzm