Identify the intersections of polylines and dimension

Identify the intersections of polylines and dimension

janu319
Advocate Advocate
2,915 Views
22 Replies
Message 1 of 23

Identify the intersections of polylines and dimension

janu319
Advocate
Advocate

Hallo,

 

Can someone please help me, if there is an easy way to Identify the intersection of polylines and dimensions(Aligned Dimensions) in a drawing, the extension lines may intersect.

 

Thanks in advance.

0 Likes
Accepted solutions (1)
2,916 Views
22 Replies
Replies (22)
Message 2 of 23

ronjonp
Mentor
Mentor

You could use THIS as a start. Pull all the parts out of the dimensions then use vla-intersectwith on all objects in your selection set.

0 Likes
Message 3 of 23

Sea-Haven
Mentor
Mentor

The one issue would be a extension line normally has a gap at the base so could miss a intersection, so make a xline for intersection. Just guessing would using the 4 points of the dim as a pline maybe work, dxf 13 & 14 come to mind.

0 Likes
Message 4 of 23

devitg
Advisor
Advisor

As DIM dxf code 11 , it is the dim text  insertion point ,  this get the intersection point 

(VLAX-CURVE-GETCLOSESTPOINTTO line dim-11)

  

0 Likes
Message 5 of 23

ronjonp
Mentor
Mentor

@Sea-Haven wrote:

The one issue would be a extension line normally has a gap at the base so could miss a intersection, so make a xline for intersection. Just guessing would using the 4 points of the dim as a pline maybe work, dxf 13 & 14 come to mind.


If there is a gap then there is not an intersection?

0 Likes
Message 6 of 23

john.uhden
Mentor
Mentor

I haven't looked at your drawing, so I don't know if you are trying to clean up overwrites, but I learned this year that newer versions of AutoCAD have a DIM;Break option that breaks the dimension line where crossing another object.  No, it doesn't explode and trim it.  It is very polite.

John F. Uhden

0 Likes
Message 7 of 23

janu319
Advocate
Advocate

Thank you for your suggestion, I actually suppress the extension lines temporarily and reduced the arrow size almost to zero, and text is aligned with the dimension line and above it.

So, I see only lines when I explode the dimensions, so I want to find the intersection of these lines and already existing polylines. There are no other line objects in the drawing before I explode the dimensions.

I searched few other posts but, couldn't find one which runs for entire drawing(without selection). Is it possible to find the intersections of "line" objects and "polyline" objects for entire drawing quickly? Say, create a circle in Zero layer or someting similar. 

 

I also attached the drawings(created for this question), Dimensions_1 is original drawing and Dimensions_2 is after exploding the dimensions.

 

Thanks you all for your time. 

0 Likes
Message 8 of 23

janu319
Advocate
Advocate

Hi John, thank you for the tip..

I should have uploaded the sample drawing, sorry for that. When there is an intersection, I need to modify the dimension such that the dimension line should not cross the polyline.

0 Likes
Message 9 of 23

john.uhden
Mentor
Mentor
Ya know, it's not very difficult to clone the linework in a dimension. You
just study the relationships of the 10, 11, 12, 13, and 14 codes. In that
way you could entmake the linework (without exploding the dimension) and
vla-intersectwith whatever you want.
Of course you could explode, gather up all the line data, and then Undo.

John F. Uhden

0 Likes
Message 10 of 23

Sea-Haven
Mentor
Mentor

Like John and Devitg look at the dxf points can do a (ssget "F" pt1  pt2 and find the line crossing then a temp line for intersectwith so find correct point. You can use the (Inters function as well if you want to use non VL lisp. I can see now you want to correct dimension errors.

 

SeaHaven_0-1640655528829.png

 

 

0 Likes
Message 11 of 23

devitg
Advisor
Advisor

@Sea-Haven 

@john.uhden 

 

 my first attempt was this code 

;************************************************************

;; Design by Gabo CALOS DE VIT from CORDOBA ARGENTINA
;;;    Copyleft 1995-2021 by Gabriel Calos De Vit ; DEVITG@GMAIL.COM    
;;




;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/



(DEFUN &-CIRCLE-CO/P1-R1-CO  (P1 R1 CO)
  (IF (= (TYPE P1) 'LIST)
    (SETQ P1 (VLAX-3D-POINT P1)))
  (IF (= CO NIL)
    (SETQ CO ACBYLAYER)
    )
  (SETQ CIRCLE# (VLA-ADDCIRCLE MODEL P1 R1))
  (VLA-PUT-COLOR CIRCLE# CO)
  CIRCLE#
  )
;;************************************************************
;;********************************************************************************************************
(DEFUN CODE/COD-ENT  (COD ENT) ;-001
  (CDR (ASSOC COD (ENTGET ENT)))
  )

;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
;;;Copyright ©2005 - Marc'Antonio Alessi, Italy - All rights reserved-01
;; http://xoomer.virgilio.it/alessi
(defun ALE_EntSelFilter	 (PrmStr FltLst / FlgSlt EntNam)
  (setvar "ERRNO" 0)
  (princ "\n_ ")
  (prompt (setq PrmStr (strcat "\n" PrmStr ": ")))
  (if
    (while (not FlgSlt)
      (if (setq EntNam (ssget "_:E:S" FltLst))
	(not (setq FlgSlt T))
	(if (= 52 (getvar "ERRNO"))
	  (setq FlgSlt T)
	  (alert
	    ;(strcat "\nUd no entendió lo que le pedí, pruebe de nuevo!"		    PrmStr)
	    (strcat "\nYou did not understood what I ask for , try it again!"   PrmStr)
	    )
	  ) ;_if 
	) ;_if
      ) ;_while
     (not (princ "\nFunction cancelled. "))
     (ssname EntNam 0)
     ) ;_if
  ) ;_defun
;;usage
;;(ALE_EntSelFilter "Seleccione la poly del terreno" '((0 . "POLYLINE") (100 . "AcDb3dPolyline")))





;;;inicia-inter-line-dim
;;;*************************************************************;;;


(defun intersect-dim-line (/ ACAD-OBJ ADOC CIRC-RAD CIRCLE COLOR DIM DIM-11  LINE
                           MODEL
                          )

  (VL-LOAD-COM)
  (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT)) ;_  ACAD program
  (SETQ ADOC (VLA-GET-ACTIVEDOCUMENT ACAD-OBJ)) ;_ active  DWG 
  (SETQ MODEL (VLA-GET-MODELSPACE ADOC)) ; model space 

  (setq line (ALE_ENTSELFILTER "Select the line or poline " '((0 . "*line*"))))
  (setq dim (ALE_ENTSELFILTER "Select the DIM " '((0 . "*dim*"))))
(setq dim-10 (CODE/COD-ENT 10 dim)) ; line text insertion point
(setq dim-11 (CODE/COD-ENT 11 dim)) ; dim text insertion point
(setq dim-12 (CODE/COD-ENT 12 dim)) ; dim text insertion point
(setq dim-13 (CODE/COD-ENT 13 dim)) ; first line text insertion point
(setq dim-14 (CODE/COD-ENT 14 dim)) ; second text insertion point

 (setq  dim-10-3 (list (car dim-13 ) (cadr dim-10) (last dim-10))) ;it depend is HOR VERT or rotated 
;;;(10.3944 7.30746 0.0) 
;;;(7.08737 7.30746 0.0) 
;;;(0.0 0.0 0.0) 
;;;(3.78038 5.25223 0.0) 
;;;(10.3944 5.25223 0.0) 
;;;(3.78038 7.30746 0.0) 
;;;


  
  (setq circ-rad 2.0) ;change as need
  (setq color 11) ;change as need
  (setq int-pt-dimxline (VLAX-CURVE-GETCLOSESTPOINTTO line dim-11)) ;the point at intersection
  (setq circle (&-CIRCLE-CO/P1-R1-CO int-pt-dimxline circ-rad color)) ;the circle 
) ;_  defun
(alert "\ntype lxd at command line ")
;end DEFUN intersect-dim-line 
(defun C:lxd ()
  (intersect-dim-line)
  
) ;_  defun

 It only depend from DXF 11 , and get the closest point to the line or pline 

Of course text, shall be justified  middle center ,  as it is show at the OP dwg 

The OP , ask if it could be made to get all intersection at once.  

 

 

0 Likes
Message 12 of 23

ronjonp
Mentor
Mentor
Accepted solution

Here's some quick code to identify if the arrow heads are crossing an object:

 

(defun c:foo (/ a d dms el p s)
  ;; RJP » 2021-12-28
  (cond	((setq s (ssget))
	 (setq d (vla-get-activedocument (vlax-get-acad-object)))
	 (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (if (= "DIMENSION" (cdr (assoc 0 (entget e))))
	     (vlax-for a (vla-item (vla-get-blocks d) (cdr (assoc 2 (setq el (entget e)))))
	       (if (= "AcDbSolid" (vla-get-objectname a))
		 (setq dms (cons a dms))
	       )
	     )
	     (setq a (cons (vlax-ename->vla-object e) a))
	   )
	 )
	)
  )
  (foreach o dms
    (if	(vl-some '(lambda (x) (> (length (setq p (vlax-invoke o 'intersectwith x 0))) 3)) a)
      (entmake (list '(0 . "POINT") (cons 10 (mapcar '+ p '(0 0 0))) '(8 . "BadJuJu")))
    )
  )
  (setvar 'pdmode 3)
  (princ)
)

 

ronjonp_0-1640725034056.png

This should do both as long as the dim line color is blue.

(defun c:foo (/ a d dms el lns p s)
  ;; RJP » 2021-12-28
  (cond	((setq s (ssget))
	 (setq d (vla-get-activedocument (vlax-get-acad-object)))
	 (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (if (= "DIMENSION" (cdr (assoc 0 (entget e))))
	     (vlax-for a (vla-item (vla-get-blocks d) (cdr (assoc 2 (setq el (entget e)))))
	       (cond ((= "AcDbSolid" (vla-get-objectname a)) (setq dms (cons a dms)))
		     ((and (= "AcDbLine" (vla-get-objectname a)) (= (vla-get-color a) 5))
		      (setq lns (cons a lns))
		     )
	       )
	     )
	     (setq a (cons (vlax-ename->vla-object e) a))
	   )
	 )
	)
  )
  (foreach o dms
    (if	(vl-some '(lambda (x) (> (length (setq p (vlax-invoke o 'intersectwith x 0))) 3)) a)
      (while p
	(entmake (list '(0 . "POINT") (cons 10 (mapcar '+ p '(0 0 0))) '(8 . "BadJuJu")))
	(setq p (cdddr p))
      )
    )
  )
  (foreach o lns
    (if	(vl-some '(lambda (x) (setq p (vlax-invoke o 'intersectwith x 0))) a)
      (while p
	(entmake (list '(0 . "POINT") (cons 10 (mapcar '+ p '(0 0 0))) '(8 . "BadJuJu")))
	(setq p (cdddr p))
      )
    )
  )
  (setvar 'pdmode 3)
  (princ)
)

 

0 Likes
Message 13 of 23

john.uhden
Mentor
Mentor
@ronjonp
And what about PDSIZE?

"BadJuJu"
But what's with (cons 10 (mapcar '+ p '(0 0 0)))?

John F. Uhden

0 Likes
Message 14 of 23

ronjonp
Mentor
Mentor

@john.uhden  I figured the default is 0 for PDSIZE so need to mess with it. The other 'trick' is Lee's get first N items.

 

 

(setq l '(1 2 3 4 5 6))
;; This
(mapcar '+ l '(0 0 0))
;; or this
(list (car l) (cadr l) (caddr l))
;; Potayto potawto 🙂

 

 

 

0 Likes
Message 15 of 23

john.uhden
Mentor
Mentor
@ronjonp
Ah, that is clever, well, unless the list is strings. 😕
That's where my @group function comes in.
But my @Anonymous function could be:
(defun @Anonymous (p)
(mapcar '+ p '(0 0))
)
I think I will use that instead of car, cadr.
Many thanks!

John F. Uhden

0 Likes
Message 16 of 23

ronjonp
Mentor
Mentor

@john.uhden wrote:
@ronjonp
Ah, that is clever, well, unless the list is strings. 😕
That's where my @group function comes in.
But my @Anonymous function could be:
(defun @Anonymous (p)
(mapcar '+ p '(0 0))
)
I think I will use that instead of car, cadr.
Many thanks!

Glad to help 🙂

 

Side topic, I've seem to lost my beer clinks ... is this the same for you?

ronjonp_0-1640805091641.png

 

0 Likes
Message 17 of 23

john.uhden
Mentor
Mentor
@ronjonp
I'm not hip. What's a beer clink?
Guess I lost mine too.

John F. Uhden

0 Likes
Message 18 of 23

ronjonp
Mentor
Mentor

@john.uhden 

Existing posts now show up like this on the forum: :clinking_beer_mugs:

 

0 Likes
Message 19 of 23

devitg
Advisor
Advisor

@john.uhden et al 

My way 

 

;;************************************************************
(DEFUN BUTLAST  (LST)
  (REVERSE (CDR (REVERSE LST)))
  
  )

 

0 Likes
Message 20 of 23

john.uhden
Mentor
Mentor
You are cool too, Gabe.
That's sorta like appending...
Command: (setq a '(1 2 3) b '(4 5))
(4 5)

Command: (append a b) (1 2 3 4 5)

Command: (defun addon (a b) (reverse (cons b (reverse a))))
ADDON

Command: (addon a b)
(1 2 3 (4 5))
but it's good only for appending one item to a list.
so it should be called addone.
Command: (addon a 4)
(1 2 3 4)

John F. Uhden

0 Likes