乐筑天下

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

[编程交流] How to select lines, Polys and

[复制链接]

29

主题

196

帖子

168

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
145
发表于 2022-7-6 11:30:48 | 显示全部楼层 |阅读模式
Hi, Again...
 
It seems I am getting very lazy with all these lisps... the best thing is that I almost have a lisp answer for any task when someone asks me....
 
Well, I know this one must be easy.. but I cannot do it with Qselect command...
 
I got many drawings from another company... but they don't use blocks for many repetitive symbols... this symbols are made with plines or lwpolylines... so I want to select them all at once and get rid of them.. They are ways to do it by using layers... but sometimes it gets difficult when there's a bunch of objects in one layer, So one needs to be selecting each object one by one.
 
Anyone who has seen a lisp to select these three types of objects by their length.. I can do it with qselect, but in the case the length is not exact, it has infinite decimals... I cannot use the less than or more than options... because there are more objects I don´t want to select...
 
So, What I am trying to find is a lisp to select all of these 3 types of objects with their length between 2 specified (by typing them) numbers. It will be like using qselected with an extra option "between lentghs?", and if any (usually Lee Mac) is willing to do it... it would be great to selected also arcs, and even better select circle perimeters between lengths also...
 
And if you can also do all my work and send me a cup of cofee and a donut... it wil be better...
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:35:29 | 显示全部楼层
Come on man, with as much code as you've modified/written, you should be able to put this one together.:wink:
 
Just iterate through a selection set, if the object matches certain criteria, ssadd it to a new selection set and when iteration is over, select new ss with sssetfirst.
回复

使用道具 举报

29

主题

196

帖子

168

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
145
发表于 2022-7-6 11:42:09 | 显示全部楼层
weeell, If a could find a similar lisp... i would try to find a way to modify it... but start it is just impossible to me... I made a couple searches on the web, with these key words "Select Polylines lengths lisp"  "Select Polylines lengths  cadtutor lsp" but didn´t find anyhting similar..  I would need to read pline- related lisp in the big lisp pages /directories...
 
I'll return here later...
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

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

铜币
362
发表于 2022-7-6 11:47:04 | 显示全部楼层
Here is a start....
 
  1. (vl-load-com)(setq sset (ssget "_X" '((0 . "LINE,POLYLINE,LWPOLYLINE"))) i 0)(repeat (sslength sset) (setq ent (ssname sset i)) (setq obj (vlax-ename->vla-object ent)) (setq len (vla-get-Length obj)) (princ (strcat "\n" (rtos len 2 2))) (setq i (1+ i)))
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:48:52 | 显示全部楼层
Arc: vla-get-arclength
Circle: vla-get-circumference
Line/*Polyline: vla-get-length
 
Prompt for 2 variables (Greater and Less than) (setq Great (getreal...))
 
Create new selection set: (setq Add (ssadd))
 
Example:
(and (> Less (vla-get-length obj) Great)
       (setq Add (ssadd (vlax-vla-object->ename obj) Add)))
 
When it's all done:  (sssetfirst nil Add)
 
It's really not difficult to put together. I was able to write something in about 5 minutes. Give it a try.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:55:19 | 显示全部楼层
I'm going to stand by these guys too - I've seen some of your code Gilsoto, it isn't half bad.
 
Think about how you would iterate through a SelectionSet, RKMcSwain has posted one example, but there are many many other ways.
 
Think what prompts you want (as Alan has said), and, you could either use ssdel to remove the item from the main if it doesn't meet criteria, or, as suggested, add it to another SelectionSet.
 
Think about displaying the new SelectionSet, look into the sssetfirst function. Oh, and in all this, make sure you allow for the case in which a SelectionSet is null.
 
Lee
回复

使用道具 举报

29

主题

196

帖子

168

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
145
发表于 2022-7-6 11:59:52 | 显示全部楼层
Well.... jajjajaja.. I think i'll just go to my kitchen and make some tortillas... that's easier for me... then I'll try it... I must say... I've written small lisps containing very basic points, autocad commands, and I am just starting to use sub-routines (and just grab existing to add them to an existing routine), I just found out how to start with basic selections, and I've found some ways to modify existing routines to do things in a different way or to add or modify factors... but all of that stuff Lee said... I felt like he's trying to impress me a bit.. (oh, and be carefull with the ssetfirst first) What?.. I made some mistakes when I was younger... 8-10 years from now... cause I downloaded a 5000 lisp file and read and checked those I was interested in.. at that time... then just took about a hundred from them and renamed them, In some cases I added my name at the top, (sometimes there was no copyright nor Name at the top) so if yuo find those lisp files in my grab bag (available in my blogspot) and its a very complex lisp with my name on it... just ignore my name...
 
To give you an idea... the only thing I may feel proud pf my own lisp knowledge.. it's to make work a script at startup... that way I may load a lisp (using the batch function) and apply another lisp to all the dwg files in a directory...
 
I did it by testing one day I was experimenting and I achieved it with 3 files in my support directory, first one called "Reset1.lsp" with this code
 
  1. (defun c:reset1 ()        (command "script" "reset.scr")     (princ))(c:reset1)
 
Then Inside the second one "Reset.scr" you'll find this
 
  1. RESET
 
And finally that "reset" inside the script calls automatically somehow a lisp routine called "Reset" (Which is not Mine), but it's a lisp routine, So, all the variables in this lisp are automatically loaded when I open any drawing... and the message at the end lets me know everything was loaded succesfully...
 
  1. ;RESET.LSP:   QCMD.LSP   Quick Commands   (C)1998, Dean Saadallah;QCMD-RESET SYSTEM VARIABLES: A simple SETVAR option.;;This routine has been successfully tested in Autocad rel.12 c2, on a;486-66 and better, using mouse and tablet puck and pen.;;this routine was written by:;DEAN SAADALLAH;3001 EAST AVENUE K, #227F;GRAND PRAIRIE, TEXAS 75050;(214) 606-1816;;;;;QCMD-RESET SYSTEM VARIABLES(defun C:RESET ()  (setvar "CMDECHO" 0)  (setvar "MENUECHO" 0)  (setvar "HIGHLIGHT" 1)  (setvar "PICKBOX" 6)  (setvar "APERTURE" 6)  (setvar "ATTDIA" 0)  (setvar "ATTMODE" 1)  (setvar "BLIPMODE" 0)  (setvar "CMDDIA" 1)  (setvar "DRAGMODE" 2)  (setvar "EXPERT" 0)  (setvar "FILEDIA" 1)  (setvar "FILLMODE" 1)  (setvar "PICKADD" 1)  (setvar "PICKAUTO" 1)  (setvar "PICKDRAG" 0)  (setvar "PICKFIRST" 1)  (setvar "PLINEGEN" 0)  (setvar "PLINEWID" 0)  (setvar "REGENMODE" 1)  (setvar "SAVETIME" 5)  (setvar "ZOOMFACTOR" 100)  (setvar "SDI" 0)  (setvar "ISAVEBAK" 1)  (setvar "TRACEWID" 4)  (setvar "TEXTFILL" 1)  (setvar "FILLETRAD" 0)  (setvar "LISPINIT" 0)  (setvar "SELECTIONPREVIEW" 0)  (setvar "VTENABLE" 0)  (setvar "DYNMODE" 0)  (setvar "PROXYNOTICE" 0)  (setvar "UPDATETHUMBNAIL" 1)  (command "REGENAUTO" "OFF")  (command "linetype" "s" "bylayer" "")  (command "COLOR" "BYLAYER")  (prompt "\nTODO LISTO, MAESTRO...")   (princ))
 
And I realized they all needed to be loaded automatically (by adding them to the acad2009doc.lsp) at the end of the list... this way
 
  1. (vmon)(load "reset.lsp")(load "reset1.lsp");;;
 
So, this, and the std.lsp are the only things are proud that are mine completely... the rest in my lisp bag is someone else's code..
 

It maight be sad.. by at this point, I am only a good searcher... (and "rememberer")
 
As you can see, it does not contain any complex code... nothing with selections... ssadd, ssdel... well... I am thinking that I may read and learn... but for the moment... I wanted to finish my "Greatest ever autocad block collection" and also my own house remodelling project and construction... and these are the thing that get my entire time at this time... but I gotta say I almost get everything solved by searching or by asking for help (like this case)...  So... It's not the big deal when I don´t get the routine for "smallies" like this one... they are "wishes".... they are also helping me to learn some... so...
STD.LSP
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 12:01:01 | 显示全部楼层
But you can learn, and there's no time like the present.
If you can figure out how to modify code, you can figure out how to write your own.
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 12:06:09 | 显示全部楼层
I mean nothing against you, but I would advise against comments of the sort.
回复

使用道具 举报

29

主题

196

帖子

168

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
145
发表于 2022-7-6 12:10:37 | 显示全部楼层
ok, it's just my normal (weird for many) sense of humor... it's difficult to communicate it by writting it... but I am just making fun of myself about requesting things with extra detail, as for adding circles and arcs to a simple small routine, in my country we would call it "limosnero y con garrote"... that means something like "Homeless asking for food, but it needs to be in a silver platter only" ( as for someone who asks much more than he really needs)
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 02:16 , Processed in 0.330324 second(s), 72 queries .

© 2020-2025 乐筑天下

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