乐筑天下

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

[编程交流] Polyline vertext - set "name"

[复制链接]

28

主题

76

帖子

48

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
140
发表于 2022-7-5 18:15:16 | 显示全部楼层
" number of vertex is n=....15..... can you add something like this at the end of the lisp? To count the number of vertex...
回复

使用道具 举报

22

主题

326

帖子

185

银币

后起之秀

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

铜币
243
发表于 2022-7-5 18:18:57 | 显示全部楼层
As a lisper, can't you do it by yourself ? ^^ Hi hi.
Maybe like this ?
  1. (defun C:TEST ( / i ss) (if   (setq i 0 ss (ssget ":E:S" '((0 . "LWPOLYLINE"))))   (progn    (foreach n     (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (ssname ss 0))))     (set (read (strcat "P" (itoa (setq i (1+ i))))) n)      (princ (strcat "\nP" (itoa i) " : " (vl-princ-to-string n)))               )   (princ  (strcat "\nTotal number of vertex is n = " (itoa i) "\n"))          ;Do sth other   (repeat i   (set (read (strcat "P" (itoa i))) nil )(setq i (1- i))   )   )   )(princ) )
回复

使用道具 举报

28

主题

76

帖子

48

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
140
发表于 2022-7-5 18:22:49 | 显示全部楼层
Thanks, ketxu!
I'm not a real lisper
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-5 18:25:55 | 显示全部楼层
A lot "similar": http://forums.augi.com/showthread.php?t=126660Just take note to be careful about global variables - especially when generating arbitrary numbers of them like with this code. In AutoLisp (and nearly all other languages) a global variable can cause quite many headaches as anything might modify / rely on it being there. Thus some other routine might rely on a pt2 being saved somewhere, but then fail because this one's modified / cleared the value. Or some other routine might clear one of these values and cause this routine to fail. The point is that you cannot think of all possibilities, since you cannot see the future (never mind that the present is a huge task to test for every possibility).
 
Though we haven't seen where these are supposed to be used. Are they meant to stay as global to be reused many times from different routines? We'd be able to give much better advise if we knew exactly what was supposed to happen with these points.
回复

使用道具 举报

28

主题

76

帖子

48

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
140
发表于 2022-7-5 18:28:26 | 显示全部楼层
It's ok now, i use 2 separate lisps, and the result you can see in the  attached drawing. Sorry, is not english in the drawing (IS ABOUT GROUND PROFILE, WITH HORIZONTALDISTANCES , ELEVATION VALUE - SORRY, NOT IN ENGLISH)  And maybe  somebody have a routine to do something similar like in the drawing...  but anyhow it's ok now, thanks for help guys! I can show those 2 lisps that i use, but they are so bad...i'm afraid to do this
Drawing1.dwg
回复

使用道具 举报

5

主题

26

帖子

21

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 18:29:48 | 显示全部楼层
Drawing2.dwgWhat about a  (let's say) "horizontal" polyline, intersected by many vertical lines, through vertices and through other points(not vertices)? I mean, to count first line -L1, second line - L2...and so on, from left to right, for example... HOW? see the drawing...
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:34:45 | 显示全部楼层
If you use the "VL-curve-getclosetpointto" command it will reduce your code immensely you just use the pline vertice and the VL it works out the perp point for you so simple, just pick pline, pick horizontal line and say datum level and vert scale = numbers just loop through the pline vertices does not matter how many.
 
Stole this from elsewhere whilst looking around today
 
  1. (setq pd1 (getpoint "\nSelect first point "))       (setq pd (car (entsel "\nSelect line to extend to:  ")))                        (setq pt (vlax-curve-getClosestPointTo pd pd1 T))
回复

使用道具 举报

3

主题

6

帖子

3

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 18:36:16 | 显示全部楼层
how to load this code in to autocad
  1. (defun C:TEST ( / i ss) (if   (setq i 0 ss (ssget ":E:S" '((0 . "LWPOLYLINE"))))   (progn    (foreach n     (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (ssname ss 0))))     (set (read (strcat "P" (itoa (setq i (1+ i))))) n)      (princ (strcat "\nP" (itoa i) " : " (vl-princ-to-string n)))               )   (princ  (strcat "\nTotal number of vertex is n = " (itoa i) "\n"))          ;Do sth other   (repeat i   (set (read (strcat "P" (itoa i))) nil )(setq i (1- i))   )   )   )(princ) )
 
@ketxu
回复

使用道具 举报

2

主题

17

帖子

15

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 18:40:24 | 显示全部楼层
Save this file as .lsp and give "ap" command in autocad and load it
回复

使用道具 举报

3

主题

6

帖子

3

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 18:43:44 | 显示全部楼层
what is the command in to command line LWPOLYLINE or other
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 04:37 , Processed in 0.719662 second(s), 81 queries .

© 2020-2025 乐筑天下

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