gilsoto13 发表于 2022-7-6 11:30:48

How to select lines, Polys and

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...

alanjt 发表于 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.

gilsoto13 发表于 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 lengthscadtutor 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...

rkmcswain 发表于 2022-7-6 11:47:04

Here is a start....
 

(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)))

alanjt 发表于 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.

Lee Mac 发表于 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

gilsoto13 发表于 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
 

(defun c:reset1 ()      (command "script" "reset.scr")   (princ))(c:reset1)
 
Then Inside the second one "Reset.scr" you'll find this
 

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...
 

;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
 

(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

alanjt 发表于 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.

alanjt 发表于 2022-7-6 12:06:09

I mean nothing against you, but I would advise against comments of the sort.

gilsoto13 发表于 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)
页: [1] 2
查看完整版本: How to select lines, Polys and