TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: psuchewinner 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:
(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>
-
My results (Map 3D 2006):
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...
Command:
Command: ; error: too many arguments
; error: too many arguments
_.mtedit
Command:
-
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.
-
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.
(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)
-
"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?
-
"Someone care to take a stab at it?"
Any takers?
-
Using the same sample code I posted before here, you can do something like:
(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)
-
Or....
(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)
-
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.
-
Check this:
PICKFIRST = 1
-
pickfirst = 1.
still nothing.
-
What AutoCAD you are using?
Is the command DBLCLKEDIT - available?
-
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.