Author Topic: Table row strikethrough via Lisp  (Read 3746 times)

0 Members and 1 Guest are viewing this topic.

cadpoobah

  • Newt
  • Posts: 48
Table row strikethrough via Lisp
« on: May 30, 2014, 02:42:26 PM »
All,

I would like to create/find a utility that will let me select a cell in a table and have it add a "strikethrough" to all the text (in any cells) in that entire row.

I've found a few vla- functions for working with cells and table text but nothing that would lead me to manipulating the strikethrough property.

Ultimately, it would act as a toggle; unstriking rows that had been "striken" and vice versa.

Any leads?

Thanks!
Chris Lindner
Onebutton CAD Solutions
----------------------------------------------------
www.onebuttoncad.com #dayjob
www.unpavedart.com    #sidehustle

ymg

  • Guest
Re: Table row strikethrough via Lisp
« Reply #1 on: May 30, 2014, 02:57:44 PM »
Don't know about newer version of Autocad but as
of 2012 Strikethrough was not available.

You can have underline or Overline.

ymg

ymg

  • Guest
Re: Table row strikethrough via Lisp
« Reply #2 on: May 30, 2014, 03:46:08 PM »
As of Version 2013 Strikethrough is available,

Code: [Select]
(setq myvar "\\KAll this will be strikehrough\\k")
ymg

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Table row strikethrough via Lisp
« Reply #3 on: May 30, 2014, 04:41:17 PM »
Give this a try  :)
Code: [Select]
(defun c:strike (/ _togglestrike i o p row ss txt)
  (defun _togglestrike (string)
    (if (wcmatch string "{\\K*")
      (substr string 4 (- (strlen string) 4))
      (strcat "{\\K" string "}")
    )
  )
  (setq i -1)
  (if (and (setq ss (ssget "_X" (list (cons 0 "acad_table") (cons 410 (getvar 'ctab)))))
   (setq ss (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))))
      )
    (if (and (setq p (getpoint "\nPick a Cell: "))
     (vl-some '(lambda (x)
(and (eq :vlax-true
  (vla-hittest
    x
    (vlax-3d-point (trans p 1 0))
    (vlax-3d-point (trans (getvar 'viewdir) 1 0))
    'row
    'col
  )
      )
      (setq o x)
)
       )
      ss
     )
)
      (repeat (vla-get-columns o)
(and (vlax-invoke o 'getcellvalue row (setq i (1+ i)))
     (/= "" (setq txt (vla-gettext o row i)))
     (vla-settext o row i (_togglestrike txt))
)
      )
      (princ "\nCell not detected!")
    )
    (princ "\nNo Tables found!")
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ymg

  • Guest
Re: Table row strikethrough via Lisp
« Reply #4 on: May 30, 2014, 05:28:53 PM »
Ronjonp,

Good show !

I believe it would be a good idea to turn the cell selection
into a function returning row and column.

ymg


Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Table row strikethrough via Lisp
« Reply #5 on: May 30, 2014, 05:35:57 PM »
I believe it would be a good idea to turn the cell selection
into a function returning row and column.

Search for 'LM:getcell'  :lol:

EDIT: Or as another example: http://www.theswamp.org/index.php?topic=37154.msg448331#msg448331

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Table row strikethrough via Lisp
« Reply #6 on: May 30, 2014, 06:33:09 PM »
Nice job as usual Lee  :kewl:

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ymg

  • Guest
Re: Table row strikethrough via Lisp
« Reply #7 on: May 30, 2014, 08:17:06 PM »
Lee,

ASMI had something very similar in https://autocadtips.wordpress.com/2012/02/27/autolisp-copy-text-to-table-cells/

So did Lee Ambrosius here http://hyperpics.blogs.com/beyond_the_ui/2012/07/create-a-table-and-select-a-cell-to-change-with-autolisp-and-activex.html

Could not find getcell. But it is easy enough to derive from what we got.

ymg

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Table row strikethrough via Lisp
« Reply #8 on: May 31, 2014, 10:37:10 AM »
Nice job as usual Lee  :kewl:

Thanks Ron, you too  :-)