Nikon Posted 5 hours ago Posted 5 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 2 hours ago by Nikon Quote
CivilTechSource Posted 3 hours ago Posted 3 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 3 hours ago Posted 3 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 3 hours ago by mhupp 1 Quote
Nikon Posted 2 hours ago Author Posted 2 hours ago 44 minutes ago, mhupp said: Your entmod has to many ( ) I understand (), but the rest is not very clear... Quote
mhupp Posted 30 minutes ago Posted 30 minutes ago 1 hour ago, Nikon said: I understand (), but the rest is not very clear... You start the lisp with if this will only run once. changing the if to while will allow you to use the break command multiple of times with out having to type the command over and over. only draw back is if you only want to run the command once you have to right click or hit enter to exit the command. using ssget with the "_+.:E:S" acts like entsel and will only select entity's you define. eliminating the need to test the entity type. since you have the two break points defined you can use ssget with the window option to "select" that entity but could pick up other smaller unwanted items also. this is all moot because id recommend using Breakall by CAB. don't know if its on here but he posted it on theswamp.org many years ago. alot more features and error handling. 1 Quote
BlackBox Posted 20 minutes ago Posted 20 minutes ago 7 minutes ago, mhupp said: ... you can use ssget with the window option to "select" that entity but could pick up other smaller unwanted items also. Entlast & entnext may help to mitigate that. 7 minutes ago, mhupp said: this is all moot because id recommend using Breakall by CAB. don't know if its on here but he posted it on theswamp.org many years ago. alot more features and error handling. 1+ 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.