Cleanup dimensions that crossover each other?

Cleanup dimensions that crossover each other?

mid-awe
Collaborator Collaborator
1,522 Views
10 Replies
Message 1 of 11

Cleanup dimensions that crossover each other?

mid-awe
Collaborator
Collaborator

Hi all,

 

Does anyone have a lisp that will remove dimensions that crossover each other. I would say, "Dimensions that intersect each other" but that is wrong. I don't want to delete dimensions that intersect only at their ends, but rather, if the dimensions crossover or intersect anywhere other than at their endpoint I want to delete the longer dimension entity.

 

Does anyone have a lisp to do that already or will anyone help me?

 

Thank you in advance for any help / advice. 

0 Likes
Accepted solutions (1)
1,523 Views
10 Replies
Replies (10)
Message 2 of 11

Kent1Cooper
Consultant
Consultant

A sample drwing or image showing the kind(s) of relationship(s) you're talking about, and not talking about, would be helpful.  [For instance, it sounds to me like you mean only Dimensions running in the same direction whose dimensioned lengths overlap, but your description could be interpreted otherwise.]

Kent Cooper, AIA
0 Likes
Message 3 of 11

mid-awe
Collaborator
Collaborator

Right you are. I constantly assume that my description is clear. 

 

I have attached a dwg that I hope is clearer.

0 Likes
Message 4 of 11

mid-awe
Collaborator
Collaborator

Sorry Kent,

 

I made an error with the dwg. If the dimension is connecting two blocks, then I need to keep it and delete the other dimension that crosses no matter the length. (totally my mistake, and I appologize.)

 

Thank you for any help.

0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant

The description in the drawing isn't quite correct.  The two vertical red-text Dimensions that hit the top edge [6'-0" and 5'-5"] are each shorter than the horizontal ones they cross over -- according to the description, those horizontal ones should be the ones deleted.  If you really want to delete the red ones, can you refine the criteria?  Delete the one of such a pair that meets the perimeter, perhaps?  Post 4's text [not the description in the drawing] sounds like that, and it's true of all your red-text ones, but maybe it wouldn't always be.

 

As for determining whether two Dimensions overlap in that way, in the case of no-extension-line Dimensions like these, their DXF-code 13 and 14 entries [definition points] can be collected into a list, and (inters) can be (apply)'d to that list without the 'onseg' argument, and if there is a result that is not a (member) of the same list, then they cross but don't meet at ends.  [It might be necessary to compare the result to each item in the list with (equal) and a small fuzz factor, rather than use (member).]  The stepping through each Dimension and comparing it in that way with all others would seem to be the tedious part.  Depending on the answer to the issue in the first paragraph above, it might also be necessary to compare them to the perimeter, which the User would presumably need to select unless it's always the only Polyline on its Layer, or can otherwise be tied down for the routine to find on its own.

Kent Cooper, AIA
0 Likes
Message 6 of 11

mid-awe
Collaborator
Collaborator

I have corrected the criteria description.

 

(It is safe to say that if BOTH end-points of the dimension coincides with another dimension's end-point, then that dimension entity should NOT be deleted.)

 

the corrected dwg is attached.

 

Thanks Kent for the prompting.

0 Likes
Message 7 of 11

hmsilva
Mentor
Mentor
Accepted solution

Hi mid-awe,

quick and dirty, and minimally tested, but it may get you started (sorry, large workload...):

 

(defun c:demo (/ dimblk dimblks dims ent hnd i ins ss typ)
    (if (setq ss (ssget '((0 . "DIMENSION,INSERT"))))
        (progn
            (repeat (setq i (sslength ss))
                (setq hnd (ssname ss (setq i (1- i)))
                      ent (entget hnd)
                      typ (cdr (assoc 0 ent))
                )
                (if (= typ "INSERT")
                    (setq ins (cons (cdr (assoc 10 ent)) ins))
                    (setq dims (cons (list hnd (cdr (assoc 13 ent)) (cdr (assoc 14 ent))) dims))
                )
            )
            (if (and ins dims)
                (progn
                    (foreach d dims
                        (if (and (vl-some '(lambda (x) (equal x (cadr d) 1e-6)) ins)
                                 (vl-some '(lambda (x) (equal x (caddr d) 1e-6)) ins)
                            )
                            (setq dimblks (cons d dimblks))
                            (setq dimblk (cons d dimblk))
                        )
                    )
                    (if (and dimblks dimblk)
                        (foreach d dimblk
                            (vl-some '(lambda (x)
                                          (and (setq int (inters (cadr d) (caddr d) (cadr x) (caddr x)))
                                               (not (vl-some '(lambda (a) (equal int (cadr a) 1e-6)) dimblks))
                                               (not (vl-some '(lambda (a) (equal int (caddr a) 1e-6)) dimblks))
                                               (entmod (subst (cons 8 "ToDelete") (assoc 8 dimdel) (setq dimdel (entget (car d)))))
                                          )
                                      )
                                     dimblks
                            )
                        )
                    )
                )
            )
        )
    )
    (princ)
)

 

Hope this helps,
Henrique

EESignature

Message 8 of 11

mid-awe
Collaborator
Collaborator
Henrique,

Brilliant 🙂 It works beautifully. I only made a few adjustments for the sake of seamless automation and to delete the "ToDelete" layer with it's dimensions. Thank you very much; you saved me.
0 Likes
Message 9 of 11

hmsilva
Mentor
Mentor

@mid-awe wrote:
Henrique,

Brilliant 🙂 It works beautifully. I only made a few adjustments for the sake of seamless automation and to delete the "ToDelete" layer with it's dimensions. Thank you very much; you saved me.

You're welcome, mid-awe!
Glad I could help 🙂

 

Please have in mind that the code was just a starting point, and only slightly tested... the "ToDelete" layer was created for visual debugging...

Henrique

EESignature

Message 10 of 11

mid-awe
Collaborator
Collaborator
I can definitely work with it as time permits. I did notice that it does not always succeed, but you have helped enormously. I cannot express how much time I'll save with this. Even as a starting point, this is very useful right now as is.

Again, thank you Henrique.
Message 11 of 11

hmsilva
Mentor
Mentor

@mid-awe wrote:
I can definitely work with it as time permits. I did notice that it does not always succeed, but you have helped enormously. I cannot express how much time I'll save with this. Even as a starting point, this is very useful right now as is.

Again, thank you Henrique.

You're welcome, mid-awe!

Cheers
Henrique

EESignature

0 Likes