Author Topic: How to select text related to Direction X?  (Read 1647 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1423
How to select text related to Direction X?
« on: November 09, 2015, 08:09:44 AM »
I want to code a lisp to calculate sum of numbers and but the result at right.
For one row it is OK but i am wondering if there are more than one row, how to sum each row in separate?

Edit: Adding pic
« Last Edit: November 09, 2015, 08:16:59 AM by HasanCAD »

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: How to select text related to Direction X?
« Reply #1 on: November 09, 2015, 08:51:53 AM »
This example should point you in the right direction  :-)

HasanCAD

  • Swamp Rat
  • Posts: 1423
Re: How to select text related to Direction X?
« Reply #2 on: November 15, 2015, 03:33:09 AM »
this what i coded but not working
- How to sort?
- How to delete first item in list to ?
Code - Auto/Visual Lisp: [Select]
  1. (defun c:rt (/ ent inc lst sel srt
  2.              D P P2 ST T1 T1S T1X T1Y T2 T2S T2X T2Y)
  3.   (defun LM:TextInsertion       (elist)                         ;lee
  4.   (if (or (eq "MTEXT" (cdr (assoc 0 elist)))      (and (zerop (cdr (assoc 72 elist)))          (zerop (cdr (assoc 73 elist)))     )      )    (cdr (assoc 10 elist))    (cdr (assoc 11 elist))  ))
  5.  
  6.   (if (setq sel (ssget "_:L" '((0 . "MTEXT,TEXT"))))
  7.     (progn
  8.       (setq lst nil)
  9.       (setq st 0)
  10.       (repeat (setq inc (sslength sel))
  11.         (setq ent (entget (ssname sel (setq inc (1- inc)))))
  12.         (setq p (LM:TextInsertion ent)) ; get txt coord.
  13.         (setq d (list (nth 1 p) (nth 0 p) (cdr (assoc 1 ent))))
  14.         (setq lst (cons d lst))
  15.       )
  16.      
  17.       (setq lst (vl-sort lst (function (lambda ( a b ) (< (car a) (car b)))))) ;How to sort
  18.       (while lst
  19.         (setq t1 (nth 0 lst))
  20.         (setq t1x (nth 0 t1))
  21.         (setq t1y (nth 1 t1))
  22.         (setq t1s (nth 2 t1))
  23.        
  24.         (setq t2 (nth 1 lst))
  25.         (setq t2x (nth 0 t2))
  26.         (setq t2y (nth 1 t2))
  27.         (setq t2s (nth 2 t2))
  28.         (if (= t1x t2x)
  29.           (progn
  30.             (setq st (+ st (atof t1s) (atof t2s)))
  31.             (setq p2 (list t1x t1y 0))
  32.             (ssdel t1 lst)      ; How to delete
  33.             )
  34.           (progn
  35.             (setq st (+ st (atof t1s)))
  36.             (setq p2 (list (+ 1000 t1x) t1y 0))
  37.             (vl-cmdf"text" "j" "R" p2 "0.0" st)
  38.             (ssdel t1 lst)      ; How to delete
  39.             )
  40.           )
  41.         )
  42.       )
  43.     )
  44.   )

HasanCAD

  • Swamp Rat
  • Posts: 1423
Re: How to select text related to Direction X?
« Reply #3 on: November 16, 2015, 09:36:42 AM »
eeeemmmmm
is there no solution?!?!?!?

ChrisCarlson

  • Guest
Re: How to select text related to Direction X?
« Reply #4 on: November 16, 2015, 09:42:37 AM »
You asked a question on a weekend, give it some time.

HasanCAD

  • Swamp Rat
  • Posts: 1423
Re: How to select text related to Direction X?
« Reply #5 on: November 16, 2015, 09:57:48 AM »
You asked a question on a weekend, give it some time.

OOPS Sorry for that. Weekend finished here.