Results 1 to 5 of 5

Thread: vl-position not working on point list

  1. #1
    Member
    Join Date
    2010-08
    Posts
    21
    Login to Give a bone
    0

    Question vl-position not working on point list

    This sample function works fine with the sample point-list data listed, but when I use the actual point list generated by the polygon I get a nil result for vl-postion

    (defun testme (/ poly minx startxy startvertex)
    (setq poly (list (list 7.5 14.0) (list 7.5 7.0) (list 1.5 7.0) (list 1.5 14.0)(list 14.0 22.1)(list -11.0 14.0)))
    (setq minx (apply 'min (mapcar 'car poly)))
    (setq startxy
    (list minx
    (apply 'max
    (mapcar 'cadr (vl-remove-if-not (function (lambda (x) (equal minx (car x) 0.00000001))) poly)))))
    (setq startvertex (vl-position startxy poly))
    (list startvertex poly(member startxy poly)))

    I am generating the pointlist with a function similar to the ones covered in this thread.
    http://www.cadtutor.net/forum/showth...-vertices-list
    Attached Images Attached Images

  2. #2
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: vl-position not working on point list

    Works fine wtih me

    Are your referingto LM's code?

  3. #3
    Member
    Join Date
    2010-08
    Posts
    21
    Login to Give a bone
    0

    Default Re: vl-position not working on point list

    Yes, (basically with no z-coordinate on 3d poly's.)

    For a project I need all polygons drawn similarly

    I am trying to write a routine that will renumber my polygon vertices so the polygon is drawn clockwise from the vertex with the the smallest X, then largest Y of those.

    If I replace the defun line with this:

    (defun testme ( polypointlist / minx startxy startvertex)

    WHERE polypoinlist is the reply from Lee Mac's much tinier and way faster than mine point list function.

    I get a nil value. I thought maybe it was (= versus (equal parameter.

    stumped.

  4. #4
    Member
    Join Date
    2010-08
    Posts
    21
    Login to Give a bone
    0

    Question Re: vl-position not working on point list

    Wow,

    Here is the full routine. I am stumped.

    If I draw a rectangle it works, my clean pointlist is given.
    If I then rotate that exact rectangle 180 degrees I get a nil value here.

    (setq startvertex (vl-position startxy poly));;;;;<--nil value occasionally occurs here

    ;;;;;; begin of poly_to_pointlist
    (defun poly_to_pointlist (ent / l f e poly minx maxx miny maxy startxy startvertex)
    (vl-load-com)
    ;;; Lee Mac + GP_ : poly to coords http://forums.augi.com
    (setq poly ((lambda (f / e)
    (if (setq e (vlax-ename->vla-object (car ent))
    poly (vl-position (vlax-get e 'objectname) '("AcDbPolyline" "AcDb2dPolyline" "AcDb3dPolyline")))
    (f (vlax-get e 'coordinates))))
    (lambda (l)
    (cond ((and l (= poly 0)) (cons (list (car l) (cadr l)) (f (cddr l))))
    ((and l (= poly 1)) (cons (list (car l) (cadr l)) (f (cdddr l))))
    ((and l (= poly 2)) (cons (list (car l) (cadr l)) (f (cdddr l))))))))
    ;;; Lee Mac + GP_ : poly to coords http://forums.augi.com
    (if (equal (car poly) (last poly) 0.000001)
    (setq poly (reverse (cdr (reverse poly)))))
    (setq minx (apply 'min (mapcar 'car poly)))
    (setq maxx (apply 'max (mapcar 'car poly)))
    (setq miny (apply 'min (mapcar 'cadr poly)))
    (setq maxy (apply 'max (mapcar 'cadr poly)))
    (setq startxy
    (list minx
    (apply 'max
    (mapcar 'cadr (vl-remove-if-not (function (lambda (x) (equal minx (car x) 0.00000001))) poly)))))
    (setq startvertex (vl-position startxy poly));;;;;<--nil value occasionally occurs here
    (if (= startvertex (-(length poly)1))
    (setq poly (reverse poly)
    startvertex 0))
    (if (= startvertex 0)
    (if (< (- (car (car poly)) (car (cadr poly))) (- (cadr (car poly)) (cadr (cadr poly))))
    (setq poly (reverse poly)))
    (progn (setq poly (append (member startxy poly) (cdr (member startxy (reverse poly)))))
    (if (< (- (car (car poly)) (car (cadr poly))) (- (cadr (car poly)) (cadr (cadr poly))))
    (setq poly (reverse poly)))))
    poly)
    ;;;;;; end of poly_to_pointlist

  5. #5
    Member
    Join Date
    2010-08
    Posts
    21
    Login to Give a bone
    0

    Unhappy Re: vl-position not working on point list

    vl-position not finding item in a given list.

    I assume there is a global variable or (=) versusd (equal)problem.

    see the jpg attached for the watch-box showing that

    notice that the values should yield a non-nil result.
    Attached Images Attached Images
    Attached Files Attached Files

Similar Threads

  1. 2014: topo from point list
    By MikeJarosz in forum Revit Architecture - General
    Replies: 2
    Last Post: 2014-04-21, 06:02 PM
  2. 3 Point Align Command not working
    By sunofcain in forum Raster Design - General
    Replies: 1
    Last Post: 2011-05-07, 12:56 AM
  3. Point list to variables
    By paul.fds in forum AutoLISP
    Replies: 5
    Last Post: 2009-06-12, 07:36 AM
  4. Adding a value to position in a list
    By dkennard in forum AutoLISP
    Replies: 3
    Last Post: 2007-06-29, 01:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •