convert polyline line to polyline with matchprop or lisp

convert polyline line to polyline with matchprop or lisp

Gh_man
Advocate Advocate
1,868 Views
8 Replies
Message 1 of 9

convert polyline line to polyline with matchprop or lisp

Gh_man
Advocate
Advocate

I often have need to use matchprop make a line to match an existing polyline. Unfortunately, I have to run pedit on the line first to convert it into a polyline, and then perform a matchprop on it. Does anyone know of a way to do this as a single step? I have a feeling that vanilla CAD won't do it, but perhaps there is a way to make it happen with a lisp? I imagine that there must be a lot of people who have needed this before me, so I suspect someone has already written one, but I haven't been able to find it.

In case it matters, my goal is to have the target line have a width, (as well as all the standard properties) which requires the target line to start off as a pline.

0 Likes
1,869 Views
8 Replies
Replies (8)
Message 2 of 9

imadHabash
Mentor
Mentor

Hi,

 

does this >> Link << help.. hope so.

Imad Habash

EESignature

Message 3 of 9

Gh_man
Advocate
Advocate
Yes, thank you! Your searching skills exceed mine. 🙂

It does 99% of what I want. My only objection to it would be that it only works on polylines, instead of all objects, so I need to use two different commands (this and regular matchprop), depending on what I wish to accomplish, instead of having one supercommand that does either. But really this is a rather minor quibble, I can happily live with an additional icon on my toolbar in exchange for saving a step in the process.
0 Likes
Message 4 of 9

jbailey
Observer
Observer

Did you ever find a LISP routine to this issue? I have battled it constantly for 20 years lol

0 Likes
Message 5 of 9

Gh_man
Advocate
Advocate

I used the code from the link above. It's broken now, but I'll paste the lisp below:

(defun c:mp (/ old_Pedit ss ss1 ss2 ent ent1)
(setq old_Pedit (getvar "peditaccept"))
(princ "\nSelect the reference lwpolyline")
(if (setq ss1 (ssget "_:S:E" '((0 . "LWPOLYLINE"))))
(progn
(prompt
"\nSelect the lines to convert polylines and matchproperties"
)
(if (setq ss (ssget '((0 . "LINE,ARC"))))
(progn
(command "copy"
(ssname ss1 0)
""
"0,0,0"
"0,0,0"
"erase"
"p"
""
)
(setvar "peditaccept" 1)
(setq ss2 (ssadd)
ent (entlast)
ent1 (entlast)
)
(ssadd ent1 ss2)
(command "pedit" "_m" ss "" "")
(while (setq ent1 (entnext ent1))
(ssadd ent1 ss2)
)
(setq ss2 (ssdel (ssname ss2 0) ss2))
(command "_.matchprop" ent ss2 "")
(setvar "peditaccept" old_Pedit)
);; progn
);; if
);; progn
);; is
(princ)
)

 

 

0 Likes
Message 6 of 9

jbailey
Observer
Observer

I think i can make that work.

Its almost perfect. Stinks you have to complete the command to see the results. 

But should save a few keystrokes.

 

Thank you! 

 

 

Message 7 of 9

Gh_man
Advocate
Advocate
Glad to help, and to pass on imadHabash's wisdom. 🙂
Message 8 of 9

ВeekeeCZ
Consultant
Consultant

Putting some things together... a bit more complex. If you find some flaws, let me know.

0 Likes
Message 9 of 9

jbailey
Observer
Observer

Holy cow that works pretty good!!! 

Will let you know if any issues come up.

 

Happy New Year

0 Likes