Print Page | Close Window

Autolisp File

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=9995
Printed Date: 16.May.2026 at 12:19


Topic: Autolisp File
Posted By: 1616syd
Subject: Autolisp File
Date Posted: 27.Jan.2014 at 22:41
Anyone got a lisp file which will enable the properties of a LWPOLYLINE to be matched to a LINE
and thus converting it into a LWPOLYLINE, in much the same way as the MATCH PROPERTIES
does with other objects.Clap


-------------
SydUK



Replies:
Posted By: Kent Cooper
Date Posted: 28.Jan.2014 at 15:09
Try this, in nearly simplest terms:
 
(defun C:MPPL
; = Match Properties of Polyline to Line [including converting Line to Polyline]
  (/ pl lin)
  (setq pea (getvar 'peditaccept))
  (setvar 'peditaccept 1)
  (setq
    pl (car (entsel "\nSelect Polyline to match Line to: "))
    lin (car (entsel "\nSelect Line to convert to Polyline and match selected one: "))
  ); setq
  (command
    "_.pedit" lin ""
    "_.matchprop" pl lin ""
  ); command
  (setvar 'peditaccept pea)
); defun
 
It ought to be enhanced with valid-object-type selection controls, maybe command-echo suppression, error handling, and all the other usual bells and whistles, but as a start it works for me, in limited testing.


Posted By: 1616syd
Date Posted: 28.Jan.2014 at 15:18
Thank you for that Kent, it works OK, other than it has to be run a second
time to create the global width of the new polyline to match original if greater than 0.
Kind regards
Syd


-------------
SydUK


Posted By: 1616syd
Date Posted: 28.Jan.2014 at 15:58
Hello Kent
I've managed to juggle your code with the addition of entlast in
the matchprop call instead of lin, which holds only the original data
fo the selected line, and not the new polyline.
 
(defun C:MPPL (/ pl lin)
  (setq pea (getvar 'peditaccept))
  (setvar 'peditaccept 1)
  (setq
    pl (car (entsel "\nSelect Polyline to match Line to: "))
    lin (car (entsel "\nSelect Line to convert to Polyline and match selected one: "))
  ); setq
  (command "_.pedit" lin "" "_.matchprop" pl (entlast) "")
  (setvar 'peditaccept pea)
  (princ)
); defun
Kind Regards
Syd


-------------
SydUK


Posted By: Kent Cooper
Date Posted: 28.Jan.2014 at 17:02
Ah, yes, of course....  I at first had it doing Matchprop before Pedit, and I reversed that specifically in case of non-zero width, but didn't think about the entity-name change, and obviously didn't test the reversed-order version in that situation.



Print Page | Close Window