Dimension Line Break Notification?

Dimension Line Break Notification?

johnw
Collaborator Collaborator
474 Views
6 Replies
Message 1 of 7

Dimension Line Break Notification?

johnw
Collaborator
Collaborator

I have a lisp routine that will check my drawing for any dimension that has been modified (text override to have dimension say something different) and it turns those modified dimension strings to WHITE, which for us is a heavy lineweight and easily stands out. Then a sub-routine turns dims back to bylayer after I've reviewed. I've attached the routine.

Question is there a way to modify this code to create a new routine to check to see if a dimension line has been broken due to dim text being too close to the dimension line (not relating to DIMBREAK command)?

 

Any assistance would be appreciated.

 

Thanks,

John

0 Likes
475 Views
6 Replies
Replies (6)
Message 2 of 7

Moshe-A
Mentor
Mentor

@johnw  hi,

 

Here is S2CD command (Select too Close Dimtxt)

it's is base on autolisp function (textbox) building a virtual box around the dimtxt than checking if the box is crossing the dimension line. the result from (textbox) is not always very accurate so give it try and will fix it along the road 😀 

 

enjoy

Moshe

 

(vl-load-com)

 ;; Intersections  -  Lee Mac
 ;; Returns a list of all points of intersection between two objects
 ;; for the given intersection mode.
 ;; ob1,ob2 - [vla] VLA-Objects
 ;;     mod - [int] acextendoption enum of intersectwith method

 (defun LM:intersections ( ob1 ob2 mod / lst rtn )
    (if (and (vlax-method-applicable-p ob1 'intersectwith)
             (vlax-method-applicable-p ob2 'intersectwith)
             (setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
        )
        (repeat (/ (length lst) 3)
            (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
                  lst (cdddr lst)
            )
        )
    )
    (reverse rtn)
 ); LM:intersections


; Select too Close Dimensions
(defun c:s2cd (/ acadObj adoc ss0 ss1 elist p10 p11 p12 p13 p14 rot text rottxt hgt gap tb hortxt vertxt t0 t1 t2 t3 AcDbLine AcDbPLine)
 (setvar "cmdecho" 0)
  
 (setq acadObj (vlax-get-acad-object))
 (setq adoc (vla-get-activedocument acadObj))
 (vla-startUndoMark adoc) 
  
 (if (setq ss0 (ssget '((0 . "dimension"))))
  (progn
   (setq ss1 (ssadd))
   
   (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss0)))
    (setq elist (entget ename))
    (if (wcmatch (cdr (assoc '100 (reverse elist))) "AcDbRotatedDimension,AcDbAlignedDimension")
     (progn 
      (setq p13 (cdr (assoc '13 elist))) 
      (setq p14 (cdr (assoc '14 elist)))
      (setq p10 (cdr (assoc '10 elist)))
      (setq p11 (cdr (assoc '11 elist)))

      (cond
       ((eq (cdr (assoc '100 (reverse elist))) "AcDbAlignedDimension")
        (setq rot (angle p13 p14)) 
       
        (if (or
	      (not (setq rottxt (cdr (assoc '53 elist))))
	      (= (cdr (assoc '53 elist)) 0.0)
	    )
         (setq rottxt (angle p13 p14)) 
        )
       ); case
       ( t
        (setq rot (cdr (assoc '50 elist)))
      
        (if (or
	      (not (setq rottxt (cdr (assoc '53 elist))))
	      (= (cdr (assoc '53 elist)) 0.0)
	    )
         (setq rottxt (cdr (assoc '50 elist)))
        );  
       ); case
      ); cond
    
      (if (eq (setq text (cdr (assoc '1 elist))) "")
       (setq text (vl-princ-to-string  (cdr (assoc '42 elist))))
      )

      (setq hgt (getpropertyvalue ename "dimtxt"))
      (setq gap (getpropertyvalue ename "dimgap"))

      (setq tb (textbox (list (cons '1 text) (cons '40 (+ gap hgt)))))

      (setq hortxt (- (caadr tb ) (caar tb )))
      (setq vertxt (- (cadadr tb) (cadar tb)))

      (setq t0 (polar (polar p11 (+ rottxt pi) (/ hortxt 2)) (+ rottxt (* pi 1.5)) (/ vertxt 2)))
      (setq t1 (polar t0 rottxt hortxt))
      (setq t2 (polar t1 (+ rottxt (* pi 0.5)) vertxt))
      (setq t3 (polar t0 (+ rottxt (* pi 0.5)) vertxt))
    
      (command "._pline" t0 t1 t2 t3 "_Close")
      (setq AcDbPLine (vlax-ename->vla-object (entlast))) 

      (setq p12 (polar p10 (+ rot pi) (cdr (assoc '42 elist))))
      (command "._line" p12 p10 "")
      (setq AcDbLine (vlax-ename->vla-object (entlast))) 

      (if (LM:intersections AcDbLine AcDbPLine acExtendNone)
       (ssadd ename ss1)
      )

      (foreach o (list AcDbLine AcDbPLine)
       (vla-delete o) 
       (vlax-release-object o)
      )
     ); progn
    ); if
   ); foreach

   (if (/= (sslength ss1) 0)
    (sssetfirst ss1 ss1)
   )
   
  ); progn
 ); if

 (vla-endUndoMark adoc)
 (setvar "cmdecho" 1)
   
 (princ) 
); c:s2cd

 

0 Likes
Message 3 of 7

johnw
Collaborator
Collaborator

I placed a dimension and pulled the dim text down until the dimension line 'broke', then ran this command and nothing happened. I don't know what the outcome is supposed to be but nothing changes on my end.

0 Likes
Message 4 of 7

Moshe-A
Mentor
Mentor

@johnw ,

 

post sample dwg

 

0 Likes
Message 5 of 7

johnw
Collaborator
Collaborator

Sample drawing attached. Shows a few dimensions that look correct as well as incorrect.

0 Likes
Message 6 of 7

Moshe-A
Mentor
Mentor

@johnw ,

 

fixed

 

 

 

 

 

(vl-load-com)

 ;; Intersections  -  Lee Mac
 ;; Returns a list of all points of intersection between two objects
 ;; for the given intersection mode.
 ;; ob1,ob2 - [vla] VLA-Objects
 ;;     mod - [int] acextendoption enum of intersectwith method

 (defun LM:intersections ( ob1 ob2 mod / lst rtn )
    (if (and (vlax-method-applicable-p ob1 'intersectwith)
             (vlax-method-applicable-p ob2 'intersectwith)
             (setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
        )
        (repeat (/ (length lst) 3)
            (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
                  lst (cdddr lst)
            )
        )
    )
    (reverse rtn)
 ); LM:intersections


; Select too Close Dimensions
(defun c:s2cd (/ acadObj adoc ss0 ss1 elist p10 p11 p12 p13 p14 rot text rottxt dimscl hgt gap tb hortxt vertxt t0 t1 t2 t3 AcDbLine AcDbPLine)
 (setvar "cmdecho" 0)
  
 (setq acadObj (vlax-get-acad-object))
 (setq adoc (vla-get-activedocument acadObj))
 (vla-startUndoMark adoc) 
  
 (if (setq ss0 (ssget '((0 . "dimension"))))
  (progn
   (setq ss1 (ssadd))
   
   (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss0)))
    (setq elist (entget ename))
    (if (wcmatch (cdr (assoc '100 (reverse elist))) "AcDbRotatedDimension,AcDbAlignedDimension")
     (progn 
      (setq p13 (cdr (assoc '13 elist))) 
      (setq p14 (cdr (assoc '14 elist)))
      (setq p10 (cdr (assoc '10 elist)))
      (setq p11 (cdr (assoc '11 elist)))

      (cond
       ((eq (cdr (assoc '100 (reverse elist))) "AcDbAlignedDimension")
        (setq rot (angle p13 p14)) 
       
        (if (or
	      (not (setq rottxt (cdr (assoc '53 elist))))
	      (= (cdr (assoc '53 elist)) 0.0)
	    )
         (setq rottxt (angle p13 p14)) 
        )
       ); case
       ( t
        (setq rot (cdr (assoc '50 elist)))
      
        (if (or
	      (not (setq rottxt (cdr (assoc '53 elist))))
	      (= (cdr (assoc '53 elist)) 0.0)
	    )
         (setq rottxt (cdr (assoc '50 elist)))
        );  
       ); case
      ); cond
      
      (if (eq (setq text (cdr (assoc '1 elist))) "")
       (setq text (rtos (cdr (assoc '42 elist)) (getpropertyvalue ename "dimlunit"))) 	
      )

      (setq dimscl (getpropertyvalue ename "dimscale"))
      (setq hgt (* dimscl (getpropertyvalue ename "dimtxt")))
      (setq gap (* dimscl (getpropertyvalue ename "dimgap")))

      (setq tb (textbox (list (cons '1 text) (cons '40 (+ gap hgt)))))

      (setq hortxt (- (caadr tb ) (caar tb )))
      (setq vertxt (- (cadadr tb) (cadar tb)))

      (setq t0 (polar (polar p11 (+ rottxt pi) (/ hortxt 2)) (+ rottxt (* pi 1.5)) (/ vertxt 2)))
      (setq t1 (polar t0 rottxt hortxt))
      (setq t2 (polar t1 (+ rottxt (* pi 0.5)) vertxt))
      (setq t3 (polar t0 (+ rottxt (* pi 0.5)) vertxt))
    
      (command "._pline" t0 t1 t2 t3 "_Close")
      (setq AcDbPLine (vlax-ename->vla-object (entlast))) 

      (setq p12 (polar p10 (+ rot pi) (cdr (assoc '42 elist))))
      (command "._line" p12 p10 "")
      (setq AcDbLine (vlax-ename->vla-object (entlast))) 

      (if (LM:intersections AcDbLine AcDbPLine acExtendNone)
       (ssadd ename ss1)
      )

      (foreach o (list AcDbLine AcDbPLine)
       (vla-delete o) 
       (vlax-release-object o)
      )
     ); progn
    ); if
   ); foreach

   (if (/= (sslength ss1) 0)
    (sssetfirst ss1 ss1)
   )
   
  ); progn
 ); if

 (vla-endUndoMark adoc)
 (vlax-release-object adoc)
 (setvar "cmdecho" 1)

  
 (princ) 
); c:s2cd
0 Likes
Message 7 of 7

johnw
Collaborator
Collaborator

Is there a way put a circle around the dim text, or change the dimension to color white? It is still difficult to see what dimensions were 'selected' by this routine. Thank you.

0 Likes