AutoCAD Visual LISP / AutoLISP :: Sorting A List
Aug 17, 2012
I have a list that contains data like this,
"Tree-01-08-AA5"
"Tree-04-12-QV"
"Tree-10-30-QS"
How would I go about sorting this list by AA5, QV, QS? I know how to use vl-sort and reverse, but I do not understand how I would go about this.
View 9 Replies
ADVERTISEMENT
Jun 12, 2013
I found a lisp for counting of selected block in a table drawing, but I can not remove the bottom line of this lisp that displays "total" blocks. How to remove this line from "total" that is created in the last row of the table that lisp.
lisp : ========================================
(defun c:TABL (/ blk_id blk_len blk_name blks ent h header_lsp height i j TOTAL
len0 lst_blk msp pt row ss str tblobj width width1 width2 x y
)
[Code]....
View 4 Replies
View Related
Aug 31, 2012
acad_strlsort will sorts strings, but what if my list looks like
("1" "2" "3" "10" "11" "12" "20")
i am sure i have seen it done ina simple way using vl-sort or vl-sort-i
but am not able to find...
View 5 Replies
View Related
Apr 23, 2013
I required a lisp for sorting Multiline text in alphabetic order. (Ascending and Descending)
For example in my drawing it contains lot of Mtexts having multi rows. I need to sort texts inside Mtext. Like PDC-012, DAG-012, AAG-096. I need that Mtext should be AAG-096,DAG-012,PDC-012.
View 9 Replies
View Related
Jul 15, 2013
I have a list -
(setq List1 (list "Line A" "Line B" "Line C"))
I would like to add each item in an existing list to a new list -
(setq ListNew (list "This is some text" "This is more text"
the following is the part I can't figure out - it just adds the list to the list, not the individual items
(mapcar '(lambda (x) x) List1)))
I am looking for ListNew to be - (a list with 5 strings)
"This is some text"
"This is more text"
"Line A"
"Line B"
"Line C"
View 9 Replies
View Related
Nov 14, 2013
I have a list ("temp.dwg" "temp2.dwg") and would like to add the string "insert text here" into each item in the list resulting in ("insert text heretemp.dwg" "insert textheretemp2.dwg"). how would i go about doing that using LISP?
View 2 Replies
View Related
Aug 26, 2012
I have a list like ("a.dwg" "b.dwg" "c.dwg") and an filename "b.dwg"
I want to know if the file name is a part of the list. which function must be used for this?
View 5 Replies
View Related
Oct 13, 2013
I need to modify the code below.
When I run the command and write the scale, I need to change the name of the scale and the ratio automatically. The ratio should always be in the format "1: #", also the name of the scale. Maybe assigning more variables with "setq", I do not know.
(defun c:test ()(setvar "cmdecho" 0)(setq name (getint "
Type the scale you need:"))(setq ratio (strcat "1:" "0.1"))(command "-SCALELISTEDIT" "Add" name ratio "Exit")(setvar "cmdecho" 1)(princ))
View 6 Replies
View Related
Jul 11, 2013
Here's one that I could use on that i can't figure out:
I have a list of a bunch of descriptions that looks like this:
("00.02.00" "CTD01 Mainframe PT1 (top)" "GD01")
What I am doing is grabbing the middle item and i need to break this up into 2 lines. So, my code below grabs the first 3 "words" in the second item in the list and puts them in a list, but I need to convert this back to a string.
(setq desc6a (list (car (read (strcat "(" (cadr input6) ")" )))(cadr (read (strcat "(" (cadr input6) ")" ))) (caddr (read (strcat "(" (cadr input6) ")" )))))
I tried a bunch of ways but can't get it
View 8 Replies
View Related
Apr 25, 2013
I've been experimenting with lists and I'm curious about the fastest / easiest way to get the next element from a list:
Currently my best shot is to wrap (member 2 '(1 2 3)) with: (car(cdr (member 2 '(1 2 3))))
View 9 Replies
View Related
Jan 6, 2012
How to export to a txt file a list containg all the objects on the current layer and their properties?
To be precise, I would like to export the following items from a selection of plines:
- ObjectID;
- Start Point;
- End Point;
- Vertex Points;
- Width.
View 3 Replies
View Related
Jul 17, 2012
Here is the code snippet from my program, I am trying to build a associative list from two regular lists in the while loop. Does ""append " or "cons" only work for simple lists? Given attributeNameList attributeValTypeList which are always of the same length
(setq listCntr 0)
(while (<= listCntr (length attributeNameList))
(setq attrTagTypeAssnList (append attrTagTypeAssnList (list ((nth listCntr attributeNameList) (nth listCntr attributeValTypeList))) ))
(setq listCntr (1+ listCntr)
)
How can I dynamically build the association list.
View 2 Replies
View Related
Sep 17, 2013
I've created a list and want to subtract all the values within it from another variable, and assign it to a new variable. How do I do it?
Basically, I ask for ground level (assigned to variable G1), and then any number of depths beneath that (assign to list LVLLIST), and I want to return the value of the bottom point. So it's all the values in LVLLIST added together and subtracted from G1. And assign it to a new variable BASE.
For example,
G1 = 650.00
LVLLIST = (1.23 23.26 0.13 50.23)
(setq BASE (- G1 LVLLLIST))
View 2 Replies
View Related
Oct 7, 2011
In the example given I have two instances to show how unique the information can be.
I would like the left column of words to be some type of drop down or list so that the user does not have to type these for each line. I don't care if it's attribute, text, mtext, just whatever gets it done.
View 6 Replies
View Related
Jun 11, 2013
I want to list all of loaded lisp programs in AutoCAD (both .lsp and .fas) It's easy for .ARX files: (vlax-safearray->list (vlax-variant-value (vlax-invoke-method (vlax-get-acad-object) 'listarx)))
View 9 Replies
View Related
Dec 5, 2012
I have the following string of code, that I'll write in everyone's start-up suite. I'm able to retrieve a list of files I want to modify, for whatever reason. (One example, when plotting drawings with layouts, sometimes the shadeplot setting is wireframe, and not classic hidden, though it's been set up in our templates).
The huge question is, can I get a list of drawings to a variable in one drawing, and have access to that variable list, in the next drawing I open? I'll iron out the bugs on read-only statuses, or manipulating drawing states later.
(defun GetDrawings ()
(setq currentpath (getvar "dwgprefix"))
(command "pspace")
(setq DrawingList (dos_getfilem "Select a file" currentpath "Drawing files (*.dwg)|*.dwg|All files (*.*)|*.*||"))
(setq ListOfDrawings (cdr DrawingList))
(setq DrawingPath (nth 0 DrawingList))
[code]...
View 1 Replies
View Related
Dec 11, 2013
I want to make a list of layers due to their index (order) in the "layers combo box" in the AutoCAD. I prepared this:
(defun c:ListLayers ( / a b)(setq a(list(cdr(assoc 2(tblnext "layer" T)))))(while(setq b(tblnext "layer")) (setq a(append a(list(cdr(assoc 2 b))))));while);end
But, It's not match with the order of layers.
View 9 Replies
View Related
Feb 3, 2012
I'm looking for a lisp routine that will globally list all the values from a specific attribute tag within a specific block. The attribute tag is "COMMENT" and the block name is "FSD".
View 9 Replies
View Related
Aug 15, 2011
How can I determine what was selected in the pop-up box and then using that for 1 of 2 things, either 1) Turn off the Edit Box for Hole Spacing if the selected option is 1(which would be value = "0" of the popup list) or 2) Making the portion where it confirms that the Hole Spacing Edit Box is filled out so that if the Pop-up List displays 1, it doesn't check the Hole Spacing Box. Below is the DCL and LISP that I'm currently using.
Here is my current DCL:
questions :dialog {label = "Information for Program";: row {: column {: boxed_radio_row {key = "Galv";label = "Galv Slot Required?";: radio_button {key = "Y"; label = "Yes"; value = "1";}: radio_button {key = "N"; label = "No";}}: boxed_radio_row {key = "Bevel";label = "Is Leg to Face
[Code].....
If needed: AutoCAD 2013 User using Visual LISP for editing LISP and DCL files Also I have AutoCAD 2011 currently still available for us, but we are using AutoCAD 2013 for 99.9% of AutoCAD use
View 6 Replies
View Related
Jun 14, 2013
How can I sort an association list?
for example:
(setq lst '((1 . "s") (12 . "t") (-7 . "u") (0 . "v")))
should be sorted as:
((-7 . "u") (0 . "v") (1 . "s") (12 . "t"))
{ sort on: (car(assoc index lst)) value}
View 9 Replies
View Related
Feb 12, 2011
Searched NG and did not find anything.
Given a list remove from list if both (nth 0) and (nth 5) are duplicates in list
(setq dolist '
(("CABLE, MIL-C-24640/18D " "IAF" "A/R" "FT" "6145-01-224-9183" "-" "3XSOW-7" "C-LC(1), (2)")
[Code]....
View 9 Replies
View Related
Oct 31, 2013
I am unsure why my Lisp does not work.
(DEFUN C:Clear_values (/ GLBLS) (SETQGLBLS '(*DATEDRAWN* *DRAFTNAME* *JOBNUMBER* *OWNERNAME**JOBCOE* *PERMITREVDATE* *PERMITCONTACT* *HOMEBUILDER**SUBDIVISION* *ADDRESS**CITY* *STATE* *ZIP* *LOT#**PARCEL#* *NSCOORD* *EWCOORD* *STANDARDDETAIL#**SUPERNAME* *SALESMAN**GATECODE* *HOMEPHONE* *WORKPHONE* *ALTPHONE1**ALTPHONE2* *EMAIL1* *EMAIL2* *ACCESS**EXCAVATIONTYP* *EXCATDEMO1**EXCATDEMO2* *SKIMRUN* *AWLRUN*
[code]....
I've tried several options such as (mapcar 'set GLBLS "%%") but nothing happens, and with the above code nothing happens; the code only returns nil.
View 8 Replies
View Related
Aug 16, 2013
I'm making a program that reads a property file that follows the format:
"key=value" for each line on the text file.
One specific line has the key "file" and the value is some file path that includes a space.file=C:/my folder/my file.txt
Now I can extract what the key and value is for any given line in the file.However, I want to put all of the data into an Associative List so that I will not need to keep opening the file each time I search for information. I've been using the cons function in order to create a dotted list, which is successful. However I have an issue when I add this dotted list to the end of my associative list.
Suppose I have a key and a value already stored inside variables. Below I have two lines of code, first the dotted list portion is printed, and works as expected. The second line adds that dotted list to the associative list:
(princ "Cons: ")(princ (cons key val)) (princ "") ;Prints (file . C:/my folder/my file.txt)(setq assocList (append assocList (cons key val))) ;Error message here.
The error that I receive says "; error: bad list: "C:/my folder/my file.txt"..Here is the change:
(setq assocList (append assocList (list (cons key val))))
Now, the dotted list is inserted properly and looks like this after printing the whole associative list: ((version . 1.0.1) (file . C:my foldermy file.txt))
View 1 Replies
View Related
Oct 17, 2011
Is it possible to obtain a list of coordinates for view ports (with dxf codes or otherwise) similar to obtaining a list of (assoc 10) for polylines?
I'm aware I can get the center, width and height from the dxf codes, but what about for clipped view ports with irregular shapes?
View 2 Replies
View Related
Dec 20, 2011
how to work with safearrays so that I can modify a dynamic block property reporting tool that I found here on the forums. I’d like to take the following code and filter out the extraneous properties so that the user doesn’t get information overload. Here’s the code that I'm starting with – works nicely:
(defun c:dbinfo (/ obj v vval sal salnth count)
(setq obj (vlax-ename->vla-object (car (entsel "
Select Dynamic Block: "))))
(setq v (vla-getdynamicblockproperties obj))
(setq vval (vlax-variant-value v))
[code]....
So, how do I filter the safearray list (down two levels to property names) so I can remove origins and other unimportant properties? Here’s the two property names I am trying to filter out:
(or (= (car y) "Origin") (= (substr (car y) 1 8) "Position"))
I’m beating my head against the wall trying to figure out how to take sal and redefine it like:
(/= (or (= (car y) "Origin") (= (substr (car y) 1 8) "Position")))
Of course, that doesn't work with a safearray.
View 6 Replies
View Related
Aug 16, 2013
I found a function on JTBWorld named listPageSetups, which appears to be meant for listing the pagesetups that exist in an "open" dwg file (as I can get it work for the current dwg). So,
(1) Can this function be used to list page setups in another, un-opened dwg, and, if so, how?
(2) If the answer to (1) is No, is there a LISP way to get a list of page setups from another, un-opened dwg?
View 9 Replies
View Related
Jul 30, 2012
where I can obtain a freeware lisp routine that lists the lengths of all the polylines on a specific layer or within a selection set? I want to avoid list if possible as there are rather a lot of polylines!
View 2 Replies
View Related
Aug 5, 2013
I am looking for code to remove duplicate points (xy coords) from a list with a fuzz factor parameter.
View 1 Replies
View Related
Nov 20, 2011
I have two lists with lists inside:
((A) (A) (A) (B) (B) (B) (B) (C) (C))
and
((A 1) (A 2) (A 3) (B 1) (B 2) (B 3) (B 4) (C 1) (C 2))
I just want to make a list with lists that is:
((A 1 2 3) (B 1 2 3 4) (C 1 2))
I am guessing map car and lambda should come into play but i can't figure it out.
View 3 Replies
View Related
Jul 17, 2012
I have a list of (0 .4 .8 0 10). I want to convert every element of the list to string.
View 4 Replies
View Related
Aug 19, 2012
I have list like (C:projectspr0310.dwg C:projectspr0315.dwg C:projectspr03drawings17.dwg)
Want these three files deleted from C:projectspr03.
View 9 Replies
View Related