Gino Lau Posted March 11 Posted March 11 I was trying to use LISP to select a segment or edge of a polyline, using "entsel". But when my mouse hover to an edge, it select the whole polyline. Something like when we trigger the Fillet or Chamfer command, we able to highlight and select just only the edge of a polyline. Quote
pkenewell Posted March 12 Posted March 12 @Gino Lau This is not really possible as a direct feature in LISP, but may have a less direct solution using temporary graphics. However, it really depends on what you are trying to do. I know the the single segment selection baked into the Fillet command is not possible to replicate with AutoLISP or Visual Lisp. If you give us an idea of what you are trying to accomplish we may be able to offer an alternate solution. Quote
Danielm103 Posted March 12 Posted March 12 Not sure with Lisp, with ARX, you can highlight sub entities, here’s a sample in Python import traceback from pyrx import Rx, Ge, Gi, Db, Ap, Ed @Ap.Command("doit") def justDoit(): try: # selet a polyline ps, id, pkpnt = Ed.Editor.entSel("\nSelect", Db.Polyline.desc()) if ps != Ed.PromptStatus.eOk: raise RuntimeError("Selection Error! {}: ".format(ps)) # open the polyline and get the closest from pkpnt pline = Db.Polyline(id) cp = pline.getClosestPointTo(pkpnt) # hack out a gs marker for the segment and create a path gsmkr = int(pline.getParamAtPoint(cp) + 1) spath = Db.FullSubentPath(id, Db.SubentType.kEdgeSubentType, gsmkr) # highlight is ok with kForRead pline.highlight(spath, False) except Exception as err: traceback.print_exception(err) Quote
Steven P Posted March 12 Posted March 12 Select the segment, I don't have anything as such but: - Select a point on the polyline (getpoint) - Create temporary polyline (I don't like these but...) - Trim temporary polyline at that point - Work out if the remaining polyline trimmed point it end A or B - Use mAssoc to get list of points, cadr or (reverse (cadr depends on direction to get the original polyline point - Use mAssoc on the original polyline, again with reverse or not find the nth + 1 point where n is the vertex above - Should give the end A and B of the polyline segment, and from there you can do your stuff. a bit long winded but should work Quote
BIGAL Posted March 12 Posted March 12 (edited) Select a segment lisp, sorry don't know where I got it, so no author name. (defun getplineseg ( / elst ename pt param preparam postparam) (setq elst (entsel "\nSelect pline segment: ")) (setq ename (car elst)) (setq pt (cadr elst)) (setq pt (vlax-curve-getClosestPointTo ename pt)) (print (setq param (vlax-curve-getParamAtPoint ename pt)) ) (setq preparam (fix param)) (setq postparam (1+ preparam)) (setq pt1 (vlax-curve-getPointAtParam ename preparam) pt2 (vlax-curve-getPointAtParam ename postparam)) ) Part two can check which end is nearest to pick point. Edited March 12 by BIGAL Quote
Danielm103 Posted March 13 Posted March 13 [Python] , here's an example of extracting a poly line segment https://www.theswamp.org/index.php?topic=58466 Quote
Saxlle Posted March 13 Posted March 13 On 11/03/2025 at 14:52, Gino Lau said: I was trying to use LISP to select a segment or edge of a polyline, using "entsel". But when my mouse hover to an edge, it select the whole polyline. If you want to select just a single or multiple segments of polyline, you can use CTRL + mouse left click to select segments of polylines (I don't know what do you want to accomplish with lisp). See the attached picture. Quote
GLAVCVS Posted March 13 Posted March 13 If you just want to get the pair of points that define the segment, you can use this: (defun s (ev / x d p i e pS) (while (and (if x x (setq x (if (= (rem (cdr (assoc 70 (setq x (entget (car ev))))) 2) 0) x (append x (list (assoc 10 x)))) pS (cadr ev))) (setq f (cdr (assoc 10 (setq x (cdr (member (setq p (assoc 10 x)) x)))))) (/= (max (distance (cdr p) pS) (distance f pS) (setq d (distance (setq i (cdr p)) f))) d) ) ) (if ev (list i f)) ) To use it: (s (entsel "\nSelect segment...")) Quote
GLAVCVS Posted March 13 Posted March 13 3 minutes ago, GLAVCVS said: If you just want to get the pair of points that define the segment, you can use this: (defun s (ev / x d p i e pS) (while (and (if x x (setq x (if (= (rem (cdr (assoc 70 (setq x (entget (car ev))))) 2) 0) x (append x (list (assoc 10 x)))) pS (cadr ev))) (setq f (cdr (assoc 10 (setq x (cdr (member (setq p (assoc 10 x)) x)))))) (/= (max (distance (cdr p) pS) (distance f pS) (setq d (distance (setq i (cdr p)) f))) d) ) ) (if ev (list i f)) ) To use it: (s (entsel "\nSelect segment...")) Of course: - it's assumed that an 'LWPOLYLINE' is selected. Otherwise, it won't work. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.