Any help would be appreciated.
Alfredo Medina
alfm...@hotmail.com
Cad Manager
The Prisco Group
Hopewell NJ
I'm about to leave right now but here is a quick one, not fully tested, also
there is one function in the bonus tools I do not remember the name.
Tested only with lwpolylines...
(defun C:TEST ()
(vl-load-com)
(setq ent (car (entsel)))
(setq vla (vlax-ename->vla-object ent))
(list (/ (length (vlax-safearray->list
(variant-value (vla-get-coordinates vla))
)
)
2
)
(/ (length
(vlax-safearray->list
(variant-value (vla-intersectwith vla vla acExtendNone))
)
)
3
)
)
)
;; ->'(9 9) = not self-intersected if returns pairs
;; ->'(8 10) = self-intersected if returns not pairs
I will back on Monday, see ya.
Luis
CrazyCAD person...
(defun @self_intersect (object / name open)
(cond
((= (type object) 'ENAME)
(setq object (vlax-ename->vla-object object)
name (vlax-get object "ObjectName")
)
)
((= (type object) 'VLA-OBJECT)
(setq name (vlax-get object "ObjectName"))
)
)
(cond
((not name))
((wcmatch name "AcDb#dPolyline")
(setq open (* 2 (1+ (vlax-get object "Closed"))))
(> (length (@cv_parse_list (vlax-invoke object "IntersectWith"
object acExtendNone) 3))
(- (length (@cv_parse_list (vlax-get object "Coordinates") 3))
open)
)
)
((= name "AcDbPolyline")
(setq open (* 2 (1+ (vlax-get object "Closed"))))
(> (length (@cv_parse_list (vlax-invoke object "IntersectWith"
object acExtendNone) 3))
(- (length (@cv_parse_list (vlax-get object "Coordinates") 2))
open)
)
)
((= name "AcDbSpline")
(if (vlax-invoke object "IntersectWith" object acExtendNone) T)
)
)
)
--
John Uhden, Cadlantic/formerly CADvantage
--> mailto:juh...@cadlantic.com
--> http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
FAX 732-528-1332
"Alfredo Medina" <alme...@hotmail.com> wrote in message
news:3C194CF8...@hotmail.com...
Thank you guys for your help. I will try it out and will post again with
comments.
Alfredo Medina
alfm...@hotmail.com
Luis Esquivel wrote:
>Alfredo,
>
>I'm about to leave right now but here is a quick one, not fully tested, also
>there is one function in the bonus tools I do not remember the name.
>
>Tested only with lwpolylines...
>
>(defun C:TEST ()
(...)
John Uhden wrote:
>
> I think the following will work...
> ;;-------------------------------------------------------------
> ;; Function returns a list of 3D points from a continuous list
> ;; as returned by (vlax-safearray->list (vlax-variant-value X))
> ;;
(...)
;;; sample by Luis Esquivel, December 17, 2001
;;; self-intersect
;;; return: T or nil
;;; note: you must pass a polyline or spline object, no error catching
(defun C:TEST (/ ent)
(lbx-self-intersect
(setq ent (car (entsel)))
)
)
(defun lbx-self-intersect (ent / vla objname)
(vl-load-com)
(setq vla (vlax-ename->vla-object ent)
objname (vla-get-objectname vla)
)
(if (= "AcDbSpline" objname)
(progn
(if (safearray-value
(vlax-variant-value
(vla-intersectwith
vla
vla
acExtendNone
)
)
)
T
nil
)
)
(progn
(apply
'/=
(list
(- (/ (length (vlax-safearray->list
(variant-value (vla-get-coordinates vla))
)
)
2
)
2
)
(/ (length
(vlax-safearray->list
(variant-value
(vla-intersectwith vla vla acExtendNone)
)
)
)
3
)
)
)
)
)
)
Good News: It worked on a 3DMesh
Bad News: It doesn't work properly on an AcDb2dPolyline ("heavy") <see my
previous contribution>
You're just a (cond ...) away from perfection.
--
John Uhden, Cadlantic/formerly CADvantage
--> mailto:juh...@cadlantic.com
--> http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
FAX 732-528-1332
"Luis Esquivel" <lu...@slarchitects.com> wrote in message
news:2AC2EE71ED54F181...@in.WebX.maYIadrTaRb...
I lied. We've got more problems than that.
ActiveX methods can return the coordinates of only definition points... no
way to get the extras added by curve-fitting without using the old-fashioned
way (entget (entnext etc.)). So mine is technically wrong as well. If we
limit the domain to just LWPolys and Splines, then I can fix your
open/closed situation fast.
Gotta go.....................
--
John Uhden, Cadlantic/formerly CADvantage
--> mailto:juh...@cadlantic.com
--> http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
FAX 732-528-1332
"Luis Esquivel" <lu...@slarchitects.com> wrote in message
news:2BA513F017396C1F...@in.WebX.maYIadrTaRb...
> Thanks John,
>
> Actually I been doing more test on this function and found some special
> conditions, here is what I have so far, in case some else wants to help me
> on this.
>
> I do not need for now this specific <function> but never the less, I need
to
> get focus in other kind of stuff right now so here it is...
>
> ;;; sample by Luis Esquivel, December 17, 2001
> ;;; self-intersect
> ;;; return: T or nil
> ;;; note: you must pass a polyline or spline object, no error catching
>
> (defun C:TEST (/ ent)
> (lbx-self-intersect
> (setq ent (car (entsel)))
> )
> )
>
> (defun lbx-self-intersect (ent)
> ;;; / vla objname)
> (vl-load-com)
> (setq vla (vlax-ename->vla-object ent)
> objname (vla-get-objectname vla)
> )
> (if (= "AcDbSpline" objname)
> (progn
> (if (safearray-value
> (vlax-variant-value
> (vla-intersectwith
> vla
> vla
> acExtendNone
> )
> )
> )
> T
> nil
> )
> )
> (progn
> (if (= :vlax-false (vla-get-closed vla))
> (progn
> (if (safearray-value
> (setq intersections
> (variant-value
> (vla-intersectwith vla vla acExtendNone)
> )
> )
> )
> (apply
> '/=
> (list
> (- (/ (length (vlax-safearray->list
> (variant-value (vla-get-coordinates vla))
> )
> )
> 2
> )
> 2
> )
> (/ (length (vlax-safearray->list intersections)) 3)
> )
> )
> )
> )
> (if (safearray-value
> (setq intersections
> (variant-value
> (vla-intersectwith vla vla acExtendNone)
> )
> )
> )
>
> (apply
> '/=
> (list
> (/ (length (vlax-safearray->list
> (variant-value (vla-get-coordinates vla))
> )
> )
> 2
> )
> (/ (length (vlax-safearray->list intersections)) 3)
> )
> )
> )
> )
> )
> )
> )
>
> Still need to verify when a open polyline is selected and has two straight
> segments see image...
>
>
----------------------------------------------------------------------------
----
If the operation fails, then the reason is most
likely because the object is self-intersecting
(although there are other reasons why it may fail
as well).
"Alfredo Medina" <alme...@hotmail.com> wrote in message
news:3C194CF8...@hotmail.com...
Thank you very much. That is a good idea. I will try it out.
Alfredo Medina
Tony Tanzillo wrote:
>
> Create a copy of the object, make it closed,
> and then try to create a region from it.
>
> If the operation fails, then the reason is most
> likely because the object is self-intersecting
> (although there are other reasons why it may fail
> as well).
>
> "Alfredo Medina" <alme...@hotmail.com> wrote in message
> news:3C194CF8...@hotmail.com...
> > How can I detect through Lisp if a Lwpolyline, Pline or Spline is a
> > self-intersecting entity?
> >
(...)