LISP - draw center line of a rectangle

LISP - draw center line of a rectangle

cool.stuff
Collaborator Collaborator
2,432 Views
20 Replies
Message 1 of 21

LISP - draw center line of a rectangle

cool.stuff
Collaborator
Collaborator

Hi!!

 

Is is possible to draw the center line of a rectangle polyline along its bigger side?

For instance, when the rectangle has 4 of length and 1 of width, a center line of 4 is drawn.

If it is a square, it is indifferent which side is drawn.

 

Any help would be deeply appreciated.

 

Many many thanks in advance

 

0 Likes
2,433 Views
20 Replies
Replies (20)
Message 2 of 21

komondormrex
Mentor
Mentor
Accepted solution

hey there,

check the code below

(defun c:rect_center_line (/ ename_index ignore_empty_sset ename_sset object
							 center_point skip_ename
							 x_length y_length angle_x angle_y
							 ucs_angle_correction
							 active_layer_locked
						  )
	(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
	(defun half (argument) (* 0.5 argument))
	(setvar 'cmdecho 0)
	(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object))) "CENTER2")))
			(command "._-linetype" "_l" "CENTER2" "acadiso.lin" "")
	)
	(setvar 'cmdecho 1)
	(if (zerop (getvar 'dimcen)) (setvar 'dimcen 2.5))

	(if (and
			(equal (car (getvar 'ucsydir)) (cos (+ (* 0.5 pi) (angle '(0 0) (getvar 'ucsxdir)))) 1e-3)			
			(equal (cadr (getvar 'ucsydir)) (sin (+ (* 0.5 pi) (angle '(0 0) (getvar 'ucsxdir)))) 1e-3)       	
		)
			(setq ucs_angle_correction 1)
			(setq ucs_angle_correction -1)
	)
	(if (minusp (vlax-get (vla-get-activelayer (vla-get-activedocument (vlax-get-acad-object))) 'lock))
			(setq active_layer_locked t)
			(setq active_layer_locked nil)
	)
	(if (null active_layer_locked)
		(repeat (sslength (setq ename_index -1
								ignore_empty_sset (while (null (setq ename_sset (vl-catch-all-apply 'ssget (list (list '(0 . "lwpolyline") '(-4 . "&=") '(70 . 1) '(90 . 4)))))))
								ename_sset (cond
													((vl-catch-all-error-p ename_sset) (princ "\nCommand cancelled") (ssadd))
													(t ename_sset)
										   )
						   )
				)
				(setq object (vlax-ename->vla-object (ssname ename_sset (setq ename_index (1+ ename_index)))) skip_ename nil)
				(cond
						(
							(and
								 (zerop (apply '+ (mapcar 'abs (mapcar 'cdr (vl-remove-if-not '(lambda (group) (= 42 (car group))) (entget (ssname ename_sset ename_index)))))))
								 (equal (distance (vlax-curve-getpointatparam object 0) (vlax-curve-getpointatparam object 2))
									 	(distance (vlax-curve-getpointatparam object 1) (vlax-curve-getpointatparam object 3))
										1e-8
								 )
								 (equal (angle (vlax-curve-getpointatparam object 0) (vlax-curve-getpointatparam object 1))
									 	(angle (vlax-curve-getpointatparam object 3) (vlax-curve-getpointatparam object 2))
										1e-8
								 )
								 (equal (angle (vlax-curve-getpointatparam object 1) (vlax-curve-getpointatparam object 2))
									 	(angle (vlax-curve-getpointatparam object 0) (vlax-curve-getpointatparam object 3))
										1e-8
								 )
							)
								(setq center_point (mapcar 'half (mapcar '+ (vlax-curve-getpointatparam object 0) (vlax-curve-getpointatparam object 2)))
									  angle_x (* ucs_angle_correction (angle (vlax-curve-getpointatparam object 1) (vlax-curve-getpointatparam object 2)))
									  angle_y (* ucs_angle_correction (angle (vlax-curve-getpointatparam object 0) (vlax-curve-getpointatparam object 1)))
									  x_length (* 0.5 (distance (vlax-curve-getpointatparam object 1) (vlax-curve-getpointatparam object 2)))
									  y_length (* 0.5 (distance (vlax-curve-getpointatparam object 0) (vlax-curve-getpointatparam object 1)))
								)
								(if (< x_length y_length) (setq x_length y_length angle_x angle_y))
						)
						(
							t
								(setq skip_ename t)
						)
				)
				(if (null skip_ename)
					(progn
							(vla-put-linetype
								(vla-addline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
											 (vlax-3d-point (polar center_point (* ucs_angle_correction angle_x) (+ x_length (getvar 'dimcen))))
											 (vlax-3d-point (polar center_point (* ucs_angle_correction (+ pi angle_x)) (+ x_length (getvar 'dimcen))))
								)
								"CENTER2"
							)
					)
				)
		)
		(princ "\nActive layer locked. Command cancelled.")
	)
	(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
	(princ)
)
0 Likes
Message 3 of 21

cool.stuff
Collaborator
Collaborator

Works perfectly!!! 🙂

 

many many thanks for your kind help!!! 🙂

0 Likes
Message 4 of 21

Kent1Cooper
Consultant
Consultant
Accepted solution

It seems to me this can be done much more simply:

(defun C:QLCL ; = Quadrilateral Long-direction Center Line
  (/ pap ss n pl dists parA)
  (defun pap (i) (vlax-curve-getPointAtParam pl i))
  (if (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1))))
    (repeat (setq n (sslength ss))
      (setq
        pl (ssname ss (setq n (1- n)))
        dists (list (distance (pap 0.5) (pap 2.5)) (distance (pap 1.5) (pap 3.5)))
        parA (vl-position (apply 'max dists) dists)
      ); setq
      (command
        "_.line" "_non" (pap (+ parA 0.5)) "_non" (pap (+ parA 2.5)) ""
        "_.chprop" (entlast) "" "_ltype" "CENTER" ""
      ); command
    ); repeat
  ); if
  (prin1)
)

It could be made to verify that a given one is actually rectangular, if needed, also I think in a simpler way.

Kent Cooper, AIA
0 Likes
Message 5 of 21

cool.stuff
Collaborator
Collaborator

Could you add the verification that a given one is actually rectangular?

Also, would you be kind to draw a line or a point if the relation between both sides are equal or lower than 2.35, please?

For instance, if its length is 2.4 and its width is 1, then it draws a line along its length. If not, draws a point at the center of that rectangle.

 

Sorry but that would save a lot of time 🙂

 

Many thanks in advance 🙂

 

0 Likes
Message 6 of 21

Kent1Cooper
Consultant
Consultant
Accepted solution

I think this does all those things [again, lightly tested]:

(defun C:QLCLP ; = Quadrilateral Long-direction Center Line or Point
  (/ pap ss n pl seglen1 seglen2 dists parA)
  (defun pap (i) (vlax-curve-getPointAtParam pl i))
  (if (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1))))
    ; 4-sided closed only
    (repeat (setq n (sslength ss))
      (setq pl (ssname ss (setq n (1- n))))
      (if
        (and
          ; all straight-line segments [no bulge factors]:
          (= (apply '+ (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 42)) (entget pl)))) 0.0)
          ; opposite sides equal lengths:
          (equal (setq seglen1 (distance (pap 0) (pap 1))) (distance (pap 2) (pap 3)) 1e-6)
          (equal (setq seglen2 (distance (pap 1) (pap 2))) (distance (pap 3) (pap 0)) 1e-6)
          ; right angle corner:
          (equal (rem (abs (- (angle (pap 0) (pap 1)) (angle (pap 1) (pap 2)))) pi) (/ pi 2) 1e-6)
        ); and
        (progn ; then
          (setq dists (list seglen1 seglen2))
          (if (> (/ (apply 'max dists) (apply 'min dists)) 2.35); ratio of sides
            (progn; then -- Center Line in longer direction
              (setq parA (vl-position (apply 'min dists) dists)); 0 or 1
              (command
                "_.line" "_non" (pap (+ parA 0.5)) "_non" (pap (+ parA 2.5)) ""
                "_.chprop" (entlast) "" "_ltype" "CENTER" ""
              ); command
            ); progn
            (command "_.point" "_non" (mapcar '/ (mapcar '+ (pap 0) (pap 2)) '(2 2 2))); else
          ); if [ratio]
        ); progn
      ); if [rectangular]
    ); repeat
  ); if [any 4-sided closed Polyline(s) selected]
  (prin1)
)
Kent Cooper, AIA
0 Likes
Message 7 of 21

cool.stuff
Collaborator
Collaborator

Works like a charm!!! 🙂

 

Many many thanks for your kindness and help!!! 🙂

 

PS: I tried to change the criterium to be equal or greater than 2.35, by adding "=" after the ">", but is does not work. Could you give me a hand please? Thanks again!!

0 Likes
Message 8 of 21

Kent1Cooper
Consultant
Consultant

@cool.stuff wrote:

 

.... I tried to change the criterium to be equal or greater than 2.35, by adding "=" after the ">", but is does not work. ....


You don't show your edited version, but I have two thoughts:

Did you perhaps put a space between the > and the = ?  There should not be one.

It may be one of those things that will work most of the time but not always right at the cut-off ratio, because of tiny way-down-in-the-decimal-places differences in calculated values, which result from the fact that decimal values are just masking the fact that everything is really done in binary fashion with 1's and 0's.  What you think is 2.35 may actually be 2.349999999999613, which would not meet the test.  This is why, when comparing real-number values, people often use (equal) with a fuzz factor, instead of (=) which wants absolute true equality.  But there's no fuzz factor option in the (>=) and similar functions.  Would it work for you to check in comparison with 2.34999 instead of 2.35?

Kent Cooper, AIA
Message 9 of 21

cool.stuff
Collaborator
Collaborator

Thanks for your answer 🙂

Sorry @Kent1Cooper for not posting my code..

No, I did not add a space between characters and thank you for your insightful explanation 🙂

What you suggested would do just fine 🙂

 

Again, many thanks 🙂

0 Likes
Message 10 of 21

calderg1000
Mentor
Mentor

Regards @cool.stuff 

Try this code, it should comply with what you request...

 

;;;___
(defun c:line_M
                (/ s lp p0 p1 p2 p3 lx ly v0 v1 v2 v3 dx dy vux vuy px pxc py
                 pyc x y i j k l u w m
                )
  (setvar 'pdmode 3)
  (setvar 'pdsize 0.1)
  (while
    (setq s (car (entsel "\nSelect Lwpolyline Rectangle: ")))
     (setq
       lp (mapcar 'cdr
                  (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget s))
          )
       p0 (car lp)
       p1 (cadr lp)
       p2 (caddr lp)
       p3 (cadddr lp)
       lx (distance p0 p1)
       ly (distance p1 p2)
       v0 (mapcar '- p1 p0)
       v1 (mapcar '- p2 p1)
       v2 (mapcar '- p3 p2)
       v3 (mapcar '- p0 p3)
     )
     (if (equal (apply '+
                       (list (* (car v0) (car v1))
                             (* (cadr v0) (cadr v1))
                             (* (car v2) (car v3))
                             (* (cadr v2) (cadr v3))
                       )
                )
                0.0
                0.0001
         )
       (progn
         (princ "\nThe selected figure is a Rectangle...")
         (setq vux (mapcar '(lambda (x) (/ x lx)) (mapcar '- p1 p0))
               vuy (mapcar '(lambda (y) (/ y ly)) (mapcar '- p2 p1))
         )
         (if (>= lx ly)
           (progn
             (setq
               dx  (/ lx 2)
               dy  (/ ly 2)
               px  (mapcar '+ p0 (mapcar '(lambda (j) (* dy j)) vuy))
               pxc (mapcar '+ px (mapcar '(lambda (u) (* dx u)) vux))
             )
             (if (<= (/ lx ly) 2.35)
               (progn
                 (princ "\nL.maj/L.min<=2.35:")
                 (entmakex
                   (list '(0 . "Point")
                         (cons 10 pxc)
                   )
                 )
               )
               (entmakex
                 (list
                   '(0 . "line")
                   (cons 10 px)
                   (cons 11 (mapcar '+ px (mapcar '(lambda (k) (* lx k)) vux)))
                 )
               )
             )
           )
           (progn
             (setq
               dx  (/ lx 2)
               dy  (/ ly 2)
               py  (mapcar '+ p0 (mapcar '(lambda (l) (* dx l)) vux))
               pyc (mapcar '+ py (mapcar '(lambda (w) (* dy w)) vuy))
             )
             (if (<= (/ ly lx) 2.35)
               (progn
                 (princ "\nL.maj/L.min<=2.35:")
                 (entmakex
                   (list '(0 . "Point")
                         (cons 10 pyc)
                   )
                 )
               )
               (entmakex
                 (list
                   '(0 . "line")
                   (cons 10 py)
                   (cons 11 (mapcar '+ py (mapcar '(lambda (m) (* ly m)) vuy)))
                 )
               )
             )
           )
         )
       )
       (progn
        (command "_chprop" s "" "c" 1 "")
       (princ "\nThe selected shape is not a Rectangle...")
         )
     )
  )
  (princ)
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 11 of 21

Kent1Cooper
Consultant
Consultant

That needs more work on its rectangularity test.  It accepted these parallelograms [green Polylines, white results]:

Kent1Cooper_1-1710120487470.png

as well as things with arc segments:

Kent1Cooper_1-1710121161373.png

and self-intersecting ones, with rectangular extents and even with isosceles trapezoidal vertex relationships:

Kent1Cooper_2-1710121469211.png

though it did reject isosceles trapezoids that are not self-intersecting.

 

[And if you need to do multiple rectangles, it requires selecting them one at a time.]

Kent Cooper, AIA
0 Likes
Message 12 of 21

calderg1000
Mentor
Mentor

Regards @Kent1Cooper 

Thank you very much for your observations, I made a mistake. I made the corrections in my previous post, to verify the perpendicularity and it was tested in your graphs. The multiple selection thing, although it wouldn't be complicated. I didn't do it so I could see the message when I selected it, it wasn't a rectangle.

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 13 of 21

Kent1Cooper
Consultant
Consultant

@calderg1000 wrote:

.... I made the corrections in my previous post, to verify the perpendicularity ....


That took care of the parallelogram and self-intersecting and trapezoidal issues, but not yet the arc segment(s) issue:

Kent1Cooper_0-1710162222620.png

And [I hadn't tried this before] it accepts one that is not closed:

Kent1Cooper_1-1710162832752.png

[And I would suggest adding a check on the type of object selected.  If I pick a non-rectangular Polyline, it scolds me but asks again, but if I pick something else like a Line, it dies with an error message.]

Kent Cooper, AIA
0 Likes
Message 14 of 21

calderg1000
Mentor
Mentor
Accepted solution

Regards @cool.stuff 

Try this code, I made the necessary edits to it so that it complies with your request and with the additional border conditions that @Kent1Cooper  mentioned.

(defun c:line_M
                (/ s lp p0 p1 p2 p3 lx ly v0 v1 v2 v3 dx dy vux vuy px pxc py
                 pyc x y i j k l u w m
                )
  (setvar 'pdmode 3)
  (setvar 'pdsize 0.25)
  (setq lsn
         (vl-remove-if
           'listp
           (mapcar
             'cadr
             (ssnamex (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1) (90 . 4)))
             )
           )
         )
  )
  (foreach i lsn
    (progn
      (setq
        lp (mapcar 'cdr
                   (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget i))
           )
        p0 (car lp)
        p1 (cadr lp)
        p2 (caddr lp)
        p3 (cadddr lp)
        lx (distance p0 p1)
        ly (distance p1 p2)
        v0 (mapcar '- p1 p0)
        v1 (mapcar '- p2 p1)
        v2 (mapcar '- p3 p2)
        v3 (mapcar '- p0 p3)
      )
      (if
        (and
          (equal (apply '+
                        (list (* (car v0) (car v1))
                              (* (cadr v0) (cadr v1))
                              (* (car v2) (car v3))
                              (* (cadr v2) (cadr v3))
                        )
                 )
                 0.0
                 0.0001
          )
          (equal
            (apply
              '+
              (mapcar 'cdr
                      (vl-remove-if-not '(lambda (x) (= (car x) 42)) (entget i))
              )
            )
            0.0
            0.0001
          )
        )
         (progn
           (princ "\nThe selected figure is a Rectangle...")
           (setq vux (mapcar '(lambda (x) (/ x lx)) (mapcar '- p1 p0))
                 vuy (mapcar '(lambda (y) (/ y ly)) (mapcar '- p2 p1))
           )
           (if (>= lx ly)
             (progn
               (setq
                 dx  (/ lx 2)
                 dy  (/ ly 2)
                 px  (mapcar '+ p0 (mapcar '(lambda (j) (* dy j)) vuy))
                 pxc (mapcar '+ px (mapcar '(lambda (u) (* dx u)) vux))
               )
               (if (<= (/ lx ly) 2.35)
                 (progn
                   (princ "\nL.maj/L.min<=2.35:")
                   (entmakex
                     (list '(0 . "Point")
                           (cons 10 pxc)
                     )
                   )
                 )
                 (entmakex
                   (list
                     '(0 . "line")
                     (cons 10 px)
                     (cons 11 (mapcar '+ px (mapcar '(lambda (k) (* lx k)) vux)))
                   )
                 )
               )
             )
             (progn
               (setq
                 dx  (/ lx 2)
                 dy  (/ ly 2)
                 py  (mapcar '+ p0 (mapcar '(lambda (l) (* dx l)) vux))
                 pyc (mapcar '+ py (mapcar '(lambda (w) (* dy w)) vuy))
               )
               (if (<= (/ ly lx) 2.35)
                 (progn
                   (princ "\nL.maj/L.min<=2.35:")
                   (entmakex
                     (list '(0 . "Point")
                           (cons 10 pyc)
                     )
                   )
                 )
                 (entmakex
                   (list
                     '(0 . "line")
                     (cons 10 py)
                     (cons 11 (mapcar '+ py (mapcar '(lambda (m) (* ly m)) vuy)))
                   )
                 )
               )
             )
           )
         )
         (command "_chprop" i "" "c" 1 "")
      )
    )
    (princ)
  )
)

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 15 of 21

cool.stuff
Collaborator
Collaborator

@Kent1Coopercould you please change the code to generate the point or line in the same layer as the rectangle? 🙂

 

I tried with this piece of code

 

"_.matchprop" pl (entlast) ""

 

but didnt work..

 

Many thanks! 🙂

0 Likes
Message 16 of 21

calderg1000
Mentor
Mentor

Regards @, the line of code you show us works for me. As practice for you, show us where you put it and we will see if it is correct.


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 17 of 21

cool.stuff
Collaborator
Collaborator

Hi @calderg1000 , thank you for your reply.

 

This is my current code, based on @Kent1Cooper lisp:

 

(defun C:QLCLP ; = Quadrilateral Long-direction Center Line or Point
  (/ pap ss n pl seglen1 seglen2 dists parA)
  (defun pap (i) (vlax-curve-getPointAtParam pl i))
  (if (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1))))
    ; 4-sided closed only
    (repeat (setq n (sslength ss))
      (setq pl (ssname ss (setq n (1- n))))
      (if
        (and
          ; all straight-line segments [no bulge factors]:
          (= (apply '+ (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 42)) (entget pl)))) 0.0)
          ; opposite sides equal lengths:
          (equal (setq seglen1 (distance (pap 0) (pap 1))) (distance (pap 2) (pap 3)) 1e-6)
          (equal (setq seglen2 (distance (pap 1) (pap 2))) (distance (pap 3) (pap 0)) 1e-6)
          ; right angle corner:
          (equal (rem (abs (- (angle (pap 0) (pap 1)) (angle (pap 1) (pap 2)))) pi) (/ pi 2) 1e-6)
        ); and
        (progn ; then
          (setq dists (list seglen1 seglen2))
          (if (> (/ (apply 'max dists) (apply 'min dists)) 4); ratio of sides
            (progn; then -- Center Line in longer direction
              (setq parA (vl-position (apply 'min dists) dists)); 0 or 1
              (command
                "_.line" "_non" (pap (+ parA 0.5)) "_non" (pap (+ parA 2.5)) ""
                "_.chprop" (entlast) "" "_ltype" "CENTER" ""
                "_.matchprop" pl (entlast) ""
              ); command
            ); progn
            (command "_.point" "_non" (mapcar '/ (mapcar '+ (pap 0) (pap 2)) '(2 2 2))); else
          ); if [ratio]
        ); progn
      ); if [rectangular]
    ); repeat
  ); if [any 4-sided closed Polyline(s) selected]
  (prin1)
)

 

Once if that line is correct, then I must have added it in the wrong place.

This is my new code, which i think is fine:

 

(defun C:QLCLP_layer ; = Quadrilateral Long-direction Center Line or Point
  (/ pap ss n pl seglen1 seglen2 dists parA)
  (defun pap (i) (vlax-curve-getPointAtParam pl i))
  (if (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1))))
    ; 4-sided closed only
    (repeat (setq n (sslength ss))
      (setq pl (ssname ss (setq n (1- n))))
      (if
        (and
          ; all straight-line segments [no bulge factors]:
          (= (apply '+ (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 42)) (entget pl)))) 0.0)
          ; opposite sides equal lengths:
          (equal (setq seglen1 (distance (pap 0) (pap 1))) (distance (pap 2) (pap 3)) 1e-6)
          (equal (setq seglen2 (distance (pap 1) (pap 2))) (distance (pap 3) (pap 0)) 1e-6)
          ; right angle corner:
          (equal (rem (abs (- (angle (pap 0) (pap 1)) (angle (pap 1) (pap 2)))) pi) (/ pi 2) 1e-6)
        ); and
        (progn ; then
          (setq dists (list seglen1 seglen2))
          (if (> (/ (apply 'max dists) (apply 'min dists)) 4); ratio of sides
            (progn; then -- Center Line in longer direction
              (setq parA (vl-position (apply 'min dists) dists)); 0 or 1
              (command
                "_.line" "_non" (pap (+ parA 0.5)) "_non" (pap (+ parA 2.5)) ""
                "_.chprop" (entlast) "" "_ltype" "CENTER" ""
                "_.matchprop" pl (entlast) "" ; new line
              ); command
            ); progn
            (command 
              "_.point" "_non" (mapcar '/ (mapcar '+ (pap 0) (pap 2)) '(2 2 2))
             "_.matchprop" pl (entlast) "" ; new line
            ); else
          ); if [ratio]
        ); progn
      ); if [rectangular]
    ); repeat
  ); if [any 4-sided closed Polyline(s) selected]
  (prin1)
)

 

Just added in another place and its original position.

I think is good now!

 

Thanks for the tip @calderg1000 🙂 many thanks!

Message 18 of 21

calderg1000
Mentor
Mentor
Accepted solution

Regrads @cool.stuff 

This right. But, so that it does not override the line type properties of the previously created line, put the code "_.matchprop" pl (entlast)" before
"_.chprop" (entlast) "" "_ltype" "CENTER" ""


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 19 of 21

Kent1Cooper
Consultant
Consultant
Accepted solution

@calderg1000 is correct that the MATCHPROP command will match the linetype as well, overriding the setting of that to CENTER for the Line result.  You could do as suggested, and assign the linetype after MATCHPROPing to get the Layer, or you could just put more than one Property change into the CHPROP command, to match the Layer of the source object, but not its Linetype [or other Properties]:

 ....
             (command
                "_.line" "_non" (pap (+ parA 0.5)) "_non" (pap (+ parA 2.5)) ""
                "_.chprop" (entlast) ""
                  "_ltype" "CENTER"
                  "_layer" (cdr (assoc 8 (entget pl)))
                  "" ; conclude CHPROP
              ); command
....

You can do the same with the Point result if you like, but MATCHPROP assigning the rectangle's Linetype to the Point won't matter.

Kent Cooper, AIA
0 Likes
Message 20 of 21

cool.stuff
Collaborator
Collaborator

@calderg1000  and @Kent1Cooper thank you both for your help!!

 

i will change my code accordingly, as yours seems better 🙂

 

Thanks for being so helpful!! 🙂

 

Best regards

0 Likes