DOT IN INTESECTION

DOT IN INTESECTION

eyal.ch
Collaborator Collaborator
1,324 Views
12 Replies
Message 1 of 13

DOT IN INTESECTION

eyal.ch
Collaborator
Collaborator

Hi guys,

 

Could you help with a lisp that: 

after selecting two lines (it can be also lines from close polyline) it will create a point in the virtual intersection,

 

I mean the lines must not be parallel so the point will be in the intersection of the lines.(if we extend them)

 

Thank you

0 Likes
Accepted solutions (3)
1,325 Views
12 Replies
Replies (12)
Message 2 of 13

ВeekeeCZ
Consultant
Consultant
Accepted solution

If you bother to search you'll find THIS 

0 Likes
Message 3 of 13

eyal.ch
Collaborator
Collaborator

Hi @ВeekeeCZ ,

 

Thank you, but sorry for ignorance- how do I operate the lisp?

;; Intersections  -  Lee Mac
;; Returns a list of all points of intersection between two objects
;; for the given intersection mode.
;; ob1,ob2 - [vla] VLA-Objects
;;     mod - [int] acextendoption enum of intersectwith method

(defun LM:intersections ( ob1 ob2 mod / lst rtn )
    (if (and (vlax-method-applicable-p ob1 'intersectwith)
             (vlax-method-applicable-p ob2 'intersectwith)
             (setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
        )
        (repeat (/ (length lst) 3)
            (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
                  lst (cdddr lst)
            )
        )
    )
    (reverse rtn)
)
0 Likes
Message 4 of 13

ВeekeeCZ
Consultant
Consultant

That's just a subfunction. You need the main (test) function which will call that one.

0 Likes
Message 5 of 13

eyal.ch
Collaborator
Collaborator

Can you please do that for me? and write the lisp so I can operate it.

I don't know how to do that.

 

0 Likes
Message 6 of 13

ВeekeeCZ
Consultant
Consultant

Not sure what else you need from me. Just follow the link I gave you. There is all you need to make it work.

0 Likes
Message 7 of 13

eyal.ch
Collaborator
Collaborator

How to call  a subfunction.  "You need the main (test) function which will call that one."

I don't know how to call it.

 

0 Likes
Message 8 of 13

CodeDing
Advisor
Advisor
Accepted solution

@eyal.ch ,

 

What @ВeekeeCZ  is trying to say, is that Lee's website already shows you how to call the subfunction and everything.

If you are not comfortable enough with putting Lee's 2 pieces of information together, then perhaps you are trying to advance faster than you should be.

Do you know how to run a lisp file even by chance?

If not, look HERE.

Otherwise, save this text into a file with a '.lsp' extension (a lisp file):

;; Intersections  -  Lee Mac
;; Returns a list of all points of intersection between two objects
;; for the given intersection mode.
;; ob1,ob2 - [vla] VLA-Objects
;;     mod - [int] acextendoption enum of intersectwith method

(defun LM:intersections ( ob1 ob2 mod / lst rtn )
    (if (and (vlax-method-applicable-p ob1 'intersectwith)
             (vlax-method-applicable-p ob2 'intersectwith)
             (setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
        )
        (repeat (/ (length lst) 3)
            (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
                  lst (cdddr lst)
            )
        )
    )
    (reverse rtn)
)
(defun c:inter ( / obj1 obj2 )    
    (if (and (setq obj1 (car (entsel "\nSelect 1st Object: ")))
             (setq obj2 (car (entsel "\nSelect 2nd Object: ")))
        )
        (foreach pnt (LM:intersections (vlax-ename->vla-object obj1) (vlax-ename->vla-object obj2) acextendnone)
            (entmake (list '(0 . "POINT") (cons 10 pnt)))
        )
    )
    (princ)
)
(vl-load-com) (princ)

Then load the file into AutoCAD (as described in the link above).

 

Then run the INTER command (as defined in Lee's example lisp).

 

If you cannot perform these steps, then you will need to spend more time researching how to accomplish these basics.

 

Best,

~DD

Message 9 of 13

Kent1Cooper
Consultant
Consultant

@eyal.ch wrote:

.... after selecting two lines (it can be also lines from close polyline) it will create a point in the virtual intersection,....


Am I missing something here?  It's just the APParent Intersection, which Object Snap will find for you:

 

POINT command

APP {Object Snap mode}

pick your two Lines/Polyline line segments.

 

If you need that built into an AutoLisp routine, that can be done easily enough, but do you really?

Kent Cooper, AIA
0 Likes
Message 10 of 13

eyal.ch
Collaborator
Collaborator

Hi @CodeDing ,

 

I know how to run a lisp, I don't know how to get this option to work:

2020-02-14_13-40-25.jpg

I want to select the 2 lines like the example , and it will draw a point in the entersection.

The lisp you wrote doesn't do this.

Thanks

0 Likes
Message 11 of 13

CodeDing
Advisor
Advisor
Accepted solution

@eyal.ch ,

 

Change this

acextendnone

To this:

acextendboth
0 Likes
Message 12 of 13

eyal.ch
Collaborator
Collaborator

EXCELENT!  THANK YOU.

 

0 Likes
Message 13 of 13

Kent1Cooper
Consultant
Consultant

@eyal.ch wrote:

....

2020-02-14_13-40-25.jpg

I want to select the 2 lines like the example , and it will draw a point in the entersection.

....


I repeat:  Is there some reason I don't understand that you don't just use the POINT command and APParent-intersection Object Snap?  I don't see the benefit of a specialty routine.

Kent Cooper, AIA
0 Likes