Jump to content

Search the Community

Showing results for tags 'lisp'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

Categories

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

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

  1. I'm new to Lisp and trying calculate the distance from a wall to a polygon box, as well as the distance between two polygon boxes. Additionally, I need to determine the dimensions of both the polygon box and the wall. I'm using Lee Mac's dimensioning code as a reference and trying to modify it to achieve these calculations.can i get this type of outcome using lisp
  2. I found this nice revision cloud lisp made by Lee Mac: (defun c:rv ( / *error* ar bn cm el fn rv ) (setq bn "revlsp") ;; Rev Cloud Attributed Block (defun *error* ( msg ) (if cm (setvar 'cmdecho cm)) (if ar (setvar 'attreq ar)) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)) ) (princ) ) (setq cm (getvar 'cmdecho) ar (getvar 'attreq) ) (cond ( (not (or (tblsearch "BLOCK" bn) (and (setq fn (findfile (strcat bn ".dwg"))) (progn (setvar 'cmdecho 0) (command "_.-insert" fn nil) (setvar 'cmdecho cm) (tblsearch "BLOCK" bn) ) ) ) ) (princ (strcat "\n" bn ".dwg not found.")) ) ( (zerop (logand 2 (cdr (assoc 70 (tblsearch "BLOCK" bn))))) (princ (strcat "\n" bn " not attributed.")) ) ( (setq *rev* (cond ( (= "" (setq rv (getstring t (strcat "\nSpecify Revision" (if *rev* (strcat " <" *rev* ">: ") ": "))))) *rev* ) ( rv ) ) ) (initcommandversion) (command-s "_.revcloud") (while (= 1 (logand 1 (getvar 'cmdactive))) (command "\\")) (setvar 'cmdecho 0) (setvar 'attreq 0) (setq el (entlast)) (command "_.-insert" bn "_S" 1.0 "_R" 0.0 "\\") (if (not (eq el (setq el (entlast)))) (progn (setq el (entget (entnext el))) (if (entmod (subst (cons 1 *rev*) (assoc 1 el) el)) (entupd (cdr (assoc -1 el))) ) ) ) (setvar 'attreq ar) (setvar 'cmdecho cm) ) ) (princ) ) (princ) What I wish to do is: 1. Set the insertion point with variable rotation using osnap nearest and then back to current osnaps 2. - Save current layer/working layer. - Then temporarily change to a new given layer but change colour on the revision cloud to cyan (not the block) - Do the revision cloud and the insert. - Finally change back to my working layer. (in my case "K596 - Revideringsmoln") REVLSP.dwg I have tried to delete the 0.0 (command "_.-insert" bn "_S" 1.0 "_R" "\\") It just allows me to rotate the block and then place it. And the revision do not show. I would like to place first and then rotate. How do I specify the insert point for the block so I can rotate it?
  3. Hello everyone I need a Lisp that converts the contents of one or more separate texts (not MTEXT) to another text. Suppose that there are discrete texts in different places of the layout, for example, apple, orange, banana, lemon. I need a lisp that after typing the command, I do the first right click on the apple, and by doing the rest of the right clicks on other fruits, they turn into apples. Thank you for your help.
  4. Hello, I am trying to create a lisp routine that sets all existing MLEADERs to a certain pre-set MLEADERSTYLE, the equivalent of doing a Quick Select for Mleaders, and setting the style under the properties window. I was able to write a similar routine that selects all dimensions and sets them to a certain DIMSTYLE, using entmod and DXF code 3 for dimstyle. So far, I have not been able to find a group code for MLEADERSTYLE Any help would be greatly appreciated! (defun C:dimstylechange (/ ENTITIES NO_OF_ENTITIES SSPOSITION ENTITY_NAME OLD_ENTLIST NEW_STYLE NEW_ENTLIST) (setvar "CMDECHO" 0) (setq ENTITIES (ssget "X" '((0 . "DIMENSION")))) (setq NO_OF_ENTITIES (sslength ENTITIES)) (setq SSPOSITION 0) (repeat NO_OF_ENTITIES ;***CHANGE STYLE*** (setq ENTITY_NAME (ssname ENTITIES SSPOSITION)) (setq OLD_ENTLIST (entget ENTITY_NAME)) (setq OLD_STYLE (assoc 3 OLD_ENTLIST)) (setq NEW_STYLE (cons 3 "BCR 11x17")) (setq NEW_ENTLIST (subst NEW_STYLE OLD_STYLE OLD_ENTLIST)) (entmod NEW_ENTLIST) ;***CHANGE LAYER*** (setq OLD_ENTLIST (entget ENTITY_NAME)) (setq OLD_STYLE (assoc 8 OLD_ENTLIST)) (setq NEW_STYLE (cons 8 "DIM")) (setq NEW_ENTLIST (subst NEW_STYLE OLD_STYLE OLD_ENTLIST)) (entmod NEW_ENTLIST) (setq SSPOSITION (1+ SSPOSITION)) ) (command ".CHPROP" ENTITIES "" "C" "BYLAYER" "LT" "BYLAYER" "") (princ (strcat "\n..." (rtos NO_OF_ENTITIES 2 0) " Dimension(s) changed...")) (setvar "CMDECHO" 1) (princ) ) dimstylechange.LSP
  5. I have drawing with a bunch of blocks with attributes tags. Among the attribute tags the following three are of importance: ID Next Previous The ID attribute values are already entered in the blocks and are unique. I would like to have a lisp that will enable me to sequentially pick the blocks and fill in the Next and Previous attributes tags with the ID values. Attached is sample file showing the starting point and expected end result. Any ideas how to go about making this lisp? EDIT: I have been able to modify a lisp from @Lee Mac as fist step. But it only works in forward direction i.e to fill in Previous attribute. Im thinking that to get the functionality to fill in "Next", we cannot use single item selection, we will have to use list selection to get the iD of next block and fill in the current block in "Next" Attribute. So the operation sequence will be Start lisp> Click all blocks one by one> hit Enter Any help in achieving this will be welcome. (defun c:ca ( / _SelectBlockWithTag a b des src tag ) (vl-load-com) (setq src "ID" ; Source Attribute Tag des "Previous" ; Destination Attribute Tag ) (defun _SelectBlockWithTag ( tag / e a ) (setq tag (strcase tag)) (while (progn (setvar 'ERRNO 0) (setq e (car (entsel (strcat "\nSelect Block with attribute " tag ": ")))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, Try Again.") ) ( (not e) nil ) ( (and (eq "INSERT" (cdr (assoc 0 (entget e)))) (= 1 (cdr (assoc 66 (entget e)))) ) (if (not (setq a (vl-some (function (lambda ( x ) (if (eq tag (strcase (vla-get-tagstring x))) x) ) ) (vlax-invoke (vlax-ename->vla-object e) 'getattributes) ) ) ) (princ (strcat "\nBlock does not contain tag " tag ".")) ) ) ( (princ "\nInvalid Object Selected.") ) ) ) ) a ) (while (and (setq a (_SelectBlockWithTag src)) (setq b (_SelectBlockWithTag des)) ) (vla-put-textstring b (vla-get-textstring a)) ) (princ) ) SampleDrwaing.dwg
  6. I am looking for a routine to sort contour lines. I am using 3d polylines that I import from Global Mapper. My problem is all of the lines are on one layer. Ideally, I would like to pick a starting elevation (polyline) and have the routine select every 5th contour up and down. Once then are all selected, I can move them to a new layer (like TOPO-INDEX). Some of these sites are hundreds of acres and have significant elevation changes. To do this by hand is VERY time-consuming (and easy to miss some contours). I am not a programmer, but this seems like the type of task that is ideal for a lisp routine. Any help is appreciated.
  7. Hi guys, I've been trying to figure out a way to insert a new block in a project that already has one with the same name. I would like to have something asking me if I want to keep the old one or replace/overwrite with the new one. Keeping the placement of the old block in the project. I know that AutoCAD keeps the old version on a block if it has the same name as the new one, having to remove all instance of the block and purge all. Why wouldn't AutoCAD asked me ; [There is a block with the same name in your project, Would you like to; Overwrite, Rename, Cancel] Just like in file explorer on desktop. Anyway, maybe I'm asking to much let me know guys if you have a suggestion, either a LISP or a command that I'm not aware of yet in AutoCAD.. Thanks
  8. Hi guys, Im new here and i've been searching and even asking chatgpt to help me out but it doesnt seem to work properly. Im working on a SLD (Single Line Diagram) for an electrical project and when wires cross on the diagram, it needs to have a gap on one of the 2 lines. I've tried this lisp command that ChatGPT gave me but with little to no success; (defun c:BreakAndShorten ( / pt line break_length startpt1 endpt1 startpt2 endpt2) (setq break_length 2.5) ; Set your desired shorten length here (2.5 mm in this case) (setq line (car (entsel "\nSelect the line to break: "))) (setq pt (getpoint "\nSelect the break point: ")) (if (and line pt) (progn (setq startpt1 (polar pt (angle pt (vlax-curve-getStartPoint line)) (- break_length))) (setq endpt1 pt) (setq startpt2 pt) (setq endpt2 (polar pt (angle pt (vlax-curve-getEndPoint line)) break_length)) (command "BREAK" line startpt1 endpt2) (setq line1 (car (entsel "\nSelect the first segment to shorten: "))) (setq line2 (car (entsel "\nSelect the second segment to shorten: "))) (if line1 (command "LENGTHEN" "DE" (- break_length) line1)) (if line2 (command "LENGTHEN" "DE" (- break_length) line2)) ) (alert "You must select a line and a break point.") ) (princ) ) In sum, I want to break one line at a point and then shorten the 2 segments by 2.5mm so it has a 5mm gap without using multiple command everytime
  9. Hello, I am searching for a lisp that can export the lengths of all selected polylines and export them to either Excel or an AutoCad table. I have found and tested around 20 lisps but so far cannot find the right one. There were only 2 that look promising, maybe they could be modified? One was by Lee Mac and the other Jimmy Bergmark. I can post the 2 Lisp if needed. The lisp would need to have you select multiple polylines and give the total lengths of each polyline in the order that they were selected in. Then the data would either appear on an AutoCad table or Excel. Thanks for any help that can be provided.
  10. Hi, i have multiple polylines in a series and block are placed on them. i want to select the polylines between two selected blocks. sample file is attached. Thanks, Srikanth select_between _two_blocks_sample.dwg
  11. Hi guys I'm not sure that this is possible but hey you guys know a hell of a lot and surprise me often. Is it possible in lisp to look inside a text file and remove some text from between 2 keywords? For example The text filename would be the same as the cad file, but it's on another network location. I can create a variable that concatenates the file name and location. This I know I can do lol. Then I want the lisp to open the file find Keyword1 and keyword2 (always the same and only ever 1 of each in the file, also there would always be text before and after the keywords which should be kept intact). Then remove any text that lies between them. And finally resave the file. I've done some searches but I keep getting results for editing text inside of cad, which isn't what I'm after, or recommending using other programming language, but I've no idea how to do that. Which is why I'm pinning my hopes on this.
  12. Hello everyone, I'm wondering if it is possible to create a lisp that could attach several images to AutoCAD 2010 at the same time and create a new layer that has the same name like an image for each image. I downloaded georefimg app that put an image in certain place in AutoCAD based on world file but it is necessary to do this for each image separately. In case of this app first thing to do is attach one image to CAD and afterwards I can use georefimg to choose an image (that was inserted before) in order to put this in proper section. But it could be faster and more efficient if I would attach many images equally in random place and after that use this georefimg for all images. If someone has some idea how to prepare sth like this I'll be grateful for any suggestions in this case. Best wishes, Jakub
  13. Shib Sankar

    Batch blocking

    Can anyone help me to write a code ?? Which Identifies each closed polyline (rectangle) on the "ss-bor" layer. Finds the text entity (content) of text on the "ss-pre" layer which is within (rectangle) on the "ss-bor" layer . Selects all entities on the "ss-part" layer within the (rectangle) on the "ss-bor" layer. Creates a block using the text value from the "ss-pre" layer as the block name, including all selected entities from the "ss-part" layer within the (rectangle) on the "ss-bor" layer. and loop though each (rectangle) on the "ss-bor" layer and make block of each as above mentioned.. For information i have attached my dwg file G27.dwg
  14. 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) )
  15. I want to change the values of a dynamic block within a lisp. This lisp contains a calculation. I used .dcl for this. My dynamic block has 7 attributes: maaiveld, HOOGTE1, HOOGTE2, HOOGTE3, HOOGTE4, HOOGTE5 and HOOGTE6. My lisp code has 7 values: m, a, b, c, x, y and z The order of these outputs are important. a, b, and c are sewer pipes that arrive in the cewer, and x, y, and z are pipes that depart from the sewer pit. So if there are only 2 pipes, we only have to use a and x. This makes it difficult. I can't just set HOOGTE1 to a, HOOGTE2 to b, HOOGTE3 to c, etc. If I do it this way, it will leave a gap in my leader. I hope this is even possible. I provided some screenshots of my calculator and of the leader, and the problem of the gap. Maybe I just need to create a more complex dynamic block, so that I can just connect the hoogte1,2,3,... to a,b,c,... I really don't know. 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 ) (set_tile "res" "") (set_tile "res2" "") (set_tile "res3" "") (set_tile "res4" "") (set_tile "res5" "") (set_tile "res6" "") (cond ( (or (not mv) (= "" mv)) (alert "Please enter a maaiveld value.") (mode_tile "mv" 2) ) ( (or (not d1) (= "" d1)) (alert "Please enter a A value.") (mode_tile "d1" 2) ) ( (or (not d2) (= "" d2)) (alert "Please enter a B value.") (mode_tile "d2" 2) ) ( (or (not d3) (= "" d3)) (alert "Please enter a C value.") (mode_tile "d3" 2) ) ( (or (not d4) (= "" d4)) (alert "Please enter a X value.") (mode_tile "d4" 2) ) ( (or (not d5) (= "" d5)) (alert "Please enter a Y value.") (mode_tile "d5" 2) ) ( (or (not d6) (= "" d6)) (alert "Please enter a Z value.") (mode_tile "d6" 2) ) ( (not (setq m (distof mv))) (alert "Het Maaiveld moet een getal zijn.") (mode_tile "mv" 2) ) ( (not (setq a (distof d1))) (alert "The A must be numerical.") (mode_tile "d1" 2) ) ( (not (setq b (distof d2))) (alert "The B must be numerical.") (mode_tile "d2" 2) ) ( (not (setq c (distof d3))) (alert "Het C moet een getal zijn.") (mode_tile "d3" 2) ) ( (not (setq x (distof d4))) (alert "The X must be numerical.") (mode_tile "d4" 2) ) ( (not (setq y (distof d5))) (alert "The Y must be numerical.") (mode_tile "d5" 2) ) ( (not (setq z (distof d6))) (alert "The Z must be numerical.") (mode_tile "d6" 2) ) ( (<= m 0.0) (alert "Het maaiveld moet groter dan nul zijn.") (mode_tile "mv" 2) ) ( (<= a 0.0) (alert "The A must be greater than zero.") (mode_tile "d1" 2) ) ( (<= b 0.0) (alert "The B must be greater than zero.") (mode_tile "d2" 2) ) ( (<= c 0.0) (alert "Het C moet groter dan nul zijn.") (mode_tile "d3" 2) ) ( (<= x 0.0) (alert "The X must be greater than zero.") (mode_tile "d4" 2) ) ( (<= y 0.0) (alert "The Y must be greater than zero.") (mode_tile "d5" 2) ) ( (<= z 0.0) (alert "The Z must be greater than zero.") (mode_tile "d6" 2) ) (t (set_tile "res" (rtos (- m a) 2)) (set_tile "res2" (rtos (- m b) 2)) (set_tile "res3" (rtos (- m c) 2)) (set_tile "res4" (rtos (- m x) 2)) (set_tile "res5" (rtos (- m y) 2)) (set_tile "res6" (rtos (- m z) 2)) ) ) ) ) ) ) (start_dialog) ) ) (*error* nil) (princ) ) The code needs work to be visually better, but I want it to work before I do that.
  16. Guys, I need one help, someone knows one Lisp that I can get Texts (words) on AutoCad and export it in order of selection to a cell on Excel... Eg.: If I have 10 words, as I'll selecting it and when finished these then words will be exported to a cell (could be cels) to Excel. Thanks in advance...
  17. I'm almost there with my workflow, but I need a little help to get it just right. Here's what I'm trying to do: Type command Select block Pick Mleader arrow location Pick Mleader landing location Mleader content should automatically populate with the "SW_LENGTH" parameter from the block Everything works great up until step 5. After I pick both Mleader points, the Mleader text box opens for me to fill out (it's blank). But if I click in the drawing area, it exits the text box and fills in the correct info. So, how do I skip that last step and have the Mleader content fill in automatically without Autocad opening the text edit box? ;; Get Dynamic Block Property Value - Lee Mac ;; Returns the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) (defun LM:getdynpropvalue (blk prp) (setq prp (strcase prp)) (vl-some '(lambda (x) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'Value))) (vlax-invoke blk 'GetDynamicBlockProperties))) (defun c:swtest () (setq blockName (car (entsel "\nSelect Block: "))) (if (and blockName (eq (cdr (assoc 0 (entget blockName))) "INSERT")) (progn (setq vlaBlock (vlax-ename->vla-object blockName)) (setq SW_LENGTH (LM:getdynpropvalue vlaBlock "SW_LENGTH")) (if SW_LENGTH (progn (setq textString (strcat "SW_LENGTH: " (rtos SW_LENGTH 2 2))) (princ (strcat "\n" textString)) (if (setq ins (getpoint "\nSpecify start point for MLeader: ")) (progn (setq endPoint (getpoint "\nSpecify end point for MLeader: " ins)) (setq curlay (getvar "CLAYER")) (setvar 'CMDECHO 0) (command "_.undo" "_group") (setvar 'CLAYER "S - TEXT") (command "CMLEADERSTYLE" "NORMAL - SW") (setvar 'CMDECHO 1) (initcommandversion) (command ".MLeader" ins endPoint "") (while (> (getvar "CMDACTIVE") 0) (command PAUSE)) (setq mleaderObj (vlax-ename->vla-object (entlast))) (vla-put-TextString mleaderObj textString) (setvar 'CMDECHO 0) (command "CMLEADERSTYLE" "Normal") (command "_.LAYER" "_SET" curlay "") (command "_.undo" "_end") (setvar 'CMDECHO 1) (princ "MLeader with SW_LENGTH created.")) (alert "Insertion point not specified!"))) (alert "SW_LENGTH attribute not found!"))) (alert "Selected entity is not a block!")) (princ))
  18. Our surveyors have asked me to create a calculation interface. I wanted to create a lisp program with an interface where the surveyors could input their measurements. They typically measure the ground level of a sewer pit and then the depth of the sewer pipes. To get the level of the sewer pipes, they subtract the ground level from their measurements. However, I have some difficulties getting the interface to function. I came across code by Lee Mac and attempted to build upon it. My code is half in Dutch, 'MV' stands for Ground Level. I've attached a screenshot of my current progress. The issue is that the second calculation isn't being displayed. I would also want my outputs to have 2 decimals. lisp code: (defun c:test ( / *error* dch dcl des mv wid diepte) (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:\";" " }" " : ed" " {" " key = \"wid\";" " label = \"Width:\";" " }" " : ed" " {" " key = \"diepte\";" " label = \"A:\";" " }" " : row" " {" " : ed { key = \"res\"; label = \"BOK:\"; is_enabled = false; }" " : ed { key = \"res2\"; label = \"BOK2:\"; 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 "wid" "(setq wid $value)") (action_tile "diepte" "(setq diepte $value)") (action_tile "cal" (vl-prin1-to-string '( (lambda ( / x y z) (set_tile "res" "") (set_tile "res2" "") (cond ( (or (not mv) (= "" mv)) (alert "Please enter a maaiveld value.") (mode_tile "mv" 2) ) ( (or (not wid) (= "" wid)) (alert "Please enter a width value.") (mode_tile "wid" 2) ) ( (or (not diepte) (= "" diepte)) (alert "Please enter a a value.") (mode_tile "diepte" 2) ) ( (not (setq x (distof mv))) (alert "Het Maaiveld moet een getal zijn.") (mode_tile "mv" 2) ) ( (not (setq y (distof wid))) (alert "The width must be numerical.") (mode_tile "wid" 2) ) ( (not (setq z (distof diepte))) (alert "The diepte must be numerical.") (mode_tile "diepte" 2) ) ( (<= x 0.0) (alert "Het maaiveld moet groter dan nul zijn.") (mode_tile "mv" 2) ) ( (<= y 0.0) (alert "The width must be greater than zero.") (mode_tile "wid" 2) ) ( (<= z 0.0) (alert "The width must be greater than zero.") (mode_tile "diepte" 2) ) ( (set_tile "res" (rtos (- x y) 2))) ( (set_tile "res2" (rtos (- x z) 2))) ) ) ) ) ) (start_dialog) ) ) (*error* nil) (princ) ) If I manage to fix this then I will try to make a leader with the outputs.
  19. Hello all, I should get the following code changed so that you can select the blocks you want to 'undynamic" first. Can somebody help me? (defun c:UnDynamic ( / _get_item _right _make_key _dynamic->static_block _get_locked _get_dynamic_inserts _main ) (defun _get_item ( collection key / item ) (vl-catch-all-apply '(lambda ( ) (setq item (vla-item collection key))) ) item ) (defun _right ( str n / len ) (if (< n (setq len (strlen str))) (substr str (1+ (- len n))) str ) ) (defun _make_key ( collection prefix len / key ) ( (lambda ( i pad ) (while (_get_item collection (setq key (strcat prefix (_right (strcat pad (itoa (setq i (1+ i)))) len ) ) ) ) ) key ) 0 ( (lambda ( pad ) (while (< (strlen pad) len) (setq pad (strcat "0" pad)) ) pad ) "" ) ) ) (defun _dynamic->static_block ( blocks insert len ) (vla-ConvertToStaticBlock insert (_make_key blocks (strcat (vla-get-EffectiveName insert) "_00") len) ) ) (defun _get_locked ( layers / locked ) (vlax-for layer layers (if (eq :vlax-true (vla-get-lock layer)) (setq locked (cons layer locked)) ) ) locked ) (defun _get_dynamic_inserts ( blocks / inserts ) (vlax-for block blocks (vlax-for object block (if (eq "AcDbBlockReference" (vla-get-objectname object)) (if (eq :vlax-true (vla-get-isdynamicblock object)) (setq inserts (cons object inserts)) ) ) ) ) inserts ) (defun _main ( document / blocks inserts locked len ) (if (setq inserts (_get_dynamic_inserts (setq blocks (vla-get-blocks document)) ) ) (progn (foreach layer (setq locked (_get_locked (vla-get-layers document))) (vla-put-lock layer :vlax-false) ) (setq len (strlen (itoa (length inserts)))) (foreach insert inserts (_dynamic->static_block blocks insert len) ) (foreach layer locked (vla-put-lock layer :vlax-true) ) ) ) (princ) ) (_main (vla-get-activedocument (vlax-get-acad-object))) ) Credits to TP from theswamp.org. Thanks, Martin.
  20. Hi everyone, I need to modify some options in the "Automatic Publish" submenu through a lisp or if not possible through a script, in detail I should modify the "Type" section from the "Multi-sheet" file to "Single-sheet file" and vice versa does anyone know if it's possible? Many thanks in advance
  21. Hi experts , good morning and happy good fryday. Hope you're doing well, I'm looking for a lisp routine which can generate blocks considering some logic.. i have attached a AutoCAD.dwg file pls help.. LISP MAKING.dwg
  22. 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
  23. I am a CAD Drafter and Land Surveyor and one of my main job is to plot my surveyed poles. However the standard is to have all the poles perpendicular to the road or to a polyline. Is there a lisp to do that? Here is a sample of what I am doing. The top most pole is what It should look like. I have around 1000 poles to rotate perpendicular and is time consuming. Can anyone help me.
  24. I am quite busy, of course, like everyone, I have loads of work needing to get done so I thought I would make this quick post. Hopefully someone with the available time can help out! I basically need a simple routine to change colors from our old standards to our new standards. I am sure it is most likely the simplest routine but if someone could post one and save me a little bit of time I would appreciate it. An example would be layer: TEXT, which with our old standards for 30+ years has been the 'GREEN', we have now changed that and are using color '104' which is more of a turtle green, anyways thats what the boss wants so that's what the boss gets. Currently when we open a drawing that was drawn, say, 10 years ago, it has all of our old layers and their respective old colors. I just need a lisp that would run every time we open a drawing for editing or revisions that would automatically search for the layers and change their properties (colors)..
  25. Do anyone have similar program?? I have attached the vlx file also its showing trail expired.. CPP-Ver2 - Type Region (Gap input)-2023 (1).VLX
×
×
  • Create New...