I've got the following routine from this forum <Thanks Mr. Kincaid> and revised it some to make it work a little better for my situation. Now I want to be able to use this on polylines and arcs. I started working on the polyline part and was unable to make a successful selection of the line with-in the line. I do use ENTNEXT to do this, right? Secondly, would I be able to extract out the line entity info from the polyline and supply it to the part where a line's info was supplied to the BREAK command? And thirdly, I haven't got the first clue as to break an arc so that it will have a gap. ;Created 8/11/89 By W. R. Kincaid ; PO Box 8085 ; Greenville, NC 27835 ; ;Modified 11/18/04 By Jamie Myers ; Jackson, TN ; ; To allow breaking entities at intersections. ; ; ;Brkint.lsp ;;;------------------------------------------------------------------------------------------------ (defun *BGP*SetupSave () (setvar "cmdecho" 0) (setq DimScl (getvar "dimtxt")) (setq OrthoMode (getvar "orthomode")) (setq OsMode (getvar "osmode")) (setvar "orthomode" 1) (setvar "OsMode" 0) ) (defun *BGP*SetupRestore () (setvar "cmdecho" 1) (setvar "dimtxt" DimScl) (setvar "orthomode" OrthoMode) (setvar "osmode" OsMode) (redraw) ) ;;;------------------------------------------------------------------------------------------------ (defun *ERROR* (Msg) (if (not (member Msg '("console break" "Function cancelled" "quit / exit abort") ) ) (princ (strcat "\nError: " Msg)) ) (*HVAC*SetupRestore) (princ) ) ;;;------------------------------------------------------------------------------------------------ (defun c:BGP( / HalfGapWidth DimScl EntityToBreak EntityAngle BreakPnt BreakPnt1 BreakPnt2) (*BGP*SetupSave) (setq HalfGapWidth (* 1.0 DimScl)) (setq EntityToBreak (entsel "\nSelect Entity to Break: ")) (if (= EntityToBreak nil) (progn (*ELEC*SetupRestore) (exit) );progn );if (setq EntityAngle (angle (cdr (assoc 10 (entget (car EntityToBreak)))) (cdr (assoc 11 (entget (car EntityToBreak)))))) (while EntityToBreak (progn (command "osnap" "int") (setq BreakPnt (getpoint "\nPick Intersection: ")) (setq BreakPnt1 (polar BreakPnt EntityAngle HalfGapWidth)) (setq BreakPnt2 (polar BreakPnt (+ pi EntityAngle) HalfGapWidth)) (command "BREAK" EntityToBreak "F" BreakPnt1 BreakPnt2) (command "osnap" "none") (setq EntityToBreak (entsel "\nSelect Next Entity: ")) (setq EntityAngle (angle (cdr (assoc 10 (entget (car EntityToBreak)))) (cdr (assoc 11 (entget (car EntityToBreak)))))) );end progn );end while (*BGP*SetupRestore) ) ;end defun
Rabbit, May I suggest, simply tell us what you want to do. Offering modified code helps some. But catch 22, we can't know what the original code was intended to do. Joe Burke
Sorry I wasn't clear enough. If two lines are crossing, I can select, using this routine, one line and then click on the intersection so that it will break with a distance equal to the Dimscale setting. I know that the dimscale is set to a variable called 'HalfGapWidth'. I had originally set it up to be half the dimscale width. that wasn't enough so I increased to 3/4 and then to full dimscale. -- Rabbit
Here is the one I use. After reading your post I tested mine, and it seems to break just fine, but when you break an arc the new arc that is drawn between the two break points doesn't reach all the way across. I will fix that when I have a chance to. If the break is to small, then change this part (2 places): (* GlbScale 0.0625) Tim (defun c:Tril (/ ActDoc CurSpace DimSc BkPt BkEnt IntPt1 IntPt2 StAng EndAng osm ocmd tmpSc tmpCir tmpIntPts tmpPt tmpArc) ; Breack object at intersection, with ability to place and arc. (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))) (vla-StartUndomark ActDoc) (setq CurSpace (GetCurrentSpace ActDoc)) (setq osm (getvar "osmode")) (setq ocmd (getvar "cmdecho")) (setvar "cmdecho" 0) (setvar "osmode" 32) (if (= (setq DimSc (getvar "dimscale")) "") (setq DimSc 1.0) ) (if (not GlbScale) (setq GlbScale DimSc) ) (if (and (setq BkPt (getpoint "\n Select intersection point: ")) (setq BkEnt (entsel "\n Select object to break: ")) ) (progn (if (setq tmpSc (getreal (strcat "\n Enter drawing scale if different then <" (rtos GlbSCale 2) ">: "))) (setq GlbScale tmpSc) ) (setq BkPt (trans BkPt 1 0)) (setq tmpCir (vla-AddCircle CurSpace (vlax-3d-point BkPt) (* GlbScale 0.0625))) (setq tmpIntPts (vlax-invoke (vlax-ename->vla-object (car BkEnt)) 'IntersectWith tmpCir acExtendNone)) (setq IntPt1 (trans (list (car tmpIntPts) (cadr tmpIntPts) (caddr tmpIntPts)) 0 1)) (setq IntPt2 (trans (cdddr tmpIntPts) 0 1)) (vla-Delete tmpCir) (setvar "osmode" 0) (command "_.break" (car BkEnt) IntPt1 IntPt2) (setvar "osmode" 1) (if (setq tmpPt (getpoint "\n Pick point to start arc [enter to end without arc]: ")) (progn (setq tmpPt (trans tmpPt 1 0)) (setq StAng (angle BkPt tmpPt)) (setq EndAng (+ StAng (DTR 180.0))) (setq tmpArc (vla-AddArc CurSpace (vlax-3d-point BkPt) (* GlbScale 0.0625) StAng EndAng)) (vla-put-Layer tmpArc (vla-get-Layer (vlax-ename->vla-object (car BkEnt)))) ) ) ) ) (setvar "osmode" osm) (setvar "cmdecho" ocmd) (vla-EndUndoMark ActDoc) (princ) ) (defun GetCurrentSpace (Doc / BlkCol SpaceList CurSpace ActSpace temp1) ; Returns the "block object" for the active space ; Thanks to Jason Piercey ;(defun activeSpaceObject (document) His Name for it (vla-get-block (vla-get-activelayout Doc) ) )
Here is the new "tril" (main part) that works better. Tim (defun c:Tril (/ ActDoc CurSpace DimSc BkPt BkEnt IntPt1 IntPt2 StAng EndAng osm ocmd tmpSc tmpCir tmpIntPts tmpPt tmpArc) ; Breack object at intersection, with ability to place and arc. ; Does not work when trying to break a circle. ; By Tim Wille 02/2005 (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))) (vla-StartUndomark ActDoc) (setq CurSpace (GetCurrentSpace ActDoc)) (setq osm (getvar "osmode")) (setq ocmd (getvar "cmdecho")) (setvar "cmdecho" 0) (setvar "osmode" 32) (if (= (setq DimSc (getvar "dimscale")) "") (setq DimSc 1.0) ) (if (not GlbScale) (setq GlbScale DimSc) ) (if (and (setq BkPt (getpoint "\n Select intersection point: ")) (setq BkEnt (entsel "\n Select object to break: ")) ) (progn (if (setq tmpSc (getreal (strcat "\n Enter drawing scale if different then <" (rtos GlbSCale 2) ">: "))) (setq GlbScale tmpSc) ) (setq BkPt (trans BkPt 1 0)) (setq tmpCir (vla-AddCircle CurSpace (vlax-3d-point BkPt) (* GlbScale 0.0625))) (setq tmpIntPts (vlax-invoke (vlax-ename->vla-object (car BkEnt)) 'IntersectWith tmpCir acExtendNone)) (setq IntPt1 (trans (list (car tmpIntPts) (cadr tmpIntPts) (caddr tmpIntPts)) 0 1)) (setq IntPt2 (trans (cdddr tmpIntPts) 0 1)) (vla-Delete tmpCir) (setvar "osmode" 0) (command "_.break" (car BkEnt) IntPt1 IntPt2) (setvar "osmode" 1) (if (setq tmpPt (getpoint "\n Pick point to start arc [enter to end without arc]: ")) (progn (setq tmpPt (trans tmpPt 1 0)) (if (equal tmpPt IntPt1 (* GlbScale 0.00000001)) (setq EndAng (angle BkPt IntPt2)) (setq EndAng (angle BkPt IntPt1)) ) (setq StAng (angle BkPt tmpPt)) (setq tmpArc (vla-AddArc CurSpace (vlax-3d-point BkPt) (* GlbScale 0.0625) StAng EndAng)) (vla-put-Layer tmpArc (vla-get-Layer (vlax-ename->vla-object (car BkEnt)))) ) ) ) ) (setvar "osmode" osm) (setvar "cmdecho" ocmd) (vla-EndUndoMark ActDoc) (princ) )
hahahahahahha.. oh man.. long day at work. Sorry I miss spelled my last name. Forgot the last letter when I posted the previous code. This line: ;; By Tim Wille 02/2005 should be ;; By Tim Willey 02/2005 Tim
Is there a function that you have called 'GetCurrentSpace'? This routine is crapping out when it reaches this point (setq CurSpace (GetCurrentSpace ActDoc)) BTW, thanks for the help. The (vla-StartUndomark ActDoc) and (vla-EndUndoMark ActDoc) lines are something I'll have to look at more closely and try to incorporate it into my routines. There's prolly a lot more I could learn from this also.
Yea. I posted it when I posted the routine first. That part didn't change so I didn't repost it. Here you go though. (defun GetCurrentSpace (Doc / BlkCol SpaceList CurSpace ActSpace temp1) ; Returns the "block object" for the active space ; Thanks to Jason Piercey ;(defun activeSpaceObject (document) His Name for it (vla-get-block (vla-get-activelayout Doc) ) ) Tim
I never caught that. I apologize. Your routine works great, buuuut...... It's not exactly what I was wanting. Although, I was able to remove a few things and change it just a little to acheive my goal. I was only needing it to just beak the entity and I seen where it has the option to put in the arc. I just took out an extra step that wasn't needed. I'm still going to hang on to it just in case I ever need that. Hope you don't mind the re-doing of it. Thanks again for the info and the lesson. I learned a few new things. Much appreciated! Here's what I revised it to: ;;;------------------------------------------------------------------------------------------------ ;;;Routines to break lines, arcs and polylines at a point with a gap. ;;; Returns the "block object" for the active space ;;; Thanks to Jason Piercey ;;;(defun activeSpaceObject (document) His Name for it (defun GetCurrentSpace (Doc / BlkCol SpaceList CurSpace ActSpace temp1) (vla-get-block (vla-get-activelayout Doc)) ) ;;; Break object at intersection, with ability to place and arc. ;;; Does not work when trying to break a circle. ;;; By Tim Willey 02/2005 ;;; Revised by Jamie Myers 02/09/2005 (defun c:BGP (/ ActDoc CurSpace DimSc BkPt BkEnt IntPt1 IntPt2 StAng EndAng osm ocmd tmpSc tmpCir tmpIntPts tmpPt tmpArc) (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))) (vla-StartUndomark ActDoc) (setq CurSpace (GetCurrentSpace ActDoc)) (setq osm (getvar "osmode")) (setq ocmd (getvar "cmdecho")) (setvar "cmdecho" 0) (setvar "osmode" 32) (if (= (setq DimSc (getvar "dimscale")) "") (setq DimSc 1.0)) (if (not GlbScale) (setq GlbScale DimSc)) (if (and (setq BkEnt (entsel "\n Select object to break: ")) (setq BkPt (getpoint "\n Select intersection point: ")) );end and (progn (setq GlbScale (* 1.0 DimScl)) (setq BkPt (trans BkPt 1 0)) (setq tmpCir (vla-AddCircle CurSpace (vlax-3d-point BkPt) (* GlbScale 1))) (setq tmpIntPts (vlax-invoke (vlax-ename->vla-object (car BkEnt)) 'IntersectWith tmpCir acExtendNone)) (setq IntPt1 (trans (list (car tmpIntPts) (cadr tmpIntPts) (caddr tmpIntPts)) 0 1)) (setq IntPt2 (trans (cdddr tmpIntPts) 0 1)) (vla-Delete tmpCir) (setvar "osmode" 0) (command "_.break" (car BkEnt) IntPt1 IntPt2) (setvar "osmode" 1) );end progn );end if (setvar "osmode" osm) (setvar "cmdecho" ocmd) (vla-EndUndoMark ActDoc) (princ) );end defun