Jump to content

Recommended Posts

Posted

II got Autocad 2024 now.

nentsel selection of a a polyline used to return the line on which you clicked.

Now it seems to return the whole polyline.  So nentsel is just entsel.

 

What happenend?  Is this a new Auocad 2024 bug (I'm not calling this a feature, feel free to disagree)?

Any obvious solution?  

Posted

Don't have 2024, but did you check if the polyline is 3D? It doesn't work for regular pline if I'm not mistaken 

Posted

It's not 3D polylines

Posted

Just checking, on my installation (2022), nentsel and entsel on a LW Polyline returns the same, nentsel and entsel return different results on a 3d polyline

Posted

I guess I'll have to write my own nentsel for polylines.

Posted

nentselp does the same as nentsel

Posted (edited)

Something like this.

Extra properties to be added as needed.

 

(vl-load-com) 

(defun drawLine (p1 p2)
 (entmakex (list (cons 0 "LINE")
                 (cons 10 p1)
                 (cons 11 p2))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; http://www.lee-mac.com/round.html
;; Round Up  -  Lee Mac
;; Rounds 'n' up to the nearest 'm'
(defun LM:roundup ( n m )
    ((lambda ( r ) (cond ((equal 0.0 r 1e-8) n) ((< n 0) (- n r)) ((+ n (- m r))))) (rem n m))
)

;; Round Down  -  Lee Mac
;; Rounds 'n' down to the nearest 'm'
(defun LM:rounddown ( n m )
    ((lambda ( r ) (cond ((equal 0.0 r 1e-8) n) ((< n 0) (- n r m)) ((- n r)))) (rem n m))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; This function allows the user to select a segment of polyline.
;; The function returns the segment as though it were a line.  As if the polyline was exploded.
(defun nentselpl ( / res sel type sel_pt pl par start_ end_)
	(setq sel (entsel "\nSelect ployline: "))
	(setq pl (car sel))
	(setq type (cdr (assoc 0 (entget pl))))
	(if (wcmatch type "*POLYLINE")
		(progn
		
			(setq sel_pt (cadr sel))
			(setq sel_pt (vlax-curve-getClosestPointTo (vlax-ename->vla-object pl) sel_pt))
			;; parameter -> this tells you the index of the segment.  And where on the segment the point is
			(setq par (vlax-curve-getparamatpoint pl sel_pt))  ;; (vlax-ename->vla-object pl)
			;; start point of the segment 
			(setq start_ (vlax-curve-getPointAtParam (vlax-ename->vla-object pl) (LM:rounddown par 1.0)))
			(setq end_   (vlax-curve-getPointAtParam (vlax-ename->vla-object pl) (LM:roundup par 1.0)))
			
			(setq res (list 
				(cons 10 start_)
				(cons 11 end_)
				(cons 8 (cdr (assoc 8 (entget pl))))		;; layer
				;;  ... add extra properties if you wish
			))
		)
		nil
	)
	res
)

;; TEST function
(defun c:nentselpl ( / sel)
	(setq sel (nentselpl))
	(princ sel)
	(drawLine 
		(cdr (assoc 10 sel))
		(cdr (assoc 11 sel))
	)
	(princ)
)

 

Edited by Emmanuel Delay
  • Like 2

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...