Jump to content

Intersecting lines


MR MAN

Recommended Posts

By hand or automatically?

For the first case use BREAK command with “First point” option and subsequently select intersection point twice – do the same for both lines. Done!

Link to comment
Share on other sites

Will require an AutoLISP routine with the above structure

1. Select the lines to process (filter for errors).

2. List endpoints of those lines.

3. Get the intersection point – using INTERS statements; exit if lines don’t intersect or the point doesn’t lies on (both) lines.

4. Call programmatically the BREAK command to split entities.

Link to comment
Share on other sites

This will work on LINEs, not PLINESs or ARCs

 

[b][color=BLACK]([/color][/b]defun c:bil [b][color=FUCHSIA]([/color][/b]/ ss l1 l1d l2 l2d p10 p11 p20 p21 ip[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not ss[b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]/= [b][color=GREEN]([/color][/b]sslength ss[b][color=GREEN])[/color][/b] 2[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect 2 LINEs that Intersect"[/color][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"LINE"[/color][b][color=BLUE])[/color][/b]
                              [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=RED])[/color][/b]
                                  [b][color=RED]([/color][/b]cons 410 [b][color=PURPLE]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b]
                                  [b][color=RED]([/color][/b]cons 67 [b][color=PURPLE]([/color][/b]- 1 [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"TILEMODE"[/color][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]setq l1 [b][color=NAVY]([/color][/b]ssname ss 0[b][color=NAVY])[/color][/b] l1d [b][color=NAVY]([/color][/b]entget l1[b][color=NAVY])[/color][/b]
       l2 [b][color=NAVY]([/color][/b]ssname ss 1[b][color=NAVY])[/color][/b] l2d [b][color=NAVY]([/color][/b]entget l2[b][color=NAVY])[/color][/b]
       p10 [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 10 l1d[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] p11 [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 11 l1d[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       p20 [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 10 l2d[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] p21 [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 11 l2d[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       ip [b][color=NAVY]([/color][/b]inters p10 p11 p20 p21[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]cond [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]not ip[b][color=MAROON])[/color][/b]
        [b][color=MAROON]([/color][/b]alert [color=#2f4f4f]"Lines Do Not Intersect"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       [b][color=NAVY]([/color][/b]T
        [b][color=MAROON]([/color][/b]command [color=#2f4f4f]"_.BREAK"[/color] l1 ip ip
                 [color=#2f4f4f]"_.BREAK"[/color] l2 ip ip[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

 

-David

Link to comment
Share on other sites

Another,

 

(defun c:brk (/ ss i y Obj1 Obj2 Ent1 Ent2 iLst ip)
 (vl-load-com)

 (if (setq ss (ssget "_:L" '((0 . "~VIEWPORT"))))
   (progn
     
     (setq i (sslength ss))
     (while (not (minusp (setq y (1- i) i (1- i))))
       (setq Obj1 (vlax-ename->vla-object (setq Ent1 (ssname ss i))))

       (while (not (minusp (setq y (1- y))))
         (setq Obj2 (vlax-ename->vla-object (setq Ent2 (ssname ss y))))

         (if (setq iLst (vlax-invoke Obj1 'IntersectWith Obj2 acExtendNone))
           (command "_.break" Ent1 "_non" (setq ip (list (car iLst) (cadr iLst) (caddr iLst)))
                     ip "_.break" (list Ent2 ip) "_non" ip ip))))))

 (princ))
   

Link to comment
Share on other sites

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