Author Topic: Find pline intersections?  (Read 3640 times)

0 Members and 1 Guest are viewing this topic.

matrix2005in

  • Guest
Find pline intersections?
« on: June 13, 2006, 01:16:30 PM »
yoyo that's gr8  8-)

i was wasted my time for that line.......actually i am just a beginner so no idea about that kinda syntax...well thanks jeff..
ok here is another question...

how can i find self intersection of a polyline..and i would like to put a point on that intersection.
if it has 1 or more then it should put points on all intersections...is it possible??


Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: How to find vertex number
« Reply #1 on: June 13, 2006, 03:10:03 PM »
How about this.....note that it will not catch an intersection if that intersection lies EXACTLY on a vertex.....and I used a circle instead of a POINT......
Code: [Select]
(defun c:circleints (/ coords coordsz doc idx intlist ints pline space ss z lyr layname circ)
  (if (setq ss (ssget '((0 . "LWPOLYLINE"))))
    (progn
      (setq idx -1
    coordsZ nil
    intList nil
    doc (vla-get-activedocument (vlax-get-acad-object))
    space (if (= (getvar "cvport") 1)
    (vla-get-paperspace doc)
    (vla-get-modelspace doc)
    )
    layname "CircleLayer" ;;use your Layer name
    )
      (setq lyr (vla-add (vla-get-layers doc) layname))
      (vla-put-color lyr 1);;make this whatever color you want, 1 is red
      (while (setq pline (ssname ss (setq idx (1+ idx))))
(setq pline (vlax-ename->vla-object pline))
(setq ints (vlax-invoke pline 'intersectwith pline acextendnone))
(setq coords (vlax-get pline 'coordinates))
(setq z (vla-get-elevation pline))
(while coords
  (setq coordsZ (cons (list (car coords) (cadr coords) z) coordsZ))
  (setq coords (cddr coords))
  )
(while ints
  (setq intList (cons (list (car ints) (cadr ints) (caddr ints)) intList))
  (setq ints (cdddr ints))
  )
(foreach x coordsZ
  (setq intlist (vl-remove-if '(lambda (y)
(equal x y 0.0001)
)
  intList)
)
  )
(mapcar '(lambda (x)
   (setq circ (vlax-invoke space 'addcircle x 2.0));;you can adjust the Radius by changing the 2.0 here
   (vla-put-layer circ layname)
   )
intlist)
)
      )
    )
  (princ)
  )
EDIT - modified code for the circles layer
« Last Edit: June 15, 2006, 04:17:00 PM by Jeff_M »

LE

  • Guest
Re: How to find vertex number
« Reply #2 on: June 13, 2006, 04:04:43 PM »
Just a little comment, and basically for the newbies, is there a chance to open a new thread for each change from the original topic or it is required to be in the same thread?

Hope that helps.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: How to find vertex number
« Reply #3 on: June 13, 2006, 04:35:08 PM »
Good point Luis!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find pline intersections?
« Reply #4 on: June 13, 2006, 06:44:06 PM »
Thanks for the 'Heads Up' Luis.
I split the thread for the readers.
As for the posters it did read like a rambling conversation about plines & lisp.
Hope the split did not leave anyone high & dry. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

matrix2005in

  • Guest
Re: Find pline intersections?
« Reply #5 on: June 14, 2006, 12:37:00 PM »
hi jeff

gr8 stuff..... :-)

well ...if we can put that circles in given layer... 8-)

thanks
mathew

matrix2005in

  • Guest
Re: Find pline intersections?
« Reply #6 on: June 14, 2006, 12:38:54 PM »
thank you CAB for starting a new topic

 :-)



Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Find pline intersections?
« Reply #7 on: June 15, 2006, 12:14:24 PM »
gr8 stuff..... :-)

well ...if we can put that circles in given layer... 8-)
Thanks and you're welcome!
Here's some code snips to be strategically placed into the code above:

To place the circle on a specific layer, first make sure the layer is there for our use...
Code: [Select]
);;end of initial setq's
(setq lyr (vla-add (vla-get-layers doc) "CircleLayer"));;use your Layer name
(vla-put-color lyr 1);;make this whatever color you want, 1 is red
(while (setq pline .......
Then, where each circle is created by this: (vlax-invoke space 'addcircle x 2.0)
change it to this:
Code: [Select]
(setq circ (vlax-invoke space 'addcircle x 2.0));;you can adjust the Radius by changing the 2.0 here
(vla-put-layer circ (vla-get-name lyr));;make sure to use the same name here
Also, make sure to add the variables lyr & circ to the Local declarations at the beginning

matrix2005in

  • Guest
Re: Find pline intersections?
« Reply #8 on: June 15, 2006, 02:02:26 PM »
hi jef

i am not sure ...but i am getting error

; error: bad argument type: VLA-OBJECT nil

i am not sure where i am mistaken :-(

mathew

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Find pline intersections?
« Reply #9 on: June 15, 2006, 04:11:28 PM »
Well, that means you are probably inserting the code into the incorrect spot....I'll update the code above in a few minutes.

matrix2005in

  • Guest
Re: Find pline intersections?
« Reply #10 on: June 16, 2006, 12:33:45 PM »
hi jeff

i am waiting  :roll:

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Find pline intersections?
« Reply #11 on: June 16, 2006, 12:55:42 PM »
EDIT - modified code for the circles layer
hi jeff

i am waiting  :roll:
For what? As I said I'd do, I modified the code above...note the edit time at the bottom of that post.......

matrix2005in

  • Guest
Re: Find pline intersections?
« Reply #12 on: June 16, 2006, 02:14:18 PM »
hi jeff

thanks man very good...yeah i wasn't aware that you modified the above one...
thanks again :kewl: