Invalid point, polygon segment
Hi,Im trying to pass points to the xclip command for making a new poly boundary.
The points are stored from an existing poly in the drawing.
Everything looks good apart from the error "Invalid point, polygon segment is zero length"
I have osmode set to 0
this is the part of the code working the xclip:
(setq $count 0)(ssget "_x" '((2 . "Drawing1")))(command "xclip" "p" "" "n" "p" (repeat $C_lst (setq $a (strcat (rtos (car (nth $count $vert_lst))) "," (rtos (cadr (nth $count $vert_lst))))) (command "\n") (setq $count (1+ $count)) );repeat"")
$vert_lst is the list of vertices extracted from the poly and seems to be fine.
$C_lst is the count of vertices in $vert_lst
I'm sure there are better ways to do this and it would nice to understand where I'm going wrong.
Cheers Maybe something like this code , replace pline with (command "xclip" "p" "" "n" "p" dont need "C" on end
; do offset 1st then (if (not getcoords)(load "pline co-ords")); do offset here(setq obj (entlast)) ; return last offset line(co-ords2xy) ; seperate routine that retrieves the pline points as a list of points ((x1 y1)(x2 y2)(princ co-ordsxy); this should return co-ordsxy(entdel obj) ; del offset pline(setq x -1) ; so x starts at nth 0 at start and closing(command "PLINE" (while (= (getvar "cmdactive") 1) (COMMAND (repeat (length co-ordsxy) (nth (setq x (+ x 1)) co-ordsxy) ) ) ) )(command "C")
; pline co-ords example; By Alan H(defun getcoords (ent) (vlax-safearray->list (vlax-variant-value (vlax-get-property (vlax-ename->vla-object ent) "Coordinates" ) ) ))(defun co-ords2xy (); convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z(setq len (length co-ords))(setq numb (/ len 2)) ; even and odd check required(setq I 0)(repeat numb(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) )); odd (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))(setq co-ordsxy (cons xy co-ordsxy))(setq I (+ I 2)))); program starts here(setq co-ords (getcoords (car (entsel "\nplease pick pline"))))(co-ords2xy) ; list of 2d points making pline Thanks Al!,
Ill try to digest that,
I was crossing my fingers that I was already on the right track and there was something simple missing from my code with regards to xclip boundaries. I would suggest this :-
(setq pl (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length $vert_lst)) (cons 70 1) ) (mapcar (function (lambda (p) (cons 10 p))) $vert_lst) ) ))(ssget "_x" '((0 . "insert")(2 . "Drawing1")))(command "xclip" "p" "" "n" "s" pl)(entdel pl) Thanks Satish, that worked perfectly Happy to hear that
页:
[1]