Nikon Posted 4 hours ago Posted 4 hours ago (edited) The code should draw a dotted new line between the points, but the line is not drawn. Would it be easier to change the properties of the line between two points? Thanks... ;; AutoLISP, which allows you to select objects (line, polyline, circle, arc), ;; break them at two points and replace the selected section with a dashed line with the specified parameters (defun c:Br2ptReplDash (/ ss pt1 pt2 ent entdata newent) (setq ss (ssget '((0 . "LINE,POLYLINE,CIRCLE,ARC")))) (if ss (progn (prompt "Select the object to split: ") (setq ent (ssname ss 0)) ;; Entering the first break point (setq pt1 (getpoint " Select the first break point: ")) ;; Entering the second break point (setq pt2 (getpoint " Select the second break point: ")) ;; Checking the object type and performing the split (cond ((= (cdr (assoc 0 (entget ent))) "LINE") ;; break the line (command "_.BREAK" ent pt1 pt2) ) ((= (cdr (assoc 0 (entget ent))) "POLYLINE") ;; break polyline (command "_.BREAK" ent pt1 pt2) ) ((= (cdr (assoc 0 (entget ent))) "CIRCLE") ;; break the circle (command "_.BREAK" ent pt1 pt2) ) ((= (cdr (assoc 0 (entget ent))) "ARC") ;; break the arc (command "_.BREAK" ent pt1 pt2) ) (T (prompt "An object of an unsupported type.") ) ) ;; Get new objects after splitting (setq ss (ssget "_N" '((0 . "LINE POLYLINE CIRCLE ARC")))) ;; Sorting through objects and replacing the section with a dotted line (setq i 0) (repeat (sslength ss) (setq ent (ssname ss i)) (setq entdata (entget ent)) ;; Create a new line between the break points (setq newent (command "_.LINE" pt1 pt2 "")) ;; Setting up line properties (entmod (append newent '((8 . "0") ; the default layer '(6 . "DASHED2") ; line type ;'(70 . 0) '(40 . 0.25) ; thickness '(47 . 20))) ; LTSCALE ) ;; Color setting (entmod (append newent '((62 . 84)))) (setq i (1+ i)) ) (prompt "Processing is completed.") ) (prompt "Objects are not selected.") ) (princ) ) Br2ptReplDash.dwg Edited 1 hour ago by Nikon Quote
CivilTechSource Posted 2 hours ago Posted 2 hours ago few issues with the lisp. 1) The ssget does not seem to work. 2) Creating a new line between breakpoints will not work for circles as you need to create an arc. It will also not work on curved polylines. Maybe a better way to approach it, is to select the object copy it. Trim it to pt1 & pt2 and then, break the selected objected between pt1 & pt2? Quote
mhupp Posted 2 hours ago Posted 2 hours ago (edited) This is a bit more streamlined. ;; AutoLISP, which allows you to select objects (line, polyline, circle, arc), ;; break them at two points and replace the selected section with a dashed line with the specified parameters (defun c:Br2ptReplDash (/ SS pt1 pt2 ent entdata newent) ;while instead of if allows this command to be repated as long as you select an entity. (while (setq SS (ssget "_+.:E:S" '((0 . "LINE,POLYLINE,CIRCLE,ARC")))) ;Will emulate an entsel selection behaviour and only allows the entity types listed (progn ;no need for cond check now (setq ent (ssname SS 0)) (setq pt1 (getpoint "Select the first break point: ")) (setq pt2 (getpoint "Select the second break point: ")) Using the two points create a selection set window to pick up created break line (ssget "_W" pt1 pt2 '((0 . "LINE"))) Your entmod has to many ( ) (entmod (append newent '((8 . "0") ; the default layer '(6 . "DASHED2") ; line type '(40 . 0.25) ; thickness '(47 . 20) ; LTSCALE '(62 . 84) ; Add here instead of 2nd (entmod (append newent '((62 . 84)))) ) ) ) ;removed 2nd '(6 . "DASHED2") Edited 2 hours ago by mhupp 1 Quote
Nikon Posted 1 hour ago Author Posted 1 hour ago 44 minutes ago, mhupp said: Your entmod has to many ( ) I understand (), but the rest is not very clear... 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.