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. 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
  2. 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
  3. 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
  4. 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.
  5. (defun c:deleteCirclesByDiameter () (setq f 0.5000) (setq ss (ssget "_X" '((0 . "CIRCLE")))) (if ss (progn (setq index 0) (repeat (sslength ss) (setq ent (ssname ss index)) (if ent (progn (setq diameter (cdr (assoc 40 (entget ent)))) (setq dia (* diameter 2)) (prompt (strcat "\nCircle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4))) (if (and (> x f) (< dia x) (not (= dia 0.6875 x 0.75)) (not (= dia 0.6880 x 0.75))) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) ) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4))) ) ) ) (setq index (1+ index)) ) ) ) (prompt "\nCircles with diameter less than x have been deleted.") ) (prompt "\nNo circles found in the drawing.") ) (princ) ) In this code, help me to fix my mistakes in if conditions..
  6. This lisp can only run with CAD 2007, please edit it to run with higher generation AutoCAD (2021..). thanks chialo.lsp
  7. Is there a method to update blocks and nested blocks (dynamic and/or annotated without losing their position, visibility status, and annotated values: Tag/prompt/default values) based on new blocks that will contain in a folder (source files)? New blocks have the same block name as old ones. The cad block files within the "source" folder have the same name as the old block. Dynamic blocks have stretch or rotation properties, example: block is stretched to 2100mm and rotated to 30 degrees. 1) is it possible to obtain this kind of sophistication? 2) How would I run this routine without opening the drawing and that select the drawing files? Thanks
  8. Not quite sure how to tackle this, because my options on the -mapimport is very limitted and did not completely understand ADE_ function library. When I use the dialouge box of mapimport, I do get options of "creating object data" in addition to "creating points as blocks" with the option of "getting attribute values from field". So I simply create a block and define attributes with the TAG to match the the "Attribute Table" from QGIS and everything works as it should - that is I now have blocks that show the values for each block because I selected "Get attribute values from field" on Mapimport dialouge box. Can it be possible to have a routine that automate this process to 0) select a folder that contains multiple shape files and not selected one by one 1) import the map (lines and points) 2) lines and maps to be imported with their respected Object data 3) dynamic blocks be inserted that contain attributes to show the OD values at each imported points 4) visibilities of the blocks change with values/ attributes (example: if value is Hydro then visibility A and if Telecom then visibility B)? so here on this code, I am selecting a folder and then reading the content (shape files), but then I cannot go further because -mapimport did not give me all the options needed. also Block_1 and Block_2 are just examples of a block/ currently with no visibility for the conditions stated above. I do not work with Map3D all that often so help is appreciated! ( (lambda ( / path);lstall lstseluser (defun BrowseForFolder ( / sh folder folderobject result) (vl-load-com) (setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application")) (setq folder (vlax-invoke-method sh 'BrowseForFolder 0 "" 0)) (vlax-release-object sh) (if folder (progn (setq folderobject (vlax-get-property folder 'Self)) (setq result (vlax-get-property FolderObject 'Path)) (vlax-release-object folder) (vlax-release-object FolderObject) result ) ) ) (if (null (setq path (BrowseForFolder))) ;; just in case you didnt specify a path nil (setq lstall (vl-directory-files path "*.shp" 1))) ;---------------------------------------- ;; msg - [str] Dialog label ;; lst - [lst] List of strings to display ;; bit - [int] 1=allow multiple; 2=return indexes ;; Returns: [lst] List of selected items/indexes, else nil (defun LM:listbox ( msg lst bit / dch des tmp rtn ) (cond ( (not (and (setq tmp (vl-filename-mktemp nil nil ".dcl")) (setq des (open tmp "w")) (write-line (strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select=" (if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=15;}spacer;ok_cancel;}" ) des ) (not (close des)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "listbox" dch) ) ) (prompt "\nError Loading List Box Dialog.") ) ( t (start_list "list") (foreach itm lst (add_list itm)) (end_list) (setq rtn (set_tile "list" "0")) (action_tile "list" "(setq rtn $value)") (setq rtn (if (= 1 (start_dialog)) (if (= 2 (logand 2 bit)) (read (strcat "(" rtn ")")) (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")"))) ) ) ) ) ) (if (< 0 dch) (unload_dialog dch) ) (if (and tmp (setq tmp (findfile tmp))) (vl-file-delete tmp) ) rtn ) (if (not (= lstall nil)) (setq lstseluser (LM:listbox "Select one or more shape files (Ctrl or Shift):" lstall 1)) ) ;---------------------------------------- (if (not (= lstall nil)) (progn (alert (vl-prin1-to-string lstseluser)) ) ) ) )
  9. Good afternoon, One of our vendors has sent us several shp files with lines/polylines and ones with points. All the data comes in on a single layer, but I would like to sort the data with a LISP based on existing layers I've created and some of the Object data. Below is an example of the OD I want to use, and the layers I would like to have the objects sorted into. Could anyone help with some code that I could use to sort these objects? The OD table name will change depending on the file we receive, if that matters. Thanks
  10. I have some lisp / DCL code that allows me to pick a note from a lstbox and insert it as an MLEADER into the drawing. How should I format that note text in my code so that the fractions insert into the drawing as diagonally stacked fractions? I've tried 3#4 but it shows up just as written, not stacked diagonally Thanks for any help
  11. Here is an example of an array that needs to be worked on and I need an easy way to count the number of rows and columns. For example, I have 3 rows and 20 columns and I need to be able to select for multiple arrays.
  12. I am pretty new to lisp programming and have only been working in it for a few months and I am pretty stuck on how to get this lisp program I've hacked together into what I need. Any help would be greatly appreciated. I would like help optimizing the lisp to be more like autocad's save as an old dxf way of converting an ellipse to a polyline. The current way I am converting an ellipse to poly line is by moving a static degree of distance between each point, the way I cannot figure out and the ideal way for me to do this is by specifying the maximum gap between the true ellipse and the polyline version. I have looked at other lisp programs out there and they are not high resolution enough for what I need, I need the data to be extremely close to the actual ellipse. I would appreciate help in pointing me towards how to do this mathematically, help implement that into a lisp, and any tips on best practice lisp programming that I might be really messing up here. Below is the function I have written to handle this so far, it takes in el which is the vla ellipse object and angleIncrement which is the degree difference between two points of the polyline. In a perfect world the second argument would be changed to be the maximum distance between the true ellipse and the polyline version. This is a function used in another script that then chains the data and does a few other things as well. (defun EllipseToLine (el angleIncrement / majorradius minorradius startangle endangle startpoint endpoint centerpoint tempVar) (vl-load-com) (setvar "cmdecho" 0) (setq majorradius (vla-get-MajorRadius el)) (setq minorradius (vla-get-MinorRadius el)) (setq startangle (* (vla-get-StartAngle el) (/ 180 pi))) (setq endangle (* (vla-get-EndAngle el)(/ 180 pi))) (setq startpoint (vlax-safearray->list (vlax-variant-value (vla-get-startpoint el)))) (setq endpoint (vlax-safearray->list (vlax-variant-value (vla-get-endpoint el)))) (setq centerpoint (vlax-safearray->list (vlax-variant-value (vla-get-center el)))) (setq centerx (nth 0 centerpoint)) (setq centery (nth 1 centerpoint)) (princ "End angle: ")(princ endangle)(princ "\n") (princ "Start angle: ")(princ startangle)(princ "\n") (setq startx (nth 0 startpoint)) (setq starty (nth 1 startpoint)) (setq endx (nth 0 endpoint)) (setq endy (nth 1 endpoint)) ; make sure we convert the ellipse on the correct layer and then later return to the layer we were on (setq ellipseLayer (vla-get-layer el)) (setq currentLayer (getvar "clayer")) (setvar "clayer" ellipseLayer) ; calculate angle between start angle and start point because the start point ; is not at the start angle so we have to adjust so numbers match up (setq angleOffset (- (* (angle centerpoint startpoint) (/ 180 pi)) startangle)) (setq radianOffset (* angleOffset (/ pi 180))) ; a = major radius ; b = minor radius (setq ecc (sqrt (- 1 (/ (expt minorradius 2) (expt majorradius 2))))) (setq angleInverted 0) (setq done 0) (setq i 0) (setq currentAngle startangle) (setq nintyDegrees 90.0) (setq twoHundredSeventyDegrees 270.0) (while (= done 0) (if (< currentAngle 0) (progn (setq currentAngle (+ currentAngle 360)) (setq angleInverted 1) ) ) (if (> currentAngle 360) (progn (setq currentAngle (- currentAngle 360)) (setq angleInverted 1) ) ) (cond ((or (and (> startangle endangle) (= angleInverted 0)) (and (> endangle startangle) (= angleInverted 1))) (if (< currentAngle endangle) (setq currentAngle endangle) ) ) ((or (and (> endangle startangle) (= angleInverted 0)) (and (> startangle endangle) (= angleInverted 1))) (if (> currentAngle endangle) (setq currentAngle endangle) ) ) ) (setq newAngle currentAngle) (if (or (> newAngle 0) (< newAngle 0)) (setq newAngle (* newAngle (/ pi 180))) ) (setq factor -1) (if (or (<= currentAngle nintyDegrees) (>= currentAngle twoHundredSeventyDegrees)) (setq factor 1) ) ; using the origional un rotated angle get the next point on the ellipse (setq x2 (/ (* majorradius minorradius) (* factor (sqrt (+ (expt minorradius 2) (* (expt majorradius 2) (expt (/ (sin newAngle) (cos newAngle)) 2))))))) (setq y2 (* x2 (/ (sin newAngle) (cos newAngle)))) (setq x2 (+ x2 centerx) y2 (+ y2 centery) ) ; rotate point on the ellipse by radian/angle offset so it matches the cad data (setq rotatedx (+ (- (* (cos radianOffset) (- x2 centerx)) (* (sin radianOffset) (- y2 centery))) centerx)) (setq rotatedy (+ (+ (* (sin radianOffset) (- x2 centerx)) (* (cos radianOffset) (- y2 centery))) centery)) (setq x2 rotatedx y2 rotatedy ) (if (= currentAngle endangle) (setq done 1) ) (if (> i 0) (if (= i 1) (command "_.line" (strcat (rtos startx) "," (rtos starty)) (strcat (rtos x2) "," (rtos y2)) "") (if (= done 1) (command "_.line" (strcat (rtos x1) "," (rtos y1)) (strcat (rtos endx) "," (rtos endy)) "") (command "_.line" (strcat (rtos x1) "," (rtos y1)) (strcat (rtos x2) "," (rtos y2)) "") ) ) ) (setq x1 x2 y1 y2 ) (setq currentAngle (+ currentAngle angleIncrement) i (+ 1 i) ) ) ; delete the origional ellipse (vla-delete el) (setvar "clayer" currentLayer) (princ) )
  13. Hello, can anyone help me please with this topic? I have 9 layouts. I've inserted the same block to each layout. I want to change some attributes (the title of the drawing inside block) for each layout out of those 9. The Layout name is variable according to the number of project which I have at that moment (SCH 23-123_01 or SCH 23-125_01 for example), but the attribute values are always the same (for example "1 floor" for layout 1, and "section A-A" for layout 2 etc.) I'm newbie in AutoCAD LISP files, so I've tried something with ChatGPT, but it doesn't seems to work. (defun c:Updateattributes () ;; Define your block name and attribute tag (setq blockName "Pečat Marko Vukićević") (setq attributeTag "NAZIV CRTEŽA") ;; Define a list of attribute values corresponding to each layout (setq attributeValuesList '("OSNOVA JAME" "PRESECI VOZNOG OKNA" "OSNOVA VRHA VOZNOG OKNA I DETALJ MONTAŽNE KUKE" "DETALJ PRAGA VRATA" "TEHNIČKE SPECIFIKACIJE" "OSNOVA KABINE" "PRESECI OPREME I RASPORED KONZOLA" "PREGLED SIGURNOSNIH PROSTORA" "POGLED PRISTUPNIH STRANA")) ;; Start iterating through layouts (vlax-for (layout (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object)))) (vla-activate layout) ;; Check if the block exists in the layout (if (tblsearch "Pečat Marko Vukićević" blockName) ;; If the block exists, update the attribute value (progn (vla-get-active (setq pspace (vla-get-ModelSpace layout))) (vlax-for obj (vla-get-Block pspace) (if (= blockName (vla-get-Name obj)) (progn ;; Find the attribute reference (vlax-for attrRef (vlax-invoke obj 'GetAttributes)) (if (= attributeTag (vla-get-TagString attrRef)) ;; Update the attribute value from the list (vla-put-TextString attrRef (pop attributeValuesList)) ) ) ) ) ) ) ) (princ "\nAttribute values updated for all layouts.") (princ) ) I've asked Chat GPT also if special characters like "č" "ć" "š" "ž" is possible to have in LISP, and I've got the positive answer, but I'm not sure that is true. Can someone please verify me this information as well? If someone has slightest idea in which direction I should go, It would mean a lot to me. Thanks in advance! P.S. In the attached file there is a sample of my drawings. Also I would like to rename another attribute inside block to be the same as the layout name, but that is on another level. Demo.dwg
  14. Hello For a few days now I have been using the LISP made by Small Fish, LISP is very good, the only problem that it is causing me is that it does not highlight the points that I have selected and on some occasions I select the same point twice, I would appreciate it if you Please tell me a way to modify that. ThaEscrumbo1.LSPnk you
  15. Hi, there, im very new working with Autolisp, in the past i copy and paste code and use the lisp. Thanks to all the people who write this lisp. Now im learning how to code with lisp, i m reading books, developers guide and this forum. I need to understand how some commands works for use it in the lisp code. I cant find a description of how command works. For example (command "xref" "r"). But i know this command have more options, i need the description of the other options and how can i use it. (defun c:CircC () (command "._circle" "0,0" "3,3") (command "._thickness" 1) (command "._circle" PAUSE PAUSE) (princ) ) i want to know how circle command works "0,0" is the origin point "3,3" is for ??
  16. Hi guys, im looking for a quick way for change the dimension precision in multiple files. I need to change from 0.000 to 0.00 in multiple files. I dont want open each drawing and set the precision to 2 decimal. You know we look for the quick and less bored way of do things. Thanks
  17. Hi, I have thousands of drawings. They are all similar to This.dwg one. My final goal is to merge them into one kml file.. This would take months to do it one by one. If I have the right lisp to automate this in one drawing, then I can use script to run that lisp over other drawings. To reduce the result file size, I decided to keep only the green polyline in the center of the drawing(which matters the most): (defun C:foo ( / varf ins str) ; Selecting Polyline (setq varf (list '(-4 . "<OR") '(0 . "LWPOLYLINE") '(-4 . "<AND") '(0 . "POLYLINE") '(-4 . "<NOT") '(-4 . "&") '(70 . 80) '(-4 . "NOT>") '(-4 . "AND>") '(-4 . "OR>") (cons 62 3) ) ) (sssetfirst nil (ssget "_X" varf)) ; Inverting selection (if (ssget "_I") (progn; then (sssetfirst nil) (command "_.select" "_all" "_remove" (ssget "_p") "") (sssetfirst nil (ssget "_p")) ) (prompt "\nRequires pre-selection."); else ) ; Delete Selection (command "_.erase") ; And This is how I insert Drawing Name (and (or (> (getvar 'DWGTITLED) 0) (alert "Save the drawing then try again!") ) (setq ins (getpoint "\nChoose Insertion Point: ")) (setq str (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 10 (trans ins 1 0)) (cons 40 0.8);Text height (cons 7 "STANDARD");Text style '(1 . "") ) ) ) (vla-put-textstring (vlax-ename->vla-object str) "%<\\AcVar Filename \\f \"%tc4%fn2\">%}" ) ) ) Now these are what I'm looking for: - I don't want to pick the insertion point manually, need to insert field inside or over selected polyline - after inserting field text, I want to explode the text. to maintain drawing name after merge. - adding a condition to check the process, if anything goes wrong, insert that drawing name at (0,0,0). this way I can track that file to check it manually. Thank you in Advanced.
  18. Hello guys, would like to ask for your help that I'd like to have a lisp that can let me extract data from multiple lines which then the data can be exported into a txt file. Would like to export the angle of the line ( the angle extracted should be in the form of degree minute second), the distance and also the end point coordinate( Y & X) in this order. Thank you very much. I am struggling with this problem!
  19. Hi Is there any way to export all layers separately into pdf format? i want to export all of them at once to edit them in illustrator. It's taking alot of time to export them one by one from autocad I don't have any professional Experience with programming but i have tried to made this .lisp with chatGPT but it's not working to export files which property in codes needs improvements please (defun c:ExportLayersToPDF (\Users\Useer\Desktop\pdf layers) (setq dwgname "EMERALD HILLS MP (2007) 25 01 2023") ; (setq dwgpath "F:\Shahtaj Ahmed Bhutto\AUTOCAD") ; (setq layname "") (while (setq layname (tblnext "LAYER" layname)) (and layname (/= layname "0") (/= layname "DEFPOINTS") (/= (logand (cdr (assoc 70 (tblsearch "LAYER" layname))) 1) 1) (progn (setq pdfname (strcat dwgname "_" layname ".PDF")) (setq pdffullpath (strcat dwgpath pdfname)) (command "-plot" "Yes" "Model" "" "" "DWG To PDF.pc3" "A0" "PORTRAIT" "Inches" "Fit" "Center" "No" "No" "No" "Yes" "No" "No" "Yes" "Yes" pdffullpath) T ) ) ) (princ) )
  20. Hi! Avid reader of the forums, first time poster. I have a code with which I'm trying to extract the x and y coordinate of the startpoint of a line to the clipboard for pasting into another program. The problem is that when I run the lisp in Civil 3D it spits out when running (caddr typelst) on line 6 in the code below. What could cause this. I'm having trouble understanding why it wouldn't be able to grab the type from the list. The code: (vl-load-com) (defun c:copyx1y1 () (setq choice (entsel "Choose the line whose start X and Y you want to copy \n")) (setq entname (car choice)) (setq typelst (assoc 0 (entget entname))) (if (= (caddr typelst) "LINE") (progn (setq startpnt (assoc 10 (entget entname))) (setq x1 (cadr startpnt)) (princ "\n") (princ x1) (princ "\n") (setq y1 (caddr startpnt)) (princ y1) (setq copiedtxt (strcat (rtos x1) "\t" (rtos y1))) (setq result (vlax-invoke (vlax-get (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'SetData "Text" copiedtxt) ) (vlax-release-object htmlfile) copiedtxt ) (progn (princ "The choice is not of type LINE") ) ) (princ) ) Regards, E
  21. Hello guys, I am working in AutoCAD. I am looking for a combined LISP code for creating points for the selected objects at its Endpoints, Midpoints, Center, Geometric center, Node, Quadrant, Intersection & Insertion as per users requirements (options with drop down list mentioning Endpoints, Midpoints, Center, Geometric center, Node, Quadrant, Intersection & Insertion Shall get prompted.) Once I select the required snap then the result shall be creation of points at the chosen object snap. An imaginary Example shall be Like like this, command: POBS(Points at Object Snap)-->prompting for what snap need to be found in the selected objects in the for of drop down list--> Creating points in the selected Object Snaps of the selection set. Actually i had found few LISP codes for the following cases 1.PLE-Points on Line Ends.lsp 2.PAI-Point At Intersection.lsp Thanks for the authors of these above LISP they have saved lot of time till date. Thanks in advance.
  22. Hello guys, I am new to this forum. I need LISP for Selection of alternate lines from the selection set of lines like 1st, 3rd, 5th, .....etc lines in Autocad. I am attaching the file with my requirement. Alternate Selection of lines.dwg Please help me out with an possible lisp solution. Also, Is there a Autocad Plugin to do this? If so Please share the link Thanks in advance, Pranesh Rathinam
  23. Subidoooo

    ADVICE NEEDED

    Hi Guys I have a .dwt with all of my custom blocks, leaderstyles, dimstyles and textstyles. i have allot of custom lisp files that generates custom styles and leaders using my styles that i have set up in my .dwt file. I have found that if i work on a drawing from another person and i want to use my "custom" lisp commands i have to drag in my styles via design center. is there a way of adding these styles automatically from my .dwt into the current drawing via lisp? then i can just edit my lisp files to include this instead of dragging in styles from my own template file?
  24. Dear team , I used etransmit command >add file than bind xref option, but not bind in current drawing. Is any tools or lisp, VBA macro for add multiple xref and bind together in current file and save as a zip file.? Note :, Xref not attached in current drawing. I need to attach multiple and bind together in current drawing. Thanks
  25. So i make some lisp-cover them to fas. Put all in 1 folder and make 1 mnu file that load with menuload and load all that lisp. But now i want put that in USB and when i load it to autocad, whatever i click in any lisp i want password showup then when i enter password i can use all fuction of it. Every time i open autocad and use them i need reenter password. Any change i can make that?
×
×
  • Create New...