Jump to content

Search the Community

Showing results for tags 'list'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions


  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...

  1. Can someone help me out with changing the attributes of a block using a list. The block is used in a leader. The block has 7 attributes, but my list doesn't always contain 7 variables. I have tried to implement Lee Mac's code dynamicblockfunctions, but I keep getting the error "too few arguments". I would like to import the leader when the calculation is done, and for the block to then automatically change the attributes to the variables in the list. Here's my current code: (defun c:testKRIS ( / *error* dch dcl des mv d1 d2 d3 d4 d5 d6) (defun *error* ( msg ) (if (and (= 'int (type dch)) (< 0 dch)) (unload_dialog dch) ) (if (= 'file (type des)) (close des) ) (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl) ) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) (princ (strcat "\nError: " msg)) ) (princ) ) (cond ( (not (setq dcl (vl-filename-mktemp nil nil ".dcl") des (open dcl "w") ) ) (princ "\nUnable to open DCL for writing.") ) ( (progn (foreach str '( "ed : edit_box" "{" " alignment = left;" " width = 20;" " edit_width = 10;" " fixed_width = true;" "}" "" "test : dialog" "{" " spacer;" " key = \"dcl\";" " : ed" " {" " key = \"mv\";" " label = \"MV:\";" " }" " :boxed_column { " " label = \"Diepte vd buizen\";" " :row {" " : ed" " {" " key = \"d1\";" " label = \"A:\";" " }" " : ed" " {" " key = \"d4\";" " label = \"X:\";" " }}" " :row {" " : ed" " {" " key = \"d2\";" " label = \"B:\";" " }" " : ed" " {" " key = \"d5\";" " label = \"Y:\";" " }}" " :row {" " : ed" " {" " key = \"d3\";" " label = \"C:\";" " }" " : ed" " {" " key = \"d6\";" " label = \"Z:\";" " }}" " }" " : boxed_row" " { " " label = \"BOK berekeningen\";" " :column {" " : ed { key = \"res\"; label = \"BOK:\"; is_enabled = false; }" " : ed { key = \"res2\"; label = \"BOK2:\"; is_enabled = false; }" " : ed { key = \"res3\"; label = \"BOK3:\"; is_enabled = false; }" " }" " :column{" " : ed { key = \"res4\"; label = \"BOK4:\"; is_enabled = false; }" " : ed { key = \"res5\"; label = \"BOK5:\"; is_enabled = false; }" " : ed { key = \"res6\"; label = \"BOK6:\"; is_enabled = false; }" " }" " }" " : button" " {" " key = \"cal\";" " label = \"Calculate\";" " }" " spacer;" " ok_only;" "}" ) (write-line str des) ) (setq des (close des) dch (load_dialog dcl) ) (<= dch 0) ) (princ "\nUnable to load DCL file.") ) ( (not (new_dialog "test" dch)) (princ "\nUnable to display 'test' dialog.") ) ( t (set_tile "dcl" "Calculate Area") (action_tile "mv" "(setq mv $value)") (action_tile "d1" "(setq d1 $value)") (action_tile "d2" "(setq d2 $value)") (action_tile "d3" "(setq d3 $value)") (action_tile "d4" "(setq d4 $value)") (action_tile "d5" "(setq d5 $value)") (action_tile "d6" "(setq d6 $value)") (action_tile "cal" (vl-prin1-to-string '( (lambda ( / m x y z a b c lijst_results ) (setq lijst_results '()) (set_tile "res" "") (set_tile "res2" "") (set_tile "res3" "") (set_tile "res4" "") (set_tile "res5" "") (set_tile "res6" "") (setq m (distof mv)) (if m (progn (setq lijst_results (append lijst_results (list (strcat "mv: " (rtos m 2 2))))) (if (and d1 (setq a (distof d1))) (progn (setq lijst_results (append lijst_results (list (strcat "A: " (rtos (- m a) 2 2))))) (set_tile "res" (rtos (- m a) 2 2)))) (if (and d2 (setq b (distof d2))) (progn (setq lijst_results (append lijst_results (list (strcat "B: " (rtos (- m b) 2 2))))) (set_tile "res2" (rtos (- m b) 2 2)))) (if (and d3 (setq c (distof d3))) (progn (setq lijst_results (append lijst_results (list (strcat "C: " (rtos (- m c) 2 2))))) (set_tile "res3" (rtos (- m c) 2 2)))) (if (and d4 (setq x (distof d4))) (progn (setq lijst_results (append lijst_results (list (strcat "X: " (rtos (- m x) 2 2))))) (set_tile "res4" (rtos (- m x) 2 2)))) (if (and d5 (setq y (distof d5))) (progn (setq lijst_results (append lijst_results (list (strcat "Y: " (rtos (- m y) 2 2))))) (set_tile "res5" (rtos (- m y) 2 2)))) (if (and d6 (setq z (distof d6))) (progn (setq lijst_results (append lijst_results (list (strcat "Z: " (rtos (- m z) 2 2))))) (set_tile "res6" (rtos (- m z) 2 2)))) (print lijst_results) ) (alert "Vul maaiveld waarden in.") ) ) ) ) ) (start_dialog) ) ) (*error* nil) (princ) )
  2. Hey guys! How's going? Can anyone help me? Look: i need to place a lot of blocks in an extensive polyline but the blocks need to have a specific distance from the polyline beginning - and this distance will not be equal to each block. So, i thought in create a list (excel or csv file) and specify each block name and distance to the lisp read the archive and place the block at correct point. Did you get it? PS: remember that the blocks will not have the same interval distance. This is an example for the list layout. And the result is something like this: I hope you guys could understand and help me! - sorry for my english - Thanks! Much love from Brazil Wellington Moura
  3. I'm trying to get a custom association list with the format: ((("TAG1" . "VAL1A") ("TAG2" . "VAL2A")("TAG3" . "VAL3A") ...) (("TAG1" . "VAL1B")("TAG5" . "VAL5B) ("TAG7". "VAL7B") ...) (("TAG1" . "VAL1C)("TAG3" . "VAL3C")("TAG4" . "VAL4C") ...)) So far, I can generate this list. So, in essence, the keys of each sublist (tags) in the list can differ slightly, meaning some tags can be missing in the other sub list. Where this happens is when attributes of blocks differ by a bit, with some values missing from another. When we use "ATTOUT", AutoCAD bypasses this by inserting empty values when you read the file as a csv file. When I'm trying to create a CSV file, I'd like to have these tags be at the first row and fill up values per item in the list. What I want is basically an ATTOUT but with my own association list. I'm trying to use Write CSV by Lee-Mac for this. So far, the only way I can do this is brute force the first row with the tags, and then extract each Value such that (("TAG1" "TAG2" "TAG3" "TAG4" ...) ("VAL1A" "VAL2A" "VAL3A" "VAL4A" ...) ("VAL1B" "VAL2B" "VAL3B" "VAL4B" ...)) Any ideas about how I should go forward with these.
  4. Happy new year my friends. Can someone help me by modifying this lisp, this code inserts a leader in one selected object and return the layer name. It would be nice this lisp could work on multiple objects at the same time, i don't mind if the leaders with the layer name are inserted on top of each, the main objective is to make a selection window and not have to pick one single object. Many Thanks MLabel.lsp
  5. I'm trying to find the latest revision from a list of revisions. The revisions start with A,B,C... Z, AA, AB, AC...ZZ, AAA, AAB, AAC... Then proceed to numbers 0, 1, 2, 3, etc. Any help would be appreciated! (setq testCases (list "A" "AA" "AB" "BD" "AZ" "ZZ" "ZZZ" "11" "10" "9" "2" "1" "0" "Z" "X" "D" "C" "B")) (setq testCases (vl-sort testCases '(lambda ( b a / x y ) (setq x (read a) y (read b)) (cond ( (and (numberp x) (numberp y)) (< x y)) ( (numberp y)) ( (numberp x) nil) ( (< a b)) ) ) ) ) (foreach test testCases (progn (princ "\n") (princ test) ) ) ;Currently produces the following reverse-alphabetical sequence: ;11, 10, 9, 2, 1, 0, ZZZ, ZZ, Z, X, D, C, BD, B, AZ, AB, AA, A ;Desired sequence: ;11, 10, 9, 2, 1, 0, ZZZ, ZZ, BD, AZ, AB, AA, Z, X, D, C, B, A
  6. ;; [INSERT INCEPTION SOUND EFFECTS HERE] ;; Preface: I've built a lisp routine that generates a script. The script then runs a SECOND lisp routine on a series of drawings. ;; I'm having serious trouble passing information from the first lisp routine to the second lisp routine. ;; The first lisp routine uses a DCL dialog box to gather user information, and the second lisp routine needs to apply this information to each drawing in a set. ;; I have assembled the information into a list of strings, which I'd like to pass as an argument into the second lisp (unless there's an easier way someone can share with me). ;; To do this, I've created the _StringifyList function, which creates a new list declaration string that gets written to the script file. ;; So here's the problem: ;; The strings in the arguments may contain quotes or backslashes since they are user entered. ;; The vl-string-translate commands I've added aren't properly appending extra backslash escape characters to make up for this. ;; Try running this example: (defun C:ListTest ( / *error* simpleList simpleListString) ;Return error descriptions to command line in the event of an error (defun *error* (/) (princ "\nInternal error") ) ;test strings are A,B,C ;to create a list: (setq simpleList (list "A" "B" "C")) (princ "simpleList: ") (princ simpleList) (princ "\n") ;result is not what we need: ;simpleList: (A B C) ;now lets wrap it with the stringify function: (setq simpleListString (_StringifyList simpleList)) (princ (strcat "simpleListString: " simpleListString "\n")) ;result is good, it can be written to a script as an argument now: ;simpleListString: (list "A" "B" "C") ;how about something more complicated though? ;test strings are one"quote, this\that, three"""quotes ;to create a list: (setq complexList (list "one\"quote" "this\\that" "three\"\"\"quotes")) (setq complexListString (_StringifyList complexList)) (princ (strcat "complexListString: " complexListString "\n")) ;result is bad. quotes have been replaced with backslashes, and backslashes haven't been duplicated. ;complexListString: (list "one\quote" "this\that" "three\\\quotes") ;what the result should look like (I think): ;complexListString: (list "one\"quote" "this\\that" "three\"\"\"quotes") (princ) ) ;; _StringifyList - plackowski ;; takes a list of strings and converts them to a declaration of a list of strings. ;; lst - [lst] A list of strings, like ("A" "B" "C") ;; str - [str] Output string in the format "(list "A" "B" "C")" (defun _StringifyList (lst / str) (setq str "(list") (foreach item lst ;any backslashes should be replaced with double slashes: \ -> \\ (setq item (vl-string-translate "\\" "\\\\" item)) ;any quotes in the string should be replaced with slash quotes to escape them: \" -> \\\" (setq item (vl-string-translate "\\\"" "\\\\\\\"" item)) (setq str (strcat str " \"" item "\"")) ) (setq str (strcat str ")")) )
  7. Hello, I want to ask for help. If i have list of points (startX1 X2 X3 X4 Xn EndXn StartX X X X X X EndX ....) --> StartX1 X2 X3 .. EndXn "all of the list is string" and i want to divide to different parts ((startX1 X2 X3 X4 Xn EndXn) (StartX X X X X X EndX)) Thank you
  8. Hi, I am running into problems with my program when I try to use the output from the "LM:directoryfiles" function. If I try to use the output from the "LM:directoryfiles" function (findjgw) I am getting the following error... error: bad argument type: (or stringp symbolp): ("L:\\DESIGN\\2018\\2018-290 Atkinson Crescent, ALDINGA BEACH\\Work in Progress CAD\\References CAD\\2018-290 Image\\2018-290 Image.jgw") (findjgw) returns the following "L:\\DESIGN\\2018\\2018-290 Atkinson Crescent, ALDINGA BEACH\\Work in Progress CAD\\References CAD\\2018-290 Image\\2018-290 Image.jgw" and if I enter this actual text string in my code it works, but it wont when referring to the variable (findjgw). Is it because I am trying to use a list as a string? If I only use the first element of a list are they not the same thing? Snippet that seems to be thew problem... ; Search Project "References CAD" Folder for ".jgw" files and Count how many... (setq rcpath (strcat sfpath "Work in Progress CAD\\References CAD\\")) (setq findjgw (LM:directoryfiles rcpath "*.jgw" T)) (setq countjgw (length findjgw)) (cond ( (= countjgw 1) (princ "\nOnly 1 Georeferenced Aerial Image exists in 'References CAD folder'") (setq jpgname (vl-string-subst "jpg" "jgw" findjgw)) (setq intFileDia (getvar "filedia")) (setvar "filedia" 0) (command "mapiinsert" jpgname "") (command "zoom" "e") (setvar "filedia" intFileDia) (princ "\nGeoreferenced Aerial Imagery Inserted...") ) ( (> countjgw 1) (alert "More than 1 Georeferenced Aerial Image exists in 'References CAD folder'...\nPlease select file to insert...") (command "mapiinsert") (princ) ) (t nil) );End Cond I will attach the full copy also. Regards, Ross. ONK Mapiinsert 4.lsp
  9. How can I arrange list of point coordinates(x y ) ascending to X or Y
  10. I have a 'while' loop that adds what was entered in the command line to a list each time it loops. Then I would like to get the sum of all the numbers in the list. I am pretty confident that this should work: (setq CLength1 (apply '+ (list lst))) But I get this error on the command line: ; error: bad argument type: numberp: (36 36 36 36) Full 'while' code: (while (progn (initget "U") (setq d (getdist (strcat "\Distance to next Vert Strap (Enter when done; U to Undo)")))) (setq lst (cons (fix d) lst)) (cond ((= d "U") (command "._undo" "._back")) ((/= d 0) (progn (command "._offset" (/ d 12.) s "_non" (polar (cdr (assoc 10 (entget s))) 0. 1.) "" ) (if (not (eq s (setq s (entlast)))) (progn (setq p1 (cdr (assoc 10 (entget s))) p2 (cdr (assoc 11 (entget s))) pt (if (< (cadr p1) (cadr p2)) p1 p2 ) ) (setq dx1 (car p1) ;ent x value dx2 (cadr p1) ;ent y value dx3 (caddr p1) ;ent z value dd1 (+ dx1 (/ d 12)) ;dimension distance sdx (- dx1 (/ d 12)) ;start point x dmx (/ (+ dd1 dx1) 2) ;middle ) (if (>= d 18) (setq doff -1.6) (setq doff -3.2) ) (entmake (list (cons 0 "DIMENSION") (cons 100 "AcDbEntity") (cons 67 0) (cons 8 "DIMBAD") (cons 100 "AcDbDimension") (cons 10 (trans (list dd1 doff 0.) 1 0)) (cons 11 (trans (list dmx doff 0.) 1 0)) (cons 12 (list 0. 0. 0.)) (cons 70 33) (cons 1 "") (cons 71 5) (cons 72 1) (cons 41 1.0) (cons 52 0) (cons 53 0) (cons 54 0) (cons 3 "TEMPLATE_DRAWING") (cons 100 "AcDbAlignedDimension") (cons 13 (trans (list sdx 0. 0.) 1 0)) (cons 14 (trans (list dx1 0. 0.) 1 0)) (cons 15 (list 0. 0. 0.)) (cons 16 (list 0. 0. 0.)) )) ) ) ) ))) (setq CLength1 (apply '+ (list lst))) (princ CLength1)
  11. benhubel

    Reverse Numbers

    I regularly use text to number objects for designating cut order. In the past, I have cobbled together some code that can quickly increment or decrement all selected numerical text in case I make a mistake and/or have to change something. This works marvelously, but often, I find that I need to go beyond that and completely reverse the order. Using this code as a starting point, I thought this would be super simple but the fact that I'm trying to do list manipulation to text objects is completely throwing me off. I'm still a bit new to this sort of thing. I was thinking I'd get a list of all selected text, sort it, then reverse that list before applying changes to the text. Highest number gets swapped with the lowest, second highest with second lowest, etc. ("1" "2") would become ("2" "1") ("2" "1" "4" "5" "3") would become ("4" "5" "2" "1" "3") ("2" "8" "17" "4") would become ("17" "4" "2" "8") ("3" "5" "-4") would become ("3" "-4" "5") I'm not sure where to start, nor what process to use. My main problem is that I can't figure out how to sort and edit the data without losing links to the correct text objects. Any help would be awesome. Here is the my quick increment/decrement routine that I'm trying to start with. ;Quick Increment/decrement ;Increments/decrements all selected text integers by 1 ;I hacked this code together with help from an "increment in range" routine. ;Original code can be found here https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/incriment-numbered-text/td-p/3614646?nobounce ;Quick Increment (defun C:qi (/ textselection textobject old) (vl-load-com) (setq textselection (ssget '((0 . "TEXT")))) (repeat (sslength textselection) (setq textobject (vlax-ename->vla-object (ssname textselection 0)) old (vla-get-TextString textobject); initial text content ); setq (if (and (= (strlen old) (strlen (itoa (atoi old)))); text represents integer ; Blocks e.g. "12A", "4.5", "C37", and completely non-numerical ; text [except for next test], but allows negative integers. ; Also disallows e.g. "06", "008", so if those should be included... (if (= (strlen old) 1) (wcmatch old "#") T) ; blocks single non-numerical character e.g. "A" [passes prior test] ); and (vla-put-TextString textobject (itoa (+ (atoi old) 1))); replace ); if (ssdel (ssname textselection 0) textselection) ); repeat (princ) (setq sel1 (ssget "P")) (sssetfirst nil sel1) ); defun ;Quick decrement (defun C:qd (/ textselection textobject old) (vl-load-com) (setq textselection (ssget '((0 . "TEXT")))) (repeat (sslength textselection) (setq textobject (vlax-ename->vla-object (ssname textselection 0)) old (vla-get-TextString textobject); initial text content ); setq (if (and (= (strlen old) (strlen (itoa (atoi old)))); text represents integer ; Blocks e.g. "12A", "4.5", "C37", and completely non-numerical ; text [except for next test], but allows negative integers. ; Also disallows e.g. "06", "008", so if those should be included... (if (= (strlen old) 1) (wcmatch old "#") T) ; blocks single non-numerical character e.g. "A" [passes prior test] ); and (vla-put-TextString textobject (itoa (- (atoi old) 1))); replace ); if (ssdel (ssname textselection 0) textselection) ); repeat (princ) (setq sel1 (ssget "P")) (sssetfirst nil sel1) ); defun
  12. Hello kind Lispers, I am wondering if someone can point me in the right direction. I have a 3D Primitive Shape, many of them actually. Picture a concrete building floor with slopes, and drain trenches. none of the shapes are simple rectangles. I see that the AutoCAD command: list will produce the following. Command: list Select objects: 1 found Select objects: Ks_VolBody Layer: "0" Space: Model space Handle = 1bc Coordinates of Object Entity Coordinate System Origin X= 122.2666 Y= 66.7545 Z= 0.0000 Xaxis X= 1.0000 Y= 0.0000 Z= 0.0000 Yaxis X= 0.0000 Y= 0.0000 Z= 1.0000 VersionIndex = 0 PartOrigin =-1 Area =128102.870250 Volume =2752941.011569 Center of Weight X=276.671661 Y=186.828356 Z=50.368505 (Sorry i know that code wrapper is meant for..well.. code. but it looks better this way) OK the point is. The volume that the list command produces is correct. I want this Volume, and I want to be able to simply prompt the user of my LISP to pick a shape and then store this volume in a variable. The problem I am having is that I can not seem to find where to access this Volume. Any help would be appreciated Cheers! Andy.
  13. When you select some points and type list, AutoCad brings a list of some data such as point coordinate and layer name or color etc. On the other hand if you have a large number of points you need to press enter and go to next page. One year ago I saw a lisp routine which could list all point coordinates in list window without any further unnecessary data, so you could copy and paste all your selected point coordinates to a text file or excel at once. Now I have lost that great lisp. That was something like this pic (this has created by Photoshop) If anyone have it please give it to me or please write a lisp like this for me again. Any help would be greatly appreciated.
  14. I've spent some time writing up the following tutorial which aims to demonstrate how to construct a simple block counter and in the process give the user an introduction to association lists and dotted pairs: Building Association Lists: A Simple Block Counter The tutorial is a step-by-step walkthrough of the process of creating the block counter, with diversions here and there to explain the various concepts used by the program. Throughout the tutorial I've also tried to explain why every part of the code is used in the way that it is, rather than providing the reader with a block of code and leaving some parts without an explanation (for example, why the program should include (princ) or (prin1) as the last expression etc.). I welcome your feedback on the tutorial - Is it too simplified? Is it too long? Too boring? All of the above? Feel free to also point out any typos, as these can be difficult to spot when proof-reading your own work. Thanks, Lee
  15. I know how to do this and have done it. BUT. I have multiple products.ini, products2.ini files where i get the values for popup_list. The first selected is ok. However when i change to the external ini file to the next ini file. The content of the popup_list is still the one i have used at first. I cant post the whole lisp nor DCL but has someone experienced this before and how can i "flush" the old external ini values? Thanks.
  16. I'm trying to make a block with an item list where I can choose any or all of 10 line items, I can put a stretch and array to size up the list to exclude blank lines but I cannot figure out which method to use to make a checklist. Layers are not an option because our clients have certain layer lists. Visibility seems to just do 'This OR That', not 'This, This AND That'. I think a LookUp Table is the key but I don't know which parameter sets to start with and how to make this checklist work. Attributes are not really the answer because the line items have 9 columns of info that never change on each item line. They must stay in the same order too. If there was some way to turn off sub-blocks, and drag them up or down! Thanks for any ideas!
  17. Drawing List Report only brings up sheet numbers. I've just started using electrical and have had to hit the ground running with it, everything has been going fine until I try to edit the index created by drawing list report. I am in Glasgow working on one server, and I send complete work over to Belfast which they copy onto their server. The most annoying thing is that i only want to pull 'sheet number' and 'description' info for a table that would take me seconds to edit manually. Problem:- when I run a report it only lifts sheet numbers, (allegedly when i tranfer the files over to the belfast server they tell me it works first time). I have tried experimenting with other project files to the same end... the default DWGDESC field never lifts any info (i do change its name). I am new to this but my spider senses are tingling and i think maybe I am missing access to a file that they have stored on their server. Does anyone recognise this problem? I hope its glaringly obvious... help me obi wan... your my only hope...
  18. Hi, I have a list of Xrefs Xref_1 Xref_2 Xref_3_ELC Xref_4_ELC Xref_........ I want to modify the list to only include items that have_ELC at the end. even better would be if i could only add Xrefs to my list that have _ELC at the end. both attempts below do not succeed. any ideas? (defun c:findxref (/ td xrf) (setq XrfM nil) (while (setq td (tblnext "BLOCK" (not td))) (and (= (logand (cdr (assoc 70 td)) 4) 4) (setq xrf (cons (strcase (cdr (assoc 2 td))) xrf)) ) ) (print xrf) ;attempt with Vl-remove (foreach n xrf (if (/= (wcmatch n "*_ELC")T) (vlremove n xrf))) ;Create new list (foreach n xrf (if (= (wcmatch n "*_ELC")T) (append n xrfm))) (print Xrf) (print Xrfm) (princ) ) Thanks
  19. Hey Guys, Its been a awhile since I have done any Autolisp programming and I am stuck... I am using a conditional statement to generate a number i.e. 1.625 and then I want to add that to the Z elevation of a point but it keep erroring out at this line. I have spent about an hour and half looking back thru resources and haven't been able to find the correct syntax. This is the line erroring out: (setq NEWPT1 (APPEND (LIST (CAR USRP1) (CADR USRP1)) (+ (CDDR USRP3) TRAP_Z_OFF))) ; ERRORS OUT HERE Here is the full code. (defun C:droptrap() (command "UNDO" "BEGIN") (initerr) (setvar "lunits" 2) (setvar "luprec" 4) (setvar "attreq" 0) (command "UNDO" "BEGIN") (setq OLDCMD (GETVAR "CMDECHO")) (setvar "CMDECHO" 0) (setq OLDOSMODE (GETVAR "OSMODE")) (setvar "OSMODE" 0) (setq OLDORTHOMODE (GETVAR "ORTHOMODE")) (vl-load-com) (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object))) (initget "1 2 3 4") (setq TRAP_TYPE (getkword "\n Select trapeze type: ([1]:1-5/8x1-5/8, [2]:1-5/8x1-5/8 B2B, [3]1-5/8x13/16, [4]1-5/8x13/16 B2B): ")) (if (or (= TRAP_TYPE "1")(= TRAP_TYPE "3")) (progn (initget "1 2") (setq FACE_DIR (getkword "\n Trapeze opening up or down?: ([1]:UP [2]:Down): ")) ) (setq FACE_DIR "1") ) (cond ((and (= TRAP_TYPE "1")(= FACE_DIR "2")) (setq TRAP_Z_OFF 1.625)) ((and (= TRAP_TYPE "3")(= FACE_DIR "2")) (setq TRAP_Z_OFF 0.8125)) (T (setq TRAP_Z_OFF 0.0)) ) (setq blockname "TRAP-XDATA-T1_1.625") (setq USRP1 (GETPOINT "\n Select center point of rod 1: ")) (setq USRP2 (GETPOINT "\n Select center point of rod 2: ")) (setq USRP3 (getpoint "\n Select elevation of attachment point: ")) (setq NEWPT1 (APPEND (LIST (CAR USRP1) (CADR USRP1)) (+ (CDDR USRP3) TRAP_Z_OFF))) ; ERRORS OUT HERE (setq NEWPT2 (APPEND (LIST (CAR USRP2) (CADR USRP2)) (+ (CDDR USRP3) TRAP_Z_OFF))) ; ERRORS OUT HERE TOO (setq MIDPT (POLAR NEWPT1 (ANGLE NEWPT1 NEWPT2) (* (DISTANCE NEWPT1 NEWPT2) 0.5))) (setvar "ORTHOMODE" 1) (COMMAND "-INSERT" BLOCKNAME MIDPT "1" "1" NEWPT2) (command "rotate3d" (entlast) "" 2 NEWPT1 NEWPT2 90) (setvar "OSMODE" OLDOSMODE) (setvar "CMDECHO" OLDCMD) (setvar "CLAYER" LAYNAME) (COMMAND "UNDO" "END") (PRINC) ) The code is unfinished so I am trying to keep it working as I build it.
  20. Hello guys, Is it possible to create a list in table about my dynamick blocks which is contain the different length, size and view of the blocks? Is it a command to list in table all of the blocks with this attributes? Thank you for your help! T
  21. Say this is my code: (defun c:test() (setq list(getpoint "\nChoose point here") ) When you click on your autocad drawing i know that it stores the coordinates in a x,y,z format in a list.. How can i extract those numbers?
  22. Hello everybody. I need help to sort lists in a code. Use a program created by the great Fixo to create tables containing some attributes. I found that, depending on how the block is built, the end result will be undesired. I took the liberty of attaching the file exemplifying the case. Any help will be appreciated. Luís Augusto. Sort list.dwg ;Oleg Fateev ;16th Jan 2014 06:18 pm (defun C:CLIST (/ acapp acsp adoc atable attdata attitem atts blkname blkobj col en headers pt row sset title ) (txtNotExists) (TablExists) (or adoc (setq adoc (vla-get-activedocument (setq acapp (vlax-get-acad-object))) ) ) (or acsp (setq acsp (vla-get-block (vla-get-activelayout adoc))) ) (if (setq sset (ssget "_:S:E:L" (list (cons 0 "INSERT") (cons 66 1) (cons 410 (getvar "ctab")) ) ) ) (progn (setq en (ssname sset 0)) (setq blkobj (vlax-ename->vla-object en) blkname (vla-get-effectivename blkobj) ) (if (/= blkname "*");any other block different "*" (progn (setq atts (vlax-invoke blkobj 'getattributes)) (foreach attobj atts (if (wcmatch (vla-get-tagstring attobj) "PIN_*");change "PIN_#*" use letters also (progn (setq attitem (cons (vla-get-tagstring attobj) (vla-get-textstring attobj) ) ) (setq attdata (cons attitem attdata)) ) (setq attdata (reverse attdata)) ) ) (setq attdata (mapcar '(lambda (a) (list (vl-string-subst "" "PIN_" (car a)) (cdr a) ) ) attdata ) ) (if (setq pt (getpoint "\nSpecify table location:")) (progn (setvar 'ctablestyle "TB_CONECTORS") (setq atable (vla-addtable acsp (vlax-3d-point pt) (+ 2 (length attdata)) 2 (/ (getvar 'dimtxt) 2) (* (getvar 'dimtxt) 16) ) ) (vla-put-regeneratetablesuppressed atable :vlax-true) (setq col 0) (foreach wid (list 4.5 30.5) (vla-setcolumnwidth atable col wid) (setq col (1+ col)) ) (vla-put-horzcellmargin atable 0.3) (vla-put-vertcellmargin atable 0.3) (vla-setTextheight atable 1 2.0) (vla-setTextheight atable 2 1.4) (vla-setTextheight atable 4 1.4) (setq title blkname) ;(setq title (getstring (strcat "\nTable title: <" blkname ">: "))) (if (eq "" title) (setq title blkname) ) (vla-setText atable 0 0 title) (vla-setcelltextheight atable 0 0 2.0) (vla-SetCellAlignment atable 0 0 acMiddleCenter) (setq headers (list "Pin" "Circuit / Color / Section / Mark") ) (setq row 1 col 0 ) (repeat (length headers) (vla-SetCellAlignment atable row col acMiddleCenter) (vla-setcelltextheight atable row col 1.4) (vla-setText atable row col (car headers)) (setq headers (cdr headers)) (setq col (1+ col)) ) (setq row 2) (foreach record attdata (setq col 0) (foreach item record (vla-setText atable row col item) (if (= 0 col) (vla-SetCellAlignment atable row col acMiddleCenter) (vla-SetCellAlignment atable row col acMiddleLeft) ) (vla-setcelltextheight atable row col 1.4) (setq col (1+ col)) ) (setq row (1+ row)) ) (vla-put-regeneratetablesuppressed atable :vlax-false) (vla-put-height atable (+ (* (vla-get-rows atable) 2.2) 4.1) ) (vla-update atable) ) ) ) ) ) ) (princ) ) (defun txtNotExists () (if (not (tblsearch "style" "ARIAL_2.0")) (progn (entmake (list '(0 . "STYLE") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbTextStyleTableRecord") '(2 . "ARIAL_2.0") ;<- Your style name here '(70 . 0) '(40 . 2.0) '(41 . 1.0) '(50 . 0.0) '(71 . 0) '(42 . 0.09375) '(3 . "Arial.ttf") '(4 . "")) ) (princ) ) ) ) (defun TablExists () (vl-load-com) (setq stylename "TB_CONECTORS") (setq actdoc (vla-get-activedocument (vlax-get-acad-object))) (setq dict (vla-get-dictionaries actdoc)) (setq tabcol (vla-item dict "acad_tablestyle")) (if (vl-catch-all-error-p (setq tabsty (vl-catch-all-apply 'vla-item (list tabcol stylename)))) (progn (vl-load-com) (MakeTableStyle) ) ) (princ) ) (vl-load-com) (defun MakeTableStyle() ;;http://hyperpics.blogs.com/beyond_the_ui/2012/07/creating-a-table-style-with-autolisp-and-the-activex-api.html ;;By Lee Ambrosius ;; Get the AutoCAD application and current document (setq acad (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acad)) ;; Get the Dictionaries collection and the TableStyle dictionary (setq dicts (vla-get-Dictionaries doc)) (setq dictObj (vla-Item dicts "acad_tablestyle")) ;; Create a custom table style (setq key "TB_CONECTORS" class "AcDbTableStyle") (setq custObj (vla-AddObject dictObj key class)) ;; Set the name and description for the style (vla-put-Name custObj "TB_CONECTORS") (vla-put-Description custObj "Tabela de conectores") ;; Sets the bit flag value for the style (vla-put-BitFlags custObj 1) ;; Sets the direction of the table, top to bottom or bottom to top (vla-put-FlowDirection custObj acTableTopToBottom) ;; Sets the supression of the table header (vla-put-HeaderSuppressed custObj :vlax-false) ;; Sets the horizontal margin for the table cells (vla-put-HorzCellMargin custObj 0.3) ;; Sets the supression of the table title (vla-put-TitleSuppressed custObj :vlax-false) ;; Sets the vertical margin for the table cells (vla-put-VertCellMargin custObj 0.3) ;; Set the alignment for the Data, Header, and Title rows (vla-SetAlignment custObj (+ acDataRow acTitleRow) acMiddleLeft) (vla-SetAlignment custObj acHeaderRow acMiddleCenter) ;; Set the text height for the Title, Header and Data rows (vla-SetTextHeight custObj acTitleRow 1.5) (vla-SetTextHeight custObj (+ acDataRow acHeaderRow) 1.0) ;; Set the text height and style for the Title row (vla-SetTextStyle custObj (+ acDataRow acHeaderRow acTitleRow) "ARIAL_2.0") (princ) ) (prompt "\n\t---\tStart command with CLIST\t---\n") (prin1) (or (vl-load-com)) (princ)
  23. I have tried several combination and gone thru about a 100 posts but I can't figure out what I am doing wrong. I am filtering thru objects and pulling out a 3D coordinate from the database. Then I am turning that into a 3 point list (x y z). Then I want to create a list of those points and add to them to the existing list as the program filters thru the remaining objects from the selection set. (progn (setq unitpoint_orig (vl-string-right-trim ";" (substr (vlax-get entvla 'points) 12))) (if (and(or (= Z_pref "Y")(= Z_pref "y"))(/= Z_height nil)) (progn (setq unitpoint_mod (comma_pull unitpoint_orig "REAL_NUM")) (setq unitpoint (list (car unitpoint_mod) (cadr unitpoint_mod) (caddr Z_height))) ) (setq unitpoint (comma_pull unitpoint_orig "REAL_NUM")) ) (setq unitpoint_lst (append unitpoint_lst 'unitpoint)) ;(command "insert" pl_block unitpoint "1" "1" "0") ) Current Result: (105.13 3165.22 0.0 105.13 3194.65 0.0 105.13 3142.5 0.0) Desired Result: ((105.13 3165.22 0.0)(105.13 3194.65 0.0)(105.13 3142.5 0.0)) Once I get this part working, I am then planning on filtering for duplicates using Lee Mac's subroutines. Then inserting based off those points.
  24. Hi guys, When I insert a dynamic block containing text attributes, it brings up a list of questions for me to fill in the information (as normal). For convenience, I would like them to appear in some sort of logical order. Does anyone know how this can be achieved? To rearrange the list?
  25. Maybe I'm just too new at the LISP thing but I've been through many forums and nothing really seems to spell it out for the layman, i.e. me. My company seems rather fresh to LISP as well but they have one "master" list of lisps they have used for some time. This list is loaded in everyone's CAD. I have several others that I have found that I would like to add to this master list but I don't see how they are separated and loaded. The idea is to update this master list with new commands and have others be able to simply have them available the next time CAD is started up again when the original lisp is loaded. Is there a quickie routine that loads other locations? I was given this style of line and told it would do such a thing but I must still be doing something wrong (load "brkblk") (load "BreakObjects18") (load "CCC") (load "Copy2DrawingsV1-2") (load "Copy2LayoutsV1-1") (load "DoubleOffsetV1-1") (load "Dynamic-Offset") (load "MCOPY") (load "QuickDimAligned-QDA") (load "ROT2ENT") (princ (load "BreakObjects18" "\nBreakObjects18.LSP file not loaded..")) (princ (load "CCC" "\nCCC.LSP file not loaded..")) (princ (load "Copy2DrawingsV1-2" "\nCopy2DrawingsV1-2.LSP file not loaded..")) (princ (load "Copy2LayoutsV1-1" "\nCopy2LayoutsV1-1.LSP file not loaded..")) (princ (load "DoubleOffsetV1-1" "\nDoubleOffsetV1-1.LSP file not loaded..")) (princ (load "Dynamic-Offset" "\nDynamic-Offset.LSP file not loaded..")) (princ (load "MCOPY" "\nMCOPY.LSP file not loaded...")) (princ (load "QuickDimAligned-QDA" "\nQuickDimAligned-QDA.LSP file not loaded...")) (princ (load "ROT2ENT" "\nROT2ENT.LSP file not loaded...")) Thanks for the patience, -Nobull
  • Create New...