Author Topic: Double-Click return attribute  (Read 2389 times)

0 Members and 1 Guest are viewing this topic.

donnieworld

  • Newt
  • Posts: 26
  • BricsCAD Fan
Double-Click return attribute
« on: June 18, 2019, 08:34:15 PM »
I've successfully customized the CUI to run my lisp routine when the user double-clicks on an attribute. I need to change the lisp routine to select the attribute they double-clicked on? Everything I try returns the block, not the specific attribute?

I expected something very simple like this to work ...

(setq ss1 (ssget "i:n")) or (setq ss1 (ssget "i:v"))

Thanks in advance :-)
Donald Broussard
Fusion Engineering and Technology

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Double-Click return attribute
« Reply #1 on: June 19, 2019, 12:28:58 AM »
If you use nentsel it will allow picking of an attribute rather than a block.

A man who never made a mistake never made anything

tombu

  • Bull Frog
  • Posts: 288
  • ByLayer=>Not0
Re: Double-Click return attribute
« Reply #2 on: June 19, 2019, 07:25:09 AM »
You can also sub-select an attribute to edit it's properties with the Properties Palette by holding the Ctrl key down to sub-select it.  Double click on an attribute while holding down the Ctrl key to edit it in place.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Double-Click return attribute
« Reply #3 on: June 19, 2019, 11:59:08 AM »
When the selection is returned from the double click, you can extract the selection point with ssnamex, then use nentselp to select select the attribute.

eg.
Code: [Select]
(nentselp (cadar (cdddar (ssnamex ss))))
The "ss" being the stored selection set, which would only work for a single object selection.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Double-Click return attribute
« Reply #4 on: June 19, 2019, 12:19:34 PM »
Maybe a DoubleClick reactor will do?

Code - Auto/Visual Lisp: [Select]
  1. (defun C:testOn nil (DClickOnAttribute t)(princ))
  2. (defun C:testOff nil (DClickOnAttribute nil)(princ))
  3.  
  4. (defun DClickOnAttribute ( flg )
  5.   (
  6.     (lambda ( rtrnm flg ) (vl-load-com)
  7.       (foreach rtr (cdar (vlr-reactors :VLR-Mouse-reactor)) (if (= rtrnm (vlr-data rtr)) (vlr-remove rtr)) )
  8.       (foreach rtr (cdar (vlr-reactors :VLR-Command-Reactor)) (if (= rtrnm (vlr-data rtr)) (vlr-remove rtr)) )
  9.       (if flg
  10.         (progn
  11.           (alert "\nDoubleClick On Attribute Reactor is ON")
  12.           (vlr-Mouse-Reactor rtrnm '((:VLR-BeginDoubleClick . Mouse:CB)))
  13.           (vlr-Command-Reactor rtrnm '((:VLR-commandWillStart . Cmd:CB)))
  14.         ); progn
  15.         (alert "\nDoubleClick On Attribute Reactor is OFF")
  16.       ); if
  17.      
  18.       (princ)
  19.     ); lambda
  20.     "test" flg
  21.   )
  22. )
  23.  
  24. ; CallBack functions -
  25. (defun Mouse:CB ( rtr args / o )
  26.   (and
  27.     (setq o (car (nentselp (car args))))
  28.     (setq o (vlax-ename->vla-object o))
  29.     (eq (vla-get-ObjectName o) "AcDbAttribute")
  30.     (alert (strcat "Attribute selected:" "\n" (vlax-get o 'TagString) "\n"(vlax-get o 'TextString)))
  31.   )
  32. )
  33.  
  34. (defun Cmd:CB ( rtr args / wsh )
  35.   (if (member (strcase (car args)) '("EATTEDIT" "QUICKPROPERTIES" "RATRRED" "WLASCIWOSCI"))
  36.     (progn
  37.       (and
  38.         (setq wsh (vlax-get-or-create-object "WScript.Shell"))
  39.         (vl-catch-all-apply (function (lambda nil (vlax-invoke-method wsh 'SendKeys "{ESC}"))))
  40.       )
  41.       (vl-catch-all-apply 'vlax-release-object (list wsh))
  42.       t
  43.     )
  44.   ); and
  45. ); defun Cmd:CB

Somewhat related thread
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

donnieworld

  • Newt
  • Posts: 26
  • BricsCAD Fan
Re: Double-Click return attribute
« Reply #5 on: June 19, 2019, 02:00:49 PM »
When the selection is returned from the double click, you can extract the selection point with ssnamex, then use nentselp to select select the attribute.

eg.
Code: [Select]
(nentselp (cadar (cdddar (ssnamex ss))))
The "ss" being the stored selection set, which would only work for a single object selection.

This is working  ... Thanks
Donald Broussard
Fusion Engineering and Technology

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Double-Click return attribute
« Reply #6 on: June 19, 2019, 04:44:14 PM »
Alternative with grread:

Code - Auto/Visual Lisp: [Select]
  1. ; Prompting for a double-click on a object (with grread)
  2. (defun C:test ( / pb *error* s k v L pL e )
  3.  
  4.   (setq pb (getvar 'pickbox))
  5.   (setvar 'pickbox (* 2.0 pb))
  6.  
  7.   (defun *error* ( m )
  8.     (and pb (setvar 'pickbox pb))
  9.     (and m (princ m)) (princ)
  10.   ); defun *error*
  11.  
  12.   (princ "\nDouble click on a object <exit>: ")
  13.   (while (not s)
  14.     (mapcar 'set '(k v) (grread))
  15.     (and (equal (list k v) '(2 13)) (setq s t))
  16.     (cond
  17.       ( (= 3 k) ; LMB
  18.         (setq L (cons (getvar 'cdate) L))
  19.         (setq pL (cons v pL))
  20.         (and
  21.           (>= (length L) 2)
  22.           (>= (length pL) 2)
  23.           (< (- (car L) (cadr L)) 1.0021e-06)
  24.           (equal (car pL) (cadr pL) 1e-3)
  25.           (progn
  26.             (setq L nil)
  27.             (setq pL nil)
  28.             (if (setq e (car (nentselp v)))
  29.               (progn
  30.                 (alert (cdr (assoc 0 (entget e))))
  31.                 (setq s t)
  32.               )
  33.               (princ "\nMissed!")
  34.             )
  35.            
  36.           ); progn
  37.         ); and
  38.       ); LMB
  39.       ( (= 25 k) (setq s t) )
  40.     )
  41.   ); while
  42.   (*error* nil)
  43.   (princ)
  44. ); defun C:test
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Double-Click return attribute
« Reply #7 on: June 19, 2019, 09:48:54 PM »
Be careful lots of other commands use double click, in a layout dbl click to change space. Code not tested .
A man who never made a mistake never made anything