AutoCAD Visual LISP / AutoLISP :: Adding To A Selection Set
Jan 27, 2003
R14 Autolisp:
I can create an empty selection set (setq EMss (ssadd)). As I loop through a list I can use the counter to create selection sets on the fly by using:
(set (read (strcat "ss" (itoa cnt))) EMss) and even keep a list of the ssets created with (setq sslst (cons (strcat "ss" (itoa cnt)) sslst)). But when I try to add an ename to the ss with (ssadd ename (read (strcat "ss" (itoa cnt))), I get a error: bad argument type (SSADD NEXTE (READ (STRCAT "ss" (ITOA CNT)))).
why I can create the sets but not add to them this way? I can add to them from the command line.
View 9 Replies
ADVERTISEMENT
Nov 15, 2013
I've created a lisp that draws the boltholes of a pipe flanges, using the correct number of holes, at the correct diameter at the correct bolt-hole diameter and then rotates. Everything works seamlessly, when i do just one flange. But I've discovered that fewuently there will be mulitple times when a user will have to perform the command.
So the idea I had was to do the following:
Select all circles with (setq CirclesFirst (ssget "X" (list (cons 0 "CIRCLE"))))
Go through the code to create the new circles.
Select all circles with (setq Circles (ssget "X" (list (cons 0 "CIRCLE"))))
Remove selection set "CirclesFirst" from "Circles".
But what for some reason (command "_.select" Circles "R" CirclesFirst "") does not work.
View 9 Replies
View Related
Apr 10, 2012
I'm trying to fix an issue with entlast where if the user hits escape during the process, the wrong entity gets erased, etc. Here's the problem code...
From a function that would have just inserted a dynamic block at 0,0 then modified it - here's where we pick up..
(SETQ ss (SSGET "L"))
(vl-cmdf "_.copybase" (getvar "LASTPOINT") ss "")
(prompt "
Pick insertion point... then rotation angle ")
(vl-cmdf "erase" ss "")
(vl-cmdf "_.pasteblock" PAUSE)
(setvar "polarmode" 1)(setvar "autosnap" 63)(setvar "osmode" osm1)
(vl-cmdf "_.ROTATE" (entlast) "" (cdr (assoc 10 (entget (entlast)))) PAUSE)
(vl-cmdf "_.EXPLODE" (entlast) ""
)
I would like to do..(setq ss (vl-cmdf "_.pasteblock" PAUSE)), but of course, that doesn't work - it returns "T".
My goal is to get rid of the entlast usage from the last two lines - unexpected cancels rotate and explode the wrong entities.
If I try (setq ss (entlast)) or (ssget "L") after the pastblock, I might still get the wrong selection set if the user hits cancel before picking.
View 4 Replies
View Related
Mar 2, 2012
I am trying to select all blocks of a certian name. I am using the following:
(setq ss1bk (ssget "_X" (list (cons 2 blkname))))
My issue is that this will not select any dynamic or attribute blocks that are not at the default insert state.
how to select all of a block by name including reguardless of current state?
View 9 Replies
View Related
Feb 28, 2013
Is it possible to get a selection set of what was just pasted into drawing?
View 8 Replies
View Related
Apr 23, 2013
I'm putting together some quick function that I can send 2 arguments and get from it the total area of a given hatch on the given layer. I think everything is in order but I'm having trouble with the selection set filter:
(DEFUN GET-HATCH-AREA (HATCH LAYR / area sset) (COND((AND(ssget "X" '((0 . "HATCH") (2 . HATCH) (8 . LAYR))) (SETQ area 0) (VLAX-FOR H (SETQ sset (VLA-GET-ACTIVESELECTIONSET (VLA-GET-ACTIVEDOCUMENT (VLAX-GET-ACAD-OBJECT)))) (SETQ area (+ (VLA-GET-AREA h) area))) (ALERT(STRCAT "Total area = " (IF (OR (= (GETVAR "lunits") 3) (= (GETVAR "lunits") 4) ) (STRCAT (RTOS area 2) " sq. in. (" (RTOS (/ area 144) 2) " sq. ft.)") (RTOS area) ) ) ) (VLA-DELETE sset) ) ) ))
View 9 Replies
View Related
Oct 16, 2013
with the mouse I can select objects on the screen and then start a command that uses these objects.
How can I perform this in lisp?
I can create my selection set, that's no problem, but how can I 'make it active' for an external function?
(ssget "_C" p0 p1 '((0 . "TEXT")))
???
(c:txtexp)
View 2 Replies
View Related
Oct 3, 2011
I wrote a lisp program which creates a selection set using ssget. Then I use the bounding box commands to get the lowest point of that selection set. Now I want to move that selection set as a whole using the vla-move command. Can we vla-move a selection set?
View 8 Replies
View Related
Feb 13, 2012
I need to copy a selection set from p1 to p2.to do this I wrote the following
(defun c:test () (setq sel (ssget)) (setq p1 (getpoint "
Origine: ")) (setq p2 (gettpoint p1 "
Destination: ")) (command "_.copy" sel "" p1 p2))
works, but this way I can not see objects dynamically attached to the mouse cursor.
To visualize this effect, I noticed that I can use:
(command "_.copy" sel "" pause pause)
but in this way I can not save the variables p1 and p2: I need for these, subsequently in the rest of thefunctions lisp.
View 4 Replies
View Related
May 29, 2012
I want to find a Lisp routine for building rooms (bedroom, bath, kitchen etc). example: I want to build a bedroom and every bedroom has the following blocks: smoke detector, door, window, bed, night stand, closet. Is there a way to run a lisp routine that would just ask me for basepoints and rotation angles of all those blocks? Basically it would automate building a bedroom by inserting all the blocks for me and just prompting me for basepoints + rotation angles.
Would a macro be better suited for this? I want to do one for every room - kitchen, bath, bedroom, living, dinning etc. I already have a nice collection of blocks.
View 5 Replies
View Related
Oct 26, 2012
Any routine where I could keep picking on my exit arrow blocks (showing how many persons exiting from each space) one-by-one and the program would add up the numbers. For example I pick on blocks with numbers of 2, 4 & 3 and I would get 9.
View 3 Replies
View Related
Apr 15, 2012
To get the 'File Selection dialog box' in AutoCAD via LISP, which command should I use other than 'GETFILED' ?
I have a program which using GETFILED to select the drawing file , but I think this dialog box size is too small to browse folder/file , as you cant see the favorites list and you cant resize the dialog box.
View 3 Replies
View Related
Aug 10, 2012
I'm working on a lisp that goes through a whole list of files and does different things to those files. I've been racking my brain for a way to select just a folder via a dialogue box, but haven't found a way. I'm sure it can be done with dcl, but I don't know where to start.
This would not be the standard "file" selection box, but would only list the folders and let me select one even if there are others "under" them. This is what I'd like it to look like.
I'm not sure if there is a standard AutoCAD box that I could call for this or not
View 5 Replies
View Related
Nov 1, 2011
I have a lisp routine that creates a "frame wall" and I want to be able to automatically dimension said wall within the same routine. I have created two sets of points, each set being on its own new layer. I have made selection sets of each set of points, and want to cycle through each set dimensioning as required. This what I have so far for this part of the routine:
(command "DIMSCALE" 24)
(setq sel1 (ssget "x" '("VPOINTS")))
(setq TC (polar (ssname sel1 0) (dtr 180.0) 9))
(command "DIMLINEAR" (ssname sel1 0) (ssname sel1 1)) "V" (polar TC (dtr 180.0) 9) "")
[code]...
When I run the program I get the error: bad point argument. So what I think is happening is that the ssname command is not returning the actual value but just the name? I am new to AutoLisp and even newer to selection sets so be easy... Along with this, I am also curious as to how a selection set is ordered when it is chosen ie how does it determine what would be in (ssname sel1 0). Also, how would one go about deleting the points in these selection sets after the dimensioning has been completed.
View 5 Replies
View Related
Jan 12, 2012
How to Set a previous selection to nil from say a move command?
View 5 Replies
View Related
Nov 1, 2011
Looking to make a selection set of points that are on a specific layer, and then create a dimension between, in this case, two points. I feel like it should be very simple, but I can't get it to work for the life of me. Here is the test code I've been playing around with:
(defun c:test (/ sel1 TC)
(setq sel1 (ssget "X" '((8 . "VPOINTS"))))
(setq TC (polar (entget (assoc 10 (ssname sel1 0))) (dtr 180.0) 9))
(command "DIMLINEAR" (entget (assoc 10 (ssname sel1 0))) (entget (assoc 10 (ssname sel1 1))) "V" (polar TC (dtr 180.0) 9) "")
[code].......
View 1 Replies
View Related
Jan 10, 2002
I wish to collect a selection set of blocks in paperspace of a certain name. For model space I would use the following line:
(setq x1 (ssget "_x" '((2 . "*etc*") (410 . "model"))))
when it comes to setting paperspace as the 410 ssget list value as the name can be modified and I need it to work in all drawings. I tried
setting a variable to the paperspace layout name and using a print function at the (410 . "model") point but without sucess.
View 9 Replies
View Related
Feb 8, 2012
How to get the individual components of a block that has just been exploded within a lisp routine into a selection set. I want to alter the layer of each element to the insert layer of the block. I may also make one or two other changes according to what I find in the block.
View 8 Replies
View Related
Oct 3, 2011
I wrote a lisp program which creates a selection set using ssget. Then I use the bounding box commands to get the lowest point of that selection set. Now I want to move that selection set as a whole using the vla-move command. I am having trouble doing this. Is this possible? Can we vla-move a selection set? Is there a workaround?
View 2 Replies
View Related
Oct 16, 2012
I downloaded a lisp routine that will align block attributes. The problem is I can only select the attributes one at a time. I'd like to be able select multiple attributes using the selection window or a crossing window, but I haven't had much luck. If you use the AEATTSHOW command, it give you a prompt to "select using window" by pressing W. I'd like to have the same functionality for my Align attributes routine.
Below is the portion of code I currently have to select attributes one at a time:
;* Select all attributes to align with the parent selected above and add the attribute entname and the block
;* entname to a list in format ( (AttrEntName BlkEntName) (AttrEntName BlkEntName) (AttrEntName BlkEntName) )
;*
while (/= TempAttr nil)
(setq
TempAttr (nentsel "
Select Attributes to align: ")
[Code] .........
View 5 Replies
View Related
Sep 5, 2012
I need the same funcionality as in code below, but without using "command".
The main idea is alowed user to modify Existing Selection Set.
(defun gt:ss->lst (a:ss / i lst ) ;_ / (setq i 0) (if a:ss (progn (repeat (sslength a:ss) (setq lst (cons (ssname a:ss i) lst) i (1+ i) ) ;_ setq ) ;_ repeat (reverse lst) ) ;_ progn ) ;_ if) ;_ defun gt:ss->lst(defun gt:ss_modify (a:en-lst / ) ;_ / ;;create Selection set (setq ss2 (ssadd)) (foreach f:en a:en-lst (ssadd f:en ss2) ) ;_ foreach ;;Run command and fill with initial content (command "_select" ss2) ;;Alow the user to modify the contents (while (/= (getvar "cmdnames") "") (command pause) ) ;_ while ;;get back the list of enames from modified selection set (setq ss3 (ssget "_P")) (setq ss3-lst (gt:ss->lst ss3))) ;_ defun gt:ss_modify(defun tst:gt:ss_modify ( / ) ;_ / (gt:ss_modify (gt:ss->lst (ssget)))) ;_ defum tst:gt:ss_modify
View 8 Replies
View Related
Feb 7, 2013
Tried retrieving an ActiveX selection set in AutoCAD 2013 (AutoCAD Architecture 64bit on Windows 7 is what I am using)?
Using a piece of LISP I got from the ADN developer site, it no longer works and gives this error....
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.
(defun c:erset (/ acApp acDoc selSets ss1)
(vl-load-com)
(setq acApp (vlax-get-acad-object))
(setq acDoc (vla-get-activeDocument acApp))
(setq selSets (vla-get-SelectionSets acDoc))
[code].....
Unfortunately my lisp is very basic.
(defun c:getSset()
(vl-load-com)
(setq ss-vba (vla-item
(vla-get-selectionsets
(vla-get-activedocument
[code]......
What about creating an AutoLisp selection set from .NET - is it possible, if so I would prefer to do that instead?
The goal is to create some objects in .NET (using activeX or managed code) and then have some way to access these objects via the command line I'm assuming they only way is using an AutoLISP selection set.
View 5 Replies
View Related
Jan 29, 2013
I was trying to add a point as extended data to a block.
Therefor i used this data but i get an error every time:
(setq lastent (entget (CAR (entsel))))(regapp "list")(setq exdata '((-3("list" (1011 . 3277.82) (1021 . 5782.5) (1031 . 369.5) ) ) ))(setq newent (append lastent exdata))(entmod newent)
View 3 Replies
View Related
Jul 10, 2013
I've inherited management of CAD standards. A third party developed the tool palette - mostly blocks, etc. but there are also icons to add whole series of layers to drawings. Click 'Architectural Layers' you add the architectural layers. Click 'Plumbing Layers' you add the plumbing layers. Since the original implementation, things have been changed.
How do I update these tools?
View 5 Replies
View Related
Jan 24, 2013
I need a LISP program to add a text given by user to all selected text.
in other words:
1- user selects some texts.
2- user give a text to program.
3- Program added this text to all selected text.
selected text: text1, text2, text3,text4,....,textn
given text by user: _xyz
Result:
text1_xyz, text2_xyz, text3_xyz,text4_xyz,....,textn_xyz
View 6 Replies
View Related
Dec 27, 2013
I've created a couple of programs:
One - that will start a new project file, add our standard drawing sheets
two - Insert a bunch of wblocked components based on user input
programs 3 - 6 all do the same as program 2, just different components for different sheets.
I can run all these programs and they work (i need to do a lot of "clean-up" but they work)...
I have them set-up to open the next drawing.But i have to type in the next command, and continue until all my programs and done running.
My questions is how can I accomplish this without having to continually type in commands?I can't run these as a script, but is there another method?
View 8 Replies
View Related
Nov 14, 2013
I have been asked to make the title text larger (drawing are being issued at 1/2 scale, A1 to A3) on a large set of drawings. My solution was to copy the title attribute block to a temporary location, resize the attributes and redefine the block by running a script (scriptpro). Some drawings needed the title line split to next line so I had to move the sheet counter (1 of xx, 2 of xx etc.) which was linked to drawing file name for number with a field/formula.
The diesel expression shown below extracts that number. My problem is I cant figure out how to I can edit this expression to allow for a set not starting at 1. I had used a formula to subtract the difference,but how do you express this to run in a script?
This is my script......
attreq
0
-insert
ftc-gwp-a1-nosheet-stb=ftc-gwp-a1-nosheet-stb
0,0
1
1
0
[code]........
View 7 Replies
View Related
Apr 5, 2012
I have draws with a a lot of layouts.In each layout, there is a block (CARTOUCHE) with a an attribute (PAGENUMBER)
I am looking for a way to select the block in my first layout, indicates a number for my attribute (PAGENUMBER). The lisp will automatically increase the attributes of the next others layout. How can I start this lisp.
View 9 Replies
View Related
Feb 27, 2012
I'm looking for something that, after selecting several plines (overlaped or not), I can insert/remove vertexes.
View 9 Replies
View Related
Oct 4, 2012
I have attached 2 lisp files. datblkx5 makes a block of selection, inserts the block with a 5x distortion, explodes it, and corrects the text for width factor and text height. This one works fine.
I wanted to add the feature of scaling my selection with a user input value. This is the lisp datblkxxx. This one doesn't work. (that is it doesn't correct the text for width factor). I can't figure it out.
View 3 Replies
View Related
May 7, 2012
I use menu's based upon the following snippet:
(if (or (equal choose "1"))(MYFUNCTIONSDEFINITION))
works a treat, its easy for me to understand even if maybe not totally orthadox in method.
So I can populate my code to have multiple selections such as follows.
(if (or (equal choose "1"))(MYfunctionDEFINITION1))(if (or (equal choose "2"))(MYfunctionDEFINITION2))(if (or (equal choose "3"))(MYfunctionDEFINITION3))
and so on, but the example above caters for situations the users enter the values of 1, 2, or 3. If the user enters anything else I get a nil response from AutoCAD. So I devised the following
(if nil (alert "Wrong selection"))
but no response from AutoCAD qua an alert
also tried to be more in uniform with the rest of the lisp and wrote
(if nil (MYalertRESPONSE))(defun MYalertRESPONSE ()(alert "Wrong selection"))
also fails to yield the desired response.
View 5 Replies
View Related