Author Topic: Lee's LM:AutoBlockBreak needs some modification  (Read 4331 times)

0 Members and 1 Guest are viewing this topic.

NICK_VNV

  • Newt
  • Posts: 63
Lee's LM:AutoBlockBreak needs some modification
« on: February 20, 2015, 03:33:06 AM »
This lisp found at http://www.lee-mac.com/autoblockbreak.html
LM:AutoBlockBreak function breaks polyline incorrect way if it has more than 2 intersections with selected block. For examlpe
original drawing:

after LM:AutoBlockBreak:

what it should be look like:

I think following strings need some corrections?? :
Code: [Select]
(command
            "_.break" (list  (car int) (trans (car brk) 0 1)) "_F"
            "_non"    (trans (car  brk) 0 1)
            "_non"    (trans (cadr brk) 0 1)
)
And can this be modified to do something like this?:

PS. maybe it wil be usefull to break hatches also..
« Last Edit: February 20, 2015, 03:55:45 AM by NICK_VNV »
Sorry for my English...

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #1 on: February 20, 2015, 04:10:49 AM »
This result is not due to the number of intersections, but due to the method used to test for intersections between the block & surrounding objects, as described on my site:

Quote from: AutoBlockBreak Description
The method utilised by the program to trim the objects surrounding the block is to obtain the dimensions of the bounding box of the selected block at zero rotation, and, following transformation of such bounding box to account for block rotation, scale and orientation, the program tests for intersections between an LWPolyline (constructed from the bounding box coordinates), and a selection set of the surrounding objects.

This method, although accurate in most cases, makes the assumption that the points of intersection between the block and surrounding objects are the extremeties of the block.

NICK_VNV

  • Newt
  • Posts: 63
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #2 on: February 20, 2015, 06:32:32 AM »
Ahh, ok. Then I'll try to modify it for my needs. :-)
Sorry for my English...

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #3 on: February 20, 2015, 08:18:11 AM »
NICK_VNV's original post is a little hard to understand. There are 8 images (some duplicates), although as I am composing this I see only 4 images (strange... ). And it is part bug report and part feature request. But, FWIW, the bug NICK_VNV has noticed does exist (see the image with 4 separate grey line segments). My hunch: looking for the '_furthestapart' points does not work for entities with more than two intersections with the temporary polyline.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #4 on: February 20, 2015, 08:43:02 AM »
... Or perhaps it is not a bug. But then the word 'trim' is confusing.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #5 on: February 20, 2015, 08:56:07 AM »
But, FWIW, the bug NICK_VNV has noticed does exist (see the image with 4 separate grey line segments). My hunch: looking for the '_furthestapart' points does not work for entities with more than two intersections with the temporary polyline.
... Or perhaps it is not a bug. But then the word 'trim' is confusing.

Indeed it is not a bug, but rather a known restriction of the method used by the program to determine the break points - I feel that my description is clear on this matter:
Quote
The program will allow a user to insert (or copy) a block at a specified point with all objects surrounding the block trimmed to the rectangular block outline
Quote
This method, although accurate in most cases, makes the assumption that the points of intersection between the block and surrounding objects are the extremeties of the block.

NICK_VNV

  • Newt
  • Posts: 63
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #6 on: February 20, 2015, 10:41:07 AM »
Lee is right, I just wrong understood the purpose of this lisp. I didn't read carefully and thought it trims all objects which intersect given block.
It is strnage but I don't know why all images in my first post have duplicates  :? Sorry.
Sorry for my English...

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #7 on: February 21, 2015, 05:35:11 AM »
@ Lee:
OK, I understand. My apologies for going on about this.

Lube

  • Guest
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #8 on: February 26, 2015, 03:44:20 AM »
Sorry guys, may I ask what "LM:" does mean? Most of programms from Lee have (defun LM:name ..)

Thanks guys

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #9 on: February 26, 2015, 04:28:16 AM »
Quite a few of us use a prefix to identify our code. The purpose is primarily to reduce the possibility of our code being overwritten by code from others.

The Autocad Symbols Registration originally proposed a similar system.
http://usa.autodesk.com/adsk/servlet/index?id=1075006&siteID=123112





kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

rhino85

  • Mosquito
  • Posts: 6
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #10 on: April 11, 2020, 01:56:58 AM »
Hi Lee,

I've read through the previous posts and understand the bounding box method.
But would you consider modifying the subroutine to pick out the poly-lines in the block for the following instance which I'm using to create breaks in pipe tubing.

Thanks again for the code  :smitten:

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #11 on: April 12, 2020, 11:02:03 AM »
Your bottom most break is wrong.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

rhino85

  • Mosquito
  • Posts: 6
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #12 on: April 12, 2020, 11:51:43 AM »
Your bottom most break is wrong.

Yes, I've fixed that after viewing this gif a number of times, ha...kept thinking somethings wrong  :idea: - have updated that block since :)

tombu

  • Bull Frog
  • Posts: 288
  • ByLayer=>Not0
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #13 on: April 17, 2020, 11:55:19 PM »
Why not just use the Extrim to get the Correct results you're looking for?
Just pick the block and select inside.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

ahsattarian

  • Newt
  • Posts: 112
Re: Lee's LM:AutoBlockBreak needs some modification
« Reply #14 on: November 20, 2020, 06:49:51 AM »
I've done it  :





(defun c:a ()
  (defun sub1 () (setq po (getpoint "\n Point : ")))
  (setq s (car (entsel "\n Select Block : ")))
  (redraw s 4)
  (setq en (entget s))
  (setq nam (cdr (assoc 2 en)))
  (print nam)
  (setvar "osmode" 512)
  (setq po (getpoint "\n Point : "))
  (while (not (osnap po "nea")) (setq po (getpoint "\n Point : ")))
  (if (= (getvar 'cvport) 1) ;|  #space  |;
    (setq sp (vla-get-paperspace (vla-get-ActiveDocument (vlax-get-acad-object))))
    (setq sp (vla-get-modelspace (vla-get-ActiveDocument (vlax-get-acad-object))))
  )
  (setq ss (ssget "c" po po '((0 . "arc,ellipse,circle,*line"))))
  (if ss
    (progn
      (setq s1 (ssname ss 0))
      (setq obj1 (vlax-ename->vla-object s1))
      (setq po (vlax-curve-getclosestpointto s1 po))
      (setq par (vlax-curve-getparamatpoint s1 (vlax-curve-getclosestpointto s1 po))) ;|  #deriv  |;
      (cond
   ((equal par (vlax-curve-getendparam s1) 1e-8)
    (setq par (vlax-curve-getparamatdist s1 (- (vlax-curve-getdistatparam s1 par) 1e-3)))
   )
   ((equal par (vlax-curve-getstartparam s1) 1e-8)
    (setq par (vlax-curve-getparamatdist s1 (+ (vlax-curve-getdistatparam s1 par) 1e-3)))
   )
      )
      (setq der (vlax-curve-getfirstderiv s1 par))
      (setq ang (angle '(0.0 0.0 0.0) (trans der 0 (cdr (assoc 210 (entget s1))))))
      (setq obj2 (vla-insertblock sp (vlax-3d-point po) nam 1.0 1.0 1.0 0.0))
      (vla-getboundingbox obj2 'bl 'tr)
      (vla-delete obj2)
      (setq p1 (vlax-safearray->list bl))
      (setq p3 (vlax-safearray->list tr))
      (setq p2 (list (car p1) (cadr p3)))
      (setq p4 (list (car p3) (cadr p1)))
      ;;(command "pline" p1 p2 p3 p4 "close")
      (setq po1 (polar po (+ (angle po p1) ang) (distance po p1)))
      (setq po2 (polar po (+ (angle po p2) ang) (distance po p2)))
      (setq po3 (polar po (+ (angle po p3) ang) (distance po p3)))
      (setq po4 (polar po (+ (angle po p4) ang) (distance po p4)))
      (command "pline" po1 po2 po3 po4 "close")
      (setq s3 (entlast))
      (setq obj3 (vlax-ename->vla-object s3))
      (setq li (vlax-invoke obj3 'intersectwith obj1 acextendboth))
      (cond
   ((= (length li) 6)
    (setq pt1 (list (nth 0 li) (nth 1 li) (nth 2 li)))
    (setq pt2 (list (nth 3 li) (nth 4 li) (nth 5 li)))
    (command "break" (list s1 po) "f" "non" pt1 "non" pt2) ;|  #Break  |;
   )
      )
      (vla-delete obj3)
      (setq obj4 (vla-insertblock sp (vlax-3d-point po) nam 1.0 1.0 1.0 ang))
    )
    (princ "\n  No Line !!  ")
  )
  (princ)
)