LISP - draw line between selected linear and aligned dimensions

LISP - draw line between selected linear and aligned dimensions

cool.stuff
Collaborator Collaborator
745 Views
8 Replies
Message 1 of 9

LISP - draw line between selected linear and aligned dimensions

cool.stuff
Collaborator
Collaborator

Hello 🙂

 

I would like to ask for help.

I have a lot of disassociated linear and aligned dimensions and I need to draw a line between each dimensions' points.

 

I have searched in forum and net and I have found nothing.

 

Is this possible?

Can someone give a hand please?

 

Thanks

0 Likes
Accepted solutions (4)
746 Views
8 Replies
Replies (8)
Message 2 of 9

Kent1Cooper
Consultant
Consultant
Accepted solution

If by "points" you mean the two definition points that the Dimension measures between, try this [in simplest terms, minimally tested]:

(defun C:LDDP ; = Lines between Dimension Definition-Points
  (/ ss n dim ddata)
  (if (setq ss (ssget '((0 . "DIMENSION"))))
    (repeat (setq n (sslength ss))
      (setq
        dim (ssname ss (setq n (1- n)))
        ddata (entget dim)
      ); setq
      (if (= (logand (cdr (assoc 70 ddata)) 6) 0)
        ;; linear/rotated/aligned, NOT angular/radius/diameter/ordinate
        ;; i.e. 70-code value does not contain either 2 or 4 bit
        (command "_.line" ; then
          "_non" (cdr (assoc 13 ddata))
          "_non" (cdr (assoc 14 ddata))
          ""
        ); command
      ); if
    ); repeat
  ); if
  (prin1)
)

It draws the Lines on the current Layer and with all current Property settings, but of course could be expanded to be more particular.  And it could use some other things, like Undo begin/end wrapping.

Kent Cooper, AIA
0 Likes
Message 3 of 9

komondormrex
Mentor
Mentor
Accepted solution

hey,

in most simplest terms

(defun c:dim_line (/ dim_sset dimension_dxf)
  (if (setq dim_sset (ssget '((0 . "dimension"))))
    (foreach dimension (vl-remove-if 'listp (mapcar 'cadr (ssnamex dim_sset)))
      (setq dimension_dxf (entget dimension))
      (entmakex (list '(0 . "line") (assoc 8 dimension_dxf) (cons 10 (cdr (assoc 13 dimension_dxf))) (cons 11 (cdr (assoc 14 dimension_dxf)))))
    )
  )
  (princ)
)
0 Likes
Message 4 of 9

Kent1Cooper
Consultant
Consultant

That works fine for linear/aligned/rotated Dimensions, and it seems to do nothing with radius/diameter Dimensions so maybe it doesn't matter with them, but it should recognize and bypass angular and ordinate Dimensions, which it does funny things with [green are the Lines it draws]:

Kent1Cooper_0-1742837444492.png

 

Kent Cooper, AIA
Message 5 of 9

cool.stuff
Collaborator
Collaborator

Many thanks 🙂 works perfectly 🙂

0 Likes
Message 6 of 9

cool.stuff
Collaborator
Collaborator

Many thanks 🙂 works like a charm 🙂

0 Likes
Message 7 of 9

cool.stuff
Collaborator
Collaborator

Thanks for the help @Kent1Cooper 🙂

I only have linear/aligned/rotated Dimensions, so I am very pleased with your solution 🙂

 

Again, many thanks for saving me hours of work 🙂

0 Likes
Message 8 of 9

Kent1Cooper
Consultant
Consultant
Accepted solution

@Kent1Cooper wrote:
....
      (if (= (logand (cdr (assoc 70 ddata)) 6) 0)
        ;; linear/rotated/aligned, NOT angular/radius/diameter/ordinate
        ;; i.e. 70-code value does not contain either 2 or 4 bit
        (command "_.line" ; then
....

 


Come to think of it, the ignoring of the "wrong" varieties of Dimensions can be done within the object selection [line 3], rather than by accepting all Dimensions in selection and then checking each one in the processing:

(defun C:LDDP ; = Lines between Dimension Definition-Points
  (/ ss n dim ddata)
  (if (setq ss (ssget '((0 . "DIMENSION") (-4 . "<NOT") (-4 . "&") (70 . 6) (-4 . "NOT>"))))
    (repeat (setq n (sslength ss))
      (setq
        dim (ssname ss (setq n (1- n)))
        ddata (entget dim)
      ); setq
      (command "_.line" ; then
        "_non" (cdr (assoc 13 ddata))
        "_non" (cdr (assoc 14 ddata))
        ""
      ); command
    ); repeat
  ); if
  (prin1)
)

 

Kent Cooper, AIA
Message 9 of 9

komondormrex
Mentor
Mentor
Accepted solution

althou i did mention that the code provided is the simplest one i suggest @cool.stuff a slightly complicated one, dealing  with aligned and rotated dims only

(defun c:dim_line (/ dim_sset dimension_dxf)
  (if (setq dim_sset (ssget '((0 . "dimension"))))
    (foreach dimension (vl-remove-if 'listp (mapcar 'cadr (ssnamex dim_sset)))
      (setq dimension_dxf (entget dimension))
	  (if (member (cdr (assoc 100 (reverse dimension_dxf))) '("AcDbAlignedDimension" "AcDbRotatedDimension"))
      	(entmakex (list '(0 . "line") (assoc 8 dimension_dxf) (cons 10 (cdr (assoc 13 dimension_dxf))) (cons 11 (cdr (assoc 14 dimension_dxf)))))
	  )
    )
  )
  (princ)
)

 

0 Likes