乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 98|回复: 5

[编程交流] Invalid point, polygon segment

[复制链接]

8

主题

22

帖子

14

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 18:35:26 | 显示全部楼层 |阅读模式
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:
 
  1. (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
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:57:15 | 显示全部楼层
Maybe something like this code , replace pline with (command "xclip" "p" "" "n" "p" dont need "C" on end
 
  1. ; 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")
 
  1. ; 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
回复

使用道具 举报

8

主题

22

帖子

14

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 19:03:17 | 显示全部楼层
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.
回复

使用道具 举报

55

主题

402

帖子

357

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
274
发表于 2022-7-5 19:16:53 | 显示全部楼层
I would suggest this :-
 
  1. (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)
回复

使用道具 举报

8

主题

22

帖子

14

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 19:30:16 | 显示全部楼层
Thanks Satish, that worked perfectly
回复

使用道具 举报

55

主题

402

帖子

357

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
274
发表于 2022-7-5 19:47:27 | 显示全部楼层
Happy to hear that
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-12 13:46 , Processed in 0.420503 second(s), 64 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表