Jump to content

Recommended Posts

Posted

Hi all, let's see if someone can figure this out...

 

I am in need for a LISP routine that will allow me to click once on an object (line, circle, etc) and it will break that object AND create a gap of one unit between the two ends.

 

Basically it breaks the object and then it trims 1/2 unit from either side of the point selected.

 

How can this be done?

 

rcmob

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    10

  • alanjt

    9

  • rcmob

    6

  • chelsea1307

    4

Top Posters In This Topic

Posted Images

Posted

might something along the line of this help

;; This lisp breaks a two lines which cross each other
(defun c:bc ()
(setq scl (getvar "dimscale" ))
(setq dis (* scl 0.052))
(if
(= "WASTE" name)
(setq dist (* dis 1.5))
(if
(= "DUCT" name)
(setq dist (* dis 1.5))
(if
(= "DUCT-RA" name)
(setq dist (* dis 1.5))
(setq dist (* dis 1.5))
)))
(setq lne (entsel "\nPick line to break:")) (terpri)
(setq pnt (getpoint "\nPick break point:" )) (terpri)
(setq pick (entget (car lne)))
(setq pt1 (cdr (assoc 10 pick)))
(setq pt2 (cdr (assoc 11 pick)))
(setq a (angle pt1 pt2))
(setq ang ( * a 57.3))
(setq bpt1 (polar pnt a dis))
(setq bpt2 (polar pnt (- a pi) dis))
(command "break" lne "f" bpt1 bpt2 )
)

Posted

what's the 'name' variable?

 

might something along the line of this help

;; This lisp breaks a two lines which cross each other
(defun c:bc ()
(setq scl (getvar "dimscale" ))
(setq dis (* scl 0.052))
(if
(= "WASTE" name)
(setq dist (* dis 1.5))
(if
(= "DUCT" name)
(setq dist (* dis 1.5))
(if
(= "DUCT-RA" name)
(setq dist (* dis 1.5))
(setq dist (* dis 1.5))
)))
(setq lne (entsel "\nPick line to break:")) (terpri)
(setq pnt (getpoint "\nPick break point:" )) (terpri)
(setq pick (entget (car lne)))
(setq pt1 (cdr (assoc 10 pick)))
(setq pt2 (cdr (assoc 11 pick)))
(setq a (angle pt1 pt2))
(setq ang ( * a 57.3))
(setq bpt1 (polar pnt a dis))
(setq bpt2 (polar pnt (- a pi) dis))
(command "break" lne "f" bpt1 bpt2 )
)

Posted

honestly not exactly sure, i didnt write this one, not sure who wrote it its in our company standards with no name on as to who wrote it. Looks like it has something to do with how big the break is depending on what layer its on, but ive used it on layers not listed and it worked fine

Posted
honestly not exactly sure, i didnt write this one, not sure who wrote it its in our company standards with no name on as to who wrote it. Looks like it has something to do with how big the break is depending on what layer its on, but ive used it on layers not listed and it worked fine

it doesn't check layers and the name check if the first thing performed. how odd. what returns if you type !name?

Posted

Hi, Thanks for the code, however I am looking for a lisp that breaks a line and creates a gap where I click, not where it crosses another line or anything like that.

Any suggestions?

 

rcmob

Posted
When i try it i get nil

who knows. oh well, just curious.

Posted
Hi, Thanks for the code, however I am looking for a lisp that breaks a line and creates a gap where I click, not where it crosses another line or anything like that.

Any suggestions?

 

rcmob

did you even try chelsea's posted code?

Posted

I tried, but I get the error: "; error: no function definition: SSREDRAW" after pressing "Enter"

 

rcmob

Posted

Hey dude,

 

Here's a quicky and dirty option for ya :)

 

(defun c:qBrk (/ off pt ent ang)
 (vl-load-com)
 (initget 7)
 (setq off (getdist "\nSpecify Break Distance: "))  
 (while (and (setq pt (getpoint "\nSelect Point to Break: "))
             (setq ent (car (nentselp pt))))
   (setq ang (angle '(0 0 0)
               (vlax-curve-getFirstDeriv ent
                 (vlax-curve-getParamatPoint ent
                   (setq pt (vlax-curve-getClosestPointto ent pt))))))
   (command "_.break" (list ent pt) "_F" "_non"
            (polar pt ang (/ off 2.)) "_non" (polar pt (+ pi ang) (/ off 2.))))
 (princ))

Posted

Here it is a little cleaned up took the name stuff out and it didnt seem to effect it at all, right now the size of the space is based on dimscale (i think please someone correct me if im wrong) This is most likely changeable if you have a set size to make it each time.

;; This lisp breaks a two lines which cross each other
(defun c:bc ()
(setq scl (getvar "dimscale" ))
(setq dis (* scl 0.052))
(setq lne (entsel "\nPick line to break:")) (terpri)
(setq pnt (getpoint "\nPick break point:" )) (terpri)
(setq pick (entget (car lne)))
(setq pt1 (cdr (assoc 10 pick)))
(setq pt2 (cdr (assoc 11 pick)))
(setq a (angle pt1 pt2))
(setq ang ( * a 57.3))
(setq bpt1 (polar pnt a dis))
(setq bpt2 (polar pnt (- a pi) dis))
(command "break" lne "f" bpt1 bpt2 )
)

Posted

An extended version of my previous post:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:qBrk [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *error* doc vl ov pt ent ang[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b]lee[b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndoMark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] ov [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl ov[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] lee[b][color=RED])[/color][/b] [b][color=#ff00ff]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\n** Error: "[/color][/b] lee [b][color=#ff00ff]" **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b]
             [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       vl [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"CMDECHO"[/color][/b] [b][color=#ff00ff]"OSMODE"[/color][/b][b][color=RED])[/color][/b] ov [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]getvar[/color][/b] vl[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"CMDECHO"[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b]
 
 [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] *Mac [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] *Mac [b][color=#009999]10.0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]initget[/color][/b] [b][color=#009900]4[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] *Mac
   [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]getdist[/color][/b]
            [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\nSpecify Break Distance <"[/color][/b]
              [b][color=RED]([/color][/b][b][color=BLUE]vl-princ-to-string[/color][/b] *Mac[b][color=RED])[/color][/b] [b][color=#ff00ff]"> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]*Mac[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 
 [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] [b][color=#ff00ff]"\nSelect Point to Break: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
             [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentselp[/color][/b] pt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   
   [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-error-p[/color][/b]
            [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-apply[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]vlax-curve-getEndParam[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] ent[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n** Cannot Break that Object **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
         
         [b][color=RED]([/color][color=Blue]t[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]vla-StartUndoMark[/color][/b] doc[b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ang [b][color=RED]([/color][/b][b][color=BLUE]angle[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b]
                      [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getFirstDeriv[/color][/b] ent
                        [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getParamatPoint[/color][/b] ent
                          [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getClosestPointto[/color][/b] ent pt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"OSMODE"[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_.break"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] ent pt[b][color=RED])[/color][/b] [b][color=#ff00ff]"_F"[/color][/b]
            [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] pt ang [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *Mac [b][color=#009999]2.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] [b][color=BLUE]pi[/color][/b] ang[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *Mac [b][color=#009999]2.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndoMark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl ov[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
            

Posted

Lee Mac...

 

Your code does exactly what I need!

 

Thanks to all who helped!

 

rcmob

Posted
Lee Mac...

 

Your code does exactly what I need!

 

Thanks to all who helped!

 

rcmob

 

 

Not a problem - got a bit carried away with it :)

Posted

Ok, I have been using it for a few days now and it works great but it has one bug...

 

If I try to use it on a circle, instead of creating a gap at the point I select, it actually leaves an arc of the selected length and deletes the rest of the circle...Basically it does the exact opposite than it does on a line...

 

Any clue what is going on?

 

rcmob

Posted

Any clue what is going on?

 

Yes, my function just works on the Break command - which will produce an arc when used on a circle...

Posted

I see...that explains it...

 

Any idea on an alternate solution that would also work on circles the same way as your code works on lines?

 

rcmob

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...