Grouped txt2mtxt

Grouped txt2mtxt

Anonymous
Not applicable
925 Views
5 Replies
Message 1 of 6

Grouped txt2mtxt

Anonymous
Not applicable

Im totally stuck on a section of a tool set im putting together at the moment.

the intent of the tool would be something that could select all TEXT objects on a specific layer, run through the selection set creating sub sets of text that are within 4 units of each other then run the txt2mtxt command on each grouping.

What would be awesome would be if someone had something similar or even just a way to set up a list of selection sets based on proximity and i can have a go from there.

attached is an example file. the text of interest is the lot and DP information.

Cheers in advance

0 Likes
Accepted solutions (1)
926 Views
5 Replies
Replies (5)
Message 2 of 6

Sea-Haven
Mentor
Mentor

It may at 1st glance be easy as the 2 texts are on different layers so make a selection set  of say Lot x then using a polygon look for text on the other layer then just txt2mxt.

 

Have a couple of tasks before this someone may jump in sooner.

0 Likes
Message 3 of 6

Anonymous
Not applicable
That's not always the case. Between multiple different information sources
and frankly lacklustre cad standards in the wider team I was hoping to
build something that's not reliant on layering
0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

Here's a quick one.

 

(defun c:TXT2MTXTGroups ( / d s e p g lst)

  (if (setq d 4
	    s (ssget "_:L" '((0 . "TEXT"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    p (cdr (assoc 10 (entget e)))
	    f nil)
      (foreach m lst
	(if (< (distance (car m) p) d)
	  (setq lst (subst (append m (list e))
			   m
			   lst)
		f t)))
      (if (not f) (setq lst (cons (list p e) lst)))))
  (foreach m lst
    (command "_.txt2mtxt")
    (mapcar 'command (cdr m))
    (command ""))
  (princ)
  )

 

Message 5 of 6

Anonymous
Not applicable
@ВeekeeCZ
Thats exactly what im after thanks! and gave me a few more ideas for other stuff im working on. Im still learning and having simple code to model from i find really helps the process.
Message 6 of 6

Sea-Haven
Mentor
Mentor

I am not sure it will work if you look closer the dwg supplied has all sorts of text, it has Text, Mtext and Mtext that has the two text already combined, it also has 2*text twice in one location. To automate joining two text together which is my understanding of request there needs to be consistency in the dwg.

0 Likes