Hello,
i have a very large dwg with data field (a nautical depth chart), which i am trying to simply.
i managed to use object filter out and keep only depth rounded of to .0 and .5 meters
is there a way that autocad can select the first and last text in the x-direction for a array of texts ?
this is a small example what i have:
its arrays of text values representing the water depth at the giving location.
and this is what i am trying to achieve
is there a way to achieve this by using object text: filter ? or any other tips/methods are welcome.
thanks
Solved! Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
An AutoLisp routine could do that. It would mean selecting all of them, and it would step through and look at the X coordinate of the insertion point of each, comparing it to the least and greatest value found so far, and replacing if the current one is found to be farther in the given direction. But first:
Do all of them have the same justification?
What should happen if more than one share the same left-most or right-most X coordinate? Are you looking for just that coordinate value, or for a specific Text object, and if the latter, how should it choose among multiples at the same X-wise position?
i have uploaded a sample part of the file, and yes all of the text's seems to have the same justification.
y was thinking maybe creating a contour with the outer texts might also work.
my concern is when you have a gap within a row in the x direction. if it could still recognize that.
What's more interesting is that the texts are slightly off the 90°grid. Is the off-angle the same (or almost) all over the drawing?
@ВeekeeCZ wrote:
... the texts are slightly off the 90°grid. Is the off-angle the same (or almost) all over the drawing?
That's important if the idea is to select the whole collection at once, because a Y-coordinate check will be needed to group things into rows. If you're willing to select each row separately, then it's easier, and the differences in Y coordinate don't matter, but....
yes the whole drawing the texts are in the same offset rotation.
i probarly the data is an export from another programs, wich they have the given depth for the given coordinate
and this has than bin imported to the autocad geometry of the area
Coordinate depth
selecting it all at once would be nice, but if autocad cant complile all the info at once we have to look into another possible.
Have a code that works nice but lost internet fcc connection. Not sure if pic helps but here it is.
You need to set UCS first that each text would be at grid 1,1
Hth
Hi @ВeekeeCZ
what do you mean with the UCS grid 1.1 ?
ive tried the code:
(defun c:RemoveInnerTexts (/ s p i e p x y l yl s)
(if (setq s (ssget '((0 . "TEXT"))))
(repeat (setq i (sslength s))
(setq e (ssname s (setq i (1- i)))
p (trans (cdr (assoc 11 (entget e))) 0 1)
x (atof (rtos (car p) 2 0))
y (rtos (cadr p) 2 0)
l (if (setq a (assoc y l))
(subst (append a (list (cons x e)))
a l)
(cons (list y (cons x e)) l)))))
(foreach yl l
(setq yl (vl-sort (cdr yl) '(lambda (x1 x2) (< (car x1) (car x2))))
s (list (car yl)))
(foreach x (cdr yl)
(if (equal (- (car x) (car s)) 1. 1.)
(setq s (cons x s))
(progn
(foreach e (cdr (reverse (cdr s)))
(entdel (cdr e)))
(set q s (list x)))))
(foreach e (cdr (reverse (cdr s)))
(entdel (cdr e))))
(princ)
)
but i am getting this error: bad argument type....
You've done a pretty decent job... but two typos in the code. HERE is how to establish UCS.
(defun c:RemoveInnerTexts (/ s i e p x y l Yline x-of-Yline s) (if (setq s (ssget '((0 . "TEXT")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) p (trans (cdr (assoc 11 (entget e))) 0 1) x (atof (rtos (car p) 2 0)) y (rtos (cadr p) 2 0) l (if (setq a (assoc y l)) (subst (append a (list (cons x e))) a l) (cons (list y (cons x e)) l))))) (foreach yl l ; y-line list of all xs (setq yl (vl-sort (cdr yl) '(lambda (x1 x2) (< (car x1) (car x2)))) ; sort y-line items by x s (list (car yl))) ; start 1st section (foreach x (cdr yl) ; for each x of y-line (if (equal (- (car x) (caar s)) 1. 1.) ; if next is by 1 from previsous (setq s (cons x s)) ; add x to section (progn (foreach e (cdr (reverse (cdr s))) ; else: all inners of previous section (entdel (cdr e))) ; remove (setq s (list x))))) ; and start new section (foreach e (cdr (reverse (cdr s))) ; last section... all inner items (entdel (cdr e)))) ; remove (princ) )
BTW The routine works just in a horizontal direction.
It would not be too much trouble include vertical direction too - the same thing would be applied with switched X-Y coords. Then would be removed just those texts which are inner in both.
hi @ВeekeeCZ
i am reaching out again maybe you have an idea,
the macro you gave me is working good, but still i have a pretty big drawing to compile, and a bit more simplification would be appreciated, if you can help me out.
my question,
the current data (depth texts) are now in an array representing 1m distance between each measurement/coordinate.
is there a way that i can filter out or run a macro that wil simply the drawing, and remove info that at the end it will be arrays representing 5m ( or even with edit later 10m) ? and then that i can change the text height from 0.20 to a bigger one, to get a better overview ?
like this:
(see attached example 2 dwg)
i had something like this in mind
i've attached a example dwg of the original data, maybe you understand at what step it is best to perform each sort of simplification.
and this is the filter i am using to isolate the .0 and .5 values
regards,
(defun c:RemoveOffGrid (/ s g f i e p) (if (and (setq s (ssget '((0 . "TEXT")))) (setq g (cond ((getdist "\nGrid <5.0>: ")) (5.0))) (setq f (cond ((getreal "\nFuzz <0.4>:")) (0.4))) ) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) p (trans (cdr (assoc 11 (entget e))) 0 1)) (if (not (and (equal (rem (car p) g) 0 f) (equal (rem (cadr p) g) 0 f))) (entdel e)))) (princ) )
Notes:
- again, adjust UCS same way as before
- considering the scale, UCS goes off with distance. So added fuzz to partially accommodate that.
- learn about the REM function HERE The routine removes text if a reminder of Xucs/grid AND Yucs/grid is NOT 0+- fuzz.
Can't find what you're looking for? Ask the community or share your knowledge.