Author Topic: My futile attemps at a doubleclickreactor  (Read 3587 times)

0 Members and 1 Guest are viewing this topic.

psuchewinner

  • Guest
My futile attemps at a doubleclickreactor
« on: August 03, 2006, 08:45:57 AM »
I have been trying for weekd to write a doubleclick reactor for a piece of mtext.  Can someone look at the attached code and help me get this right?  I know I am missing something but I just cant find it.  I have not finished cleaning up so forgive me for the stupid stuff.

Code starts here:
Code: [Select]
(defun c:ATR ()
  (vl-load-com)
  (setq myReactor (vlr-mouse-reactor (list mtextobj) '((:vlr-BeginDoubleClick . event))))
;---------------Variables-------------
(setq doc (vla-get-activeDocument (vlax-get-acad-object)))
(setq pspace (vla-get-paperSpace doc))
;--------------End Variables----------

;;;  DoubleClickEvent
  (defun Event ()
        (alert "\nReactor Lesson Complete")
    (princ)
  );end Event

; Create Mtext Insertion point and convert it to a 2D point
  (setq MtextInsPoint (getpoint "\nSelect point for Insertion::"))
   (setq MtextString "SADADASD")
    (setq mtextobj (vla-addMText
                   pspace
    (vlax-3d-point MtextInsPoint)
                   0.0
                mtextstring
                 );end vla-addmtext
  );end setq

;;;  Reactor Data
;;;
 
;--------------
);End AR
 

<code tags added>
« Last Edit: August 03, 2006, 08:56:27 AM by CAB »

nivuahc

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #1 on: August 03, 2006, 09:36:53 AM »
My results (Map 3D 2006):

Code: [Select]
Command: ATR


Select point for Insertion::_ins of #<VLA-OBJECT IAcadMText2 0d89a454>

Command:

Saw nothing, zoomed extents, created some MTEXT from scratch (using the same point previously selected), double-clicked it...

Code: [Select]
Command:
Command: ; error: too many arguments
; error: too many arguments
_.mtedit
Command:

psuchewinner

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #2 on: August 03, 2006, 10:11:17 AM »
I want it to be able to suppress the ._DDEDIT command and replace it with an editor of my own.  Ideally, it will eventually identify if it has certain xdata attached to the MTEXT and if it does, open my own editor.  We have a program here at work that does this and I am trying to figure it out.  Kinda' like "reverse engineering." 

I just want to get something other than the standard DDEDIT to act upon the double click.  That is why my program "event" ['((vlr:BeginDoubleClick . event))] only has the alert box in it.  If I can get it to work like that then maybe I can proceed with the rest of my lesson.

LE

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #3 on: August 03, 2006, 10:28:00 AM »
My goodness, super difficult to pronounce your name....   :-o

Here is a very old code - as-is - I do not do nothing about reactor in lisp anymore hth.

Code: [Select]
(vl-load-com)

(or thisDwg
    (setq thisDwg (vla-get-activeDocument (vlax-get-acad-object))))

(vla-sendCommand thisDwg "_.dblclkedit _off ")

(vla-setVariable
  thisDwg
  "pickfirst"
  (vlax-make-variant 1 vlax-vbInteger))

(or mouseReactor
    (setq mouseReactor
    (vlr-mouse-reactor
      data
      '((:vlr-beginDoubleClick
  .
  mouse-beginDoubleClick)))))

(defun mouse-beginDoubleClick
       (reactor params / obj data ss compare pt)

  (setq obj
  (if (setq data (nentselp "" (car params)))
    (vlax-ename->vla-object (car data))))

  (if (and obj
    (equal (getVar "cmdnames") ""))
    (progn

      (if (setq ss (ssGet "i"))
 (progn

   (setq pt (cadr data))

   (setq
     compare
      (strCase
        (vla-get-objectName
   (vlax-ename->vla-object (ssName ss 0)))))

   (cond
     ((wcmatch compare "*DIM*,*TEXT*")
      ;(vla-sendCommand thisDwg "_.ddedit (princ pt)\n"))
      (vla-sendcommand thisDwg "_.ddedit (princ pt)"))

     ((wcmatch compare "ACDBMLINE")
      (vla-sendCommand thisDwg "_.mledit \n"))

     ((wcmatch compare "*HATCH")
      (vla-sendCommand
        thisDwg
        "_.hatchedit (princ pt) \n"))

     ((wcmatch compare "ACDBLINE")
      (vla-sendCommand thisDwg "_.line \n"))

     ((wcmatch compare "*BLOCK*")
      (initdia)
      (vla-sendCommand thisDwg "_.attedit (princ pt) \n"))))))))

(princ)

psuchewinner

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #4 on: August 03, 2006, 02:14:40 PM »
"my goodness, super difficult to pronounce your name"

It is pronounced "Suu-k winner"  "Psuche" is greek for Soul.

I am having a problem getting the dialog for the text and mtext editors to turn off.

Someone care to take a stab at it?
« Last Edit: August 03, 2006, 02:15:58 PM by psuchewinner »

psuchewinner

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #5 on: August 04, 2006, 10:32:06 AM »
"Someone care to take a stab at it?"

Any takers?
« Last Edit: August 04, 2006, 10:33:24 AM by psuchewinner »

LE

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #6 on: August 04, 2006, 11:19:55 AM »
Using the same sample code I posted before here, you can do something like:

Code: [Select]
(vl-load-com)

(if (not thisdwg)
  (setq thisdwg (vla-get-activedocument (vlax-get-acad-object))))

(vla-sendcommand thisdwg "_.dblclkedit _off ")

(vla-setvariable
  thisdwg
  "pickfirst"
  (vlax-make-variant 1 vlax-vbinteger))

(if (not mousereactor)
  (setq mousereactor
(vlr-mouse-reactor
   data
   '((:vlr-begindoubleclick
      .
      mouse-begindoubleclick)))))

(defun mouse-begindoubleclick
       (reactor params / obj data ss compare pt)

  (setq obj
(if (setq data (nentselp "" (car params)))
   (vlax-ename->vla-object (car data))))

  (if (and obj
   (equal (getvar "cmdnames") ""))
    (progn

      (if (setq ss (ssget "i"))
(progn

  (setq pt (cadr data))

  (setq
    compare
     (strcase
       (vla-get-objectname
(vlax-ename->vla-object (ssname ss 0)))))

  (cond
    ((wcmatch compare "*DIM*,*TEXT*")

     (alert "my DIM and TEXT editor goes here") ;; here you add your own interface for dimensions and texts/mtext

     )

    ))))))

(princ)



LE

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #7 on: August 04, 2006, 11:34:24 AM »
Or....

Code: [Select]
(vl-load-com)

(if (not thisdwg)
  (setq thisdwg (vla-get-activedocument (vlax-get-acad-object))))

;;;(vla-sendcommand thisdwg "_.dblclkedit _off ")

(vla-setvariable
  thisdwg
  "pickfirst"
  (vlax-make-variant 1 vlax-vbinteger))

(if (not mousereactor)
  (setq mousereactor
(vlr-mouse-reactor
   data
   '((:vlr-begindoubleclick
      .
      mouse-begindoubleclick)))))

(defun mouse-begindoubleclick
       (reactor params / obj data ss compare pt)

  (setq obj
(if (setq data (nentselp "" (car params)))
   (vlax-ename->vla-object (car data))))

  (if (and obj
   (equal (getvar "cmdnames") ""))
    (progn

      (if (setq ss (ssget "i"))
(progn

  (setq pt (cadr data))

  (setq
    compare
     (strcase
       (vla-get-objectname
(vlax-ename->vla-object (ssname ss 0)))))

  (cond
    ((wcmatch compare "*DIM*")

     (alert "my DIMENSION editor goes here")

     (sssetfirst nil)

     )

    ((= compare "ACDBTEXT")

     (alert "my TEXT editor goes here")

     (sssetfirst nil)

     )

    ((= compare "ACDBMTEXT")

     (alert "my MTEXT editor goes here")

     (sssetfirst nil)

     )

    ))))))

(princ)

psuchewinner

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #8 on: August 04, 2006, 12:30:21 PM »
I loaded the code above into the Vlisp editor and double clicked on a text entity and I did not get the alert boxes.  Very stange.

LE

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #9 on: August 04, 2006, 12:40:33 PM »
Check this:

PICKFIRST = 1

psuchewinner

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #10 on: August 04, 2006, 12:45:38 PM »
pickfirst = 1.
still nothing.

LE

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #11 on: August 04, 2006, 12:53:38 PM »
What AutoCAD you are using?

Is the command DBLCLKEDIT - available?

psuchewinner

  • Guest
Re: My futile attemps at a doubleclickreactor
« Reply #12 on: August 04, 2006, 02:05:28 PM »
We are using 2005 MDT here.  I have found a solution to my problem though.  By setting the "MTEXTED" system variable to something other than "Internal" or null.  In fact, it can be set to use any editor that you want.  Such a simple solution.  My problem is solved.  Imagine that, It only took 2 weeks this time. :-)  Thanks for your help.  I can now proceed with finishing my code.