gilsoto13 Posted March 22, 2010 Posted March 22, 2010 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... Quote
alanjt Posted March 22, 2010 Posted March 22, 2010 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. Quote
gilsoto13 Posted March 23, 2010 Author Posted March 23, 2010 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... Quote
rkmcswain Posted March 23, 2010 Posted March 23, 2010 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)) ) Quote
alanjt Posted March 23, 2010 Posted March 23, 2010 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. Quote
Lee Mac Posted March 23, 2010 Posted March 23, 2010 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 Quote
gilsoto13 Posted March 23, 2010 Author Posted March 23, 2010 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 Quote
alanjt Posted March 23, 2010 Posted March 23, 2010 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. Quote
alanjt Posted March 23, 2010 Posted March 23, 2010 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.... ........... And if you can also do all my work and send me a cup of cofee and a donut... it wil be better... I mean nothing against you, but I would advise against comments of the sort. Quote
gilsoto13 Posted March 23, 2010 Author Posted March 23, 2010 I mean nothing against you, but I would advise against comments of the sort. 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) Quote
Pablo Ferral Posted March 23, 2010 Posted March 23, 2010 It's not as much fun as writing lisp, But how about making some cool blocks for the company you are receiving drawings from and showing the company how to use the Blocks effectivly? I admit It's doing work for free and they might not accept your help, but as they say 'You don't know what you don't know'. They just might not know how to organise their drawings. It maybe that, given a bit of guidence from you, you can pursuade them to clean up there act. Who knows, it might be worth a punt! (And if you could send me some torrtilla, I will send doughnuts!) Quote
Lee Mac Posted March 23, 2010 Posted March 23, 2010 .. 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?... No, not at all - I'm just trying to put the ideas into your head, give you pointers To better explain your quote, I said to: "Think about displaying the new SelectionSet, look into the sssetfirst function." In which I meant, think about how you would show the objects that are contained in the SelectionSet when you are finished. The sssetfirst function can highlight objects in a SelectionSet. I also said "make sure you allow for the case in which a SelectionSet is null." Trying to operate on a null SelectionSet will cause errors, so you should always allow for the time that the SelectionSet will not exist. Lee Quote
alanjt Posted March 23, 2010 Posted March 23, 2010 No, not at all - I'm just trying to put the ideas into your head, give you pointers To better explain your quote, I said to: "Think about displaying the new SelectionSet, look into the sssetfirst function." In which I meant, think about how you would show the objects that are contained in the SelectionSet when you are finished. The sssetfirst function can highlight objects in a SelectionSet. I also said "make sure you allow for the case in which a SelectionSet is null." Trying to operate on a null SelectionSet will cause errors, so you should always allow for the time that the SelectionSet will not exist. Lee We're only trying to impress ideas upon you. Quote
gilsoto13 Posted March 23, 2010 Author Posted March 23, 2010 It's not as much fun as writing lisp, But how about making some cool blocks for the company you are receiving drawings from and showing the company how to use the Blocks effectivly? I admit It's doing work for free and they might not accept your help, but as they say 'You don't know what you don't know'. They just might not know how to organise their drawings. It maybe that, given a bit of guidence from you, you can pursuade them to clean up there act. Who knows, it might be worth a punt! (And if you could send me some torrtilla, I will send doughnuts!) It wouldn't be difficult... I know a few small engineering and architecture companies where I have been involved in several small projects, and I work in a company with a very robust standard package including blocks, documents, formats...I have thought about making some routines or teach them how to work faster with some standards... and this company that made the project I am trying to fit to our standards might use maybe a 1/4 of our standards and their drawings have many different formats, but it's located too far away, in another state of my country... . This lisp will help me for just one of the tasks... and trying to help a company as a consultant would be nice... but it requires me to go personally and make an appointment with the company manager for each case... maybe after learning lisp I wil become a company standard consultant (maybe less than a decade). I also like to teach, in my city there are lots of schools (just before highschool) where I can teach autocad as a technical class, but the pay is just very low, it would be only for... and well.... the fact is that right now I just can teach my mates in the company on how to use new lisps for our standards... And yes, I made about 200 tortillas yesterday... enough for me and my girl for 3-4 weeks... I can´t send any that far .. And still all of those ideas are just unknown words for me at this point... But If could hold this thread for a few years they will help me to build this new routine, so you guys just leave it here... who knows... I might find some time in a couple weeks and challenge myself to build my very first complex lisp.. Quote
Lee Mac Posted March 23, 2010 Posted March 23, 2010 If the functions are unknown to you Gilsoto, I would recommend that you read about them in the Visual LISP Editor Help files - you can learn a great deal from those documents. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.