Jump to content

Search the Community

Showing results for tags 'autolisp'.

  • 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. Please, someone help me. I thought my program was in its final stages, but it is not. I used AutoCAD 2002 and 2007 during development, but when I tried to install it in AutoCAD 2021, this happened (see the picture). It prompts as if I need to edit the attributes one by one. Also, how can I eliminate the automatic prompts in the command line made by AutoCAD, while keeping the programmed prompts within the AutoLISP? (defun c:nancsv ( / fname dummy pts newline blockName height x y base-point auto-numbering num) (princ "\nImport CSV/Text File by: Nan Glase (2025-01-04)") ; (princ "\nEnter \"NANCSV\" to run.") ; (defun csv->lst ( str / pos ) (if (setq pos (vl-string-position 44 str)) ; (cons (substr str 1 pos) (csv->lst (substr str (+ pos 2)))) ; (list str) ) ) ; Set the block name (setq blockName "Nan Glase") ; Prompt for text height (setq height (getreal "\nEnter text height [0.60]: ")) ; Prompt for text height ; If the user presses Enter without input (height is nil), set the default value to 0.60 (if (not height) (setq height 0.60) ) ; Apply the formula (value entered / 2) (setq height (/ height 2)) ; Divide the height by 2 ; Define acceptable inputs for Yes and No (setq yes-options '("" "Y" "y" "Yes" "yes" "YES")) (setq no-options '("N" "n" "No" "no" "NO")) ; Prompt for automatic point numbering in a loop until valid input is given (setq auto-numbering nil) (while (not (or (member auto-numbering yes-options) (member auto-numbering no-options))) (setq auto-numbering (getstring "\nAutomatic point numbering? (Yes/No): ")) ) ; Start numbering from 1 if automatic numbering is enabled (if (member auto-numbering yes-options) (setq num 1) (setq num nil) ; Set num to nil if automatic numbering is not enabled ) ; Open the CSV file (setq fname (open (getfiled "Import CSV/Text File" "d:\\" "csv;txt" 16) "R")) (setq dummy (read-line fname)) ; ; (while (setq newline (read-line fname)) (setq pts (csv->lst newline)) ; ; If automatic numbering is enabled, modify the first element in pts (if num (setq pts (cons (itoa num) (cdr pts))) ; ) ; Extract coordinates from the list (setq x (atof (nth 2 pts))) ; X coordinate from CSV (setq y (atof (nth 1 pts))) ; Y coordinate from CSV (setq base-point (list x y)) ; Create the base point list ; Insert the block reference with the specified base point (command "-insert" blockName ; base-point ; Use the base point defined above height ; Scale X (use the calculated height) height ; Scale Y (use the calculated height) 0 ; Rotation (nth 0 pts) ; column A from CSV (last pts) ; column E from CSV (nth 3 pts) ; column D from CSV ) ; Increment the number for the next point if automatic numbering is enabled (if num (setq num (1+ num)) ) ) ; Close the file after processing (close fname) ; Close the file ; Notify user that the process is complete (princ "\nProcess completed successfully!") ; Completion message (princ) ; End of the function ) ; (princ "\nImport CSV/Text File by: Nan Glase (2025-01-04)") (princ "\nEnter \"NANCSV\" to run Import CSV/Text File.") Nan Glase.dwg
  2. Need help. how to maintain 3 decimal places even with zeros like in the picture? (defun c:nanpt () (vl-load-com) (princ "\nStakeout Point by: Nan Glase (2024-12-24)") (princ "\nEnter \"NANPT\" to run.") (setq points '()) (setq polyline nil) ; Variable to hold the polyline object ;; Start the polyline command (command "_.PLINE") (while t (setq pt (getpoint "\nSelect a point (or press Enter to finish): ")) (if (null pt) (progn ;; Finish the polyline if at least one point was selected (if (> (length points) 0) (progn (command "") ; End the polyline command (setq polyline (entlast)) ; Get the last entity created (the polyline) ;; Save points to a file (setq data '()) (setq i 1) (foreach p points (setq line (strcat "S" (itoa i) ", " (rtos (cadr p) 2 3) ", " (rtos (car p) 2 3) ", 0")) (setq data (append data (list line))) (setq i (1+ i)) ) (setq formattedData (apply 'strcat (mapcar (function (lambda (x) (strcat x "\n"))) data))) (setq tmpfile (vl-file-syst-write (strcat (getenv "TEMP") "\\Nan_stakeoutpoint.txt") formattedData)) (startapp "notepad.exe" tmpfile) ) (princ "\nPlease select at least one point before finishing.") ) (if polyline (progn (command "_.ERASE" polyline "") ; Erase the polyline (setq polyline nil) ; Clear polyline reference ) ) (setq points nil) ; Clear points list ) (progn ;; Append the point to the list (setq points (append points (list pt))) ; Store the point directly (command pt) ; Add the point to the polyline ) ) ) (princ) ) (defun vl-file-syst-write (filename content) (setq file (open filename "w")) (if file (progn (write-line content file) (close file) (princ (strcat "\nData has been written to Notepad. " filename)) ) (princ "\nError opening file for writing.") ) filename ) (princ "\nStakeout Point by: Nan Glase (2024-12-31)") (princ "\nEnter \"NANPT\" to run.")
  3. please help me write a code. i have csv file contains point, northing, easting, elevation, description. i also have a drawing file that has attributes-point,description,elevation. this drawing file is in a support file search path. i want to make an autolisp that import csv data into autocad. The northing and easthing will be the location of the point. NANCSV.DWG SURVEY POINTS.csv
  4. I got this code from chatgpt, that chatgpt got from a defunct post from autocad website forums. Whenever I tried going to the website or googling, the link seems broken so I don't know how this code exactly works. I am trying to make a Lisp that creates dimstyles from scratch. everything is working except for changing between annotative and non annotative. The code below does a good job of setting the created dimension style to annotative. But when I ask chat gpt to make it in reverse, i.e. make a code that makes the created dimstyle non annotative, it can't. (defun set-dimstyle-annotative (dimstyle-name / ent entdata xdata) ;; Ensure the dimension style exists (if (and (setq ent (tblobjname "dimstyle" dimstyle-name)) (setq entdata (entget ent))) (progn ;; Check if XData for "AcadAnnotative" exists (if (not (assoc -3 entdata)) (progn ;; Add XData to set the dimension style as annotative (setq xdata '((-3 ("AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) ; Version number (1070 . 1) ; Annotative flag: 1 = Yes, 0 = No (1002 . "}") ) ) ) ) ;; Apply the XData to the dimension style (entmod (append entdata xdata)) (princ (strcat "\nDimension style '" dimstyle-name "' set to annotative.")) ) (princ (strcat "\nDimension style '" dimstyle-name "' is already annotative.")) ) ) (princ (strcat "\nDimension style '" dimstyle-name "' not found.")) ) (princ) ) Basically when a dimstyle is created, I put this at the end of the code to make it annotative. However, after making an annotative dimstyle, I can make a dimstyle, but because the previous was annotative, I cannot set the new dimstyle to non annotative. Chat gpt gave me a code but it seems it just butchered the code and it doesn't work. I attached the lisp file. Thanks!! DimStyles.lsp
  5. 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
  6. It's a bit complicated for me to explain this. In this case, numbers should be selected and moved to the nearest point or vertex, and when moved, the text should not intersect any lines or polygons. Moving isn't that much of a problem, but the latter is. My idea is to create a rectangle around the text using the TCIRCLE function and then move the rectangle along the edge of the circle (where the center of the circle is the moving point) of some radius until it is not intersected by lines, if there is no such place then the radius increases by some value, it doesn't matter which one. Anyway, maybe I'm asking to much let me know guys if you have a suggestion. THANKS
  7. Hello, This question is in reference to AutoLisp, but the specific CAD version this is used for is MicroSurvey CAD 2020. We are running into an issue where the PRINT dialog coordinates are completely different than the real coordinates reported by AutoLISP and the objects properties in CAD. As an example, on one drawing, the coordinate of the bottom left of a box is (606625.433, 4841479.138), however this coordinate is reported by the print dialog to be (4207152.580, 2471093.689). This means when the automatic print functions calculate the box coordinates, they rightly get the bottom left of the box to be at (606625.433, 4841479.138), but this is not correct for the print dialog resulting in the print not even capturing any part of the drawing. The drawing is a 2d flat image on the top face, and the main bounding box of the drawing is not aligned with the x/y axis. I initially assumed this was an issue between model and paper space, but the coordinates seem large enough that the paper-space ones do not make sense. If anyone has experience with this sort of coordinate issue please let me know. I can share more information if needed.
  8. Hi, This is my first after so many days using this site. my block have multiple attributes for different types of lengths and one(DUCT_ID) attribute for sequence. i want to link objects length to block attribute(its a field)(MICRODUCT) by using TAG(DUCT_ID). HOW IT WORKS. command to select the objects then ask for DUCT_ID. then link the selected objects to MICRODUCT. i'm using lee mac length2 field for now. but in this lisp you have to select the block manually. but blocks our drawing usually in different location initially for easy to work. thanks in advance.
  9. I found autolisp code on this forum with the function of inserting multiple blocks at the center point circle. Can anyone help me to make a code like this but with function to inserting multiple blocks (Attribute Blocks) at the geometric center of a closed polyline Thank you This is the code for inserting multiple blocks at the center point circle : BlockOnCircle.lsp
  10. 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.
  11. Hello everyone, can anyone help me, I have a case example that is almost similar to the actual case I am experiencing now. In the 1st picture I have a shapefile of the administrative boundaries of the United States that I have entered into autocad, the shp attribute has been entered into the data object of each feature with the data object name "GADM", in the data object there are State and County fields, for the layer of each feature I use the County field reference so that each feature is currently layered with its respective county name. what I want is that as in the 2nd picture I want each feature to be grouped or made per block per category of state, is there a quick way, because I think in each feature there is a State field? Noted: The Autocad that I use is AutocadMap 2021. Pic 1 Pic 2
  12. I have one AutoLISP to insert Dynamic Blocks containing Attributes. With this AutoLISP I can select the Value Attribute via the List DCL. I can insert Dynamic blocks wherever I want. The problem is, I want to use this AutoLISP by inserting dynamic blocks simultaneously at the midpoint of the line. what should I do? can anyone help me Thank You
  13. Hi, I tried to write an autolisp code and I got to a certain point, but it is not working as I wanted. I would like your suggestions and your support in revising the code. What I want to do is select a block. To find out which character (n) from the right is the "-" sign in the layer name of the line touching the block I selected. Then subtract 1 from this character(n) number and add n-1 from the right. Combining the part up to the character and the prefix text and writing to the block geometric point. The way this code works now is to combine the front text and the text to the right of the "-" sign of the last layer added to the layer list and write it to the center of the block. This wasn't something I wanted. (setq *textHeight* 8) (setq *layerName* "01 Equipment list 2") (setq *textColor* 1) ; (defun c:bs_ayar () (setq *textHeight* (getreal "\nEnter new text height: ")) (setq *layerName* (getstring "\nEnter new layer name: ")) (setq *textColor* (getint "\nEnter new color index (1 for Magenta): ")) (princ (strcat "\nText height is now " (rtos *textHeight*) ", layer name is " *layerName* ", color is " (itoa *textColor*) " was set to. ")) (princ) ) (defun c:bs4 () (setq prefix (getstring T "\nEnter prefix letter: ")) (setq blk (car (entsel "\nSelect Block: "))) (setq blkEnt (entget blk)) (setq insPt (cdr (assoc 10 blkEnt))) (setq ss (ssget "_X" (list (cons 0 "LINE,POLYLINE")))) (if (and ss (> (sslength ss) 0)) (progn (setq line (ssname ss 0)) (setq lineEnt (entget line)) (setq lineLayer (cdr (assoc 8 lineEnt))) (setq dashPos (vl-string-search "-" lineLayer)) (if dashPos (setq rightPart (substr lineLayer (+ dashPos 2))) (setq rightPart lineLayer) ) (command "._-LAYER" "_M" *layerName* "" "_C" *textColor* "" "") (command "._TEXT" insPt *textHeight* "" (strcat prefix rightPart)) (command "._-LAYER" "_S" *layerName* "") ) (princ "\nNo line or polyline was found touching the selected block.") ) (princ) )
  14. Hello, I have a lisp code that I have been working on and I have brought it to a certain stage. However, I am having a problem at one point. In this lisp code, I have a product list with my purpose defined. When the code runs, my product list is listed in the pop-up window. And I choose what I want and paste it to the places I specify on the screen. However, my product list can be up to 500 items, so I created a search button in the popup window. The button works, but it is based on the line number I choose, not the product name I choose, and it writes the product on this line number in the general list to the screen. I need support on how to overcome this problem. main command (defun C:prdef (/ dcl_id product_list product filter_list pt index) (create-layer "00-Equipment List" 3) ; Number 3 is used for green color (setq product_list '("Product-1" "Product-2" "Product-3" "Product-4" "Product-5" "Product-6" "Product-7" "Product-8" "Product-9" "Product-10" "Product-11" "Product-12" "Product-13" "Product-14")) (setq dcl_id (load_dialog "product_select.dcl")) (if (not (new_dialog "product_select" dcl_id)) (exit) ) (start_list "product_list") (mapcar 'add_list product_list) (end_list) (action_tile "search_box" "(progn (setq filter_text $value) (update_list filter_text))") (action_tile "product_list" "(setq product (nth (atoi $value) product_list))") ; (action_tile "ok" "(done_dialog)") (action_tile "search_button" "(update_list filter_text)") ; (start_dialog) (unload_dialog dcl_id) (initget 1) (while (setq pt (getpoint "\nChoose a location (exit with ESC): ")) (setq index (atoi product)) ; (command "_.-layer" "_S" "00-Equipment List" "") ; (command "_.text" pt default-text-height 0 product) ; (command "_.-layer" "_S" "0" "") ; ) ) ; List update function (defun update_list (filter_text / filtered_list) (setq filtered_list (if (= filter_text "") product_list (vl-remove-if-not '(lambda (x) (vl-string-search (strcase filter_text) (strcase x))) product_list ) ) ) (start_list "product_list") (mapcar 'add_list filtered_list) (end_list) (set_tile "product_list" "") ) In my dcl code as follows product_select : dialog { label = "Product Select"; : edit_box { key = "search_box"; label = "search"; width = 40; } : button { key = "search_button"; label = "search"; is_default = true; } : list_box { key = "product_list"; multiple_select = false; fixed_width = true; width = 40; } ok_cancel; }
  15. Is there any chance of matchline automation using lisp in layout? I have attached sample dwg and screenshot of block for matchline. Please help. And thanks in advance. SRS.dwg
  16. Dears, AUTOLIPS works on the english version but i want to use it on the frensh version, any kind of support Thanks
  17. Hi There, I'm trying to make various custom tools that deal with clicking on bearings, but sometimes these text entities might be enclosed by brackets, and so I need to filter those out in a lot of my routines. So I figured, let's make a separate routine that I can load when called instead of copy pasting this a bunch. (My initial thought was to use on_start.lsp (acad.lsp), but I think load is the correct thing to do here?) I guess the problem is that in some instances I'd like to set a flag if brackets were removed or not, so that I can put them back on (or not). I'm not too sure if there is such a thing as overloading in AutoLisp, but if someone could point me to what the preferred equivalent method would be that would be appreciated. I've vaguely read about parsing lists as args, but I thought I should ask here just to confirm before I make any fundamental mistakes. Cheers,
  18. Can we extend inside polylines and Trim outside polylines to selected polyline boundary. See the attached Image
  19. 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 ??
  20. Hello everyone, I was just wondering how you guys organize your LISP routines. I currently have a file structure that looks like this. \AutoLisp ----\lib --------\libs --------\...All My Lee-Mac files, thanks LEE :D --------\lisp-loader.lsp (basically loads all the LEE-MAC routine so that I can use it in my LSP) ----\LM_functions --------\...basically other Lee-Mac functions that are way too big by themselves. ----\MA_functions --------\...my functions basically ----\NUMCOUNT.lsp (my own version of numeric counting for blocks, and multileaders) ----\...other projects basically ----\MA-load-lisp.lsp (loads my MA_functions) Basically, for every major project that I have, by themselves without external loading of scripts that I use, the lsp file reaches thousands of lines of code. Also, this way, the codes are easier to manage and can be verified individually. In each project, I start with: (vl-load-com) (load (findfile "lisp-loader.lsp")) (load (findfile "MA-load-lisp.lsp")) Looking at MA-load-lisp, here's what it looks like: (defun MA-load-lisp (/ lisp lisppath lisplist count) (setq lisppath "~~AutoLISP\\MA_functions\\") (setq lisplist (vl-directory-files lisppath "*.lsp" 1)) (setq count (length lisplist)) (foreach lisp lisplist (if (load (strcat lisppath lisp)) (princ (strcat lisp " has been loaded.\n")) (princ (strcat lisp " didn't load.\n")) ) ;end if ) ;end foreach (princ (strcat "There are " (itoa count) " pre-loaded scripts from " lisppath ".\n") ) (princ) ); end function (MA-load-lisp); and, run this function the ~~ at the 2nd line is just short for C:\\---- to wherever the folder is. However, here's the deal, whenever I load the scripts using APPLOAD, AutoCAD 2020 prompts a security check for each of the files. I already have this folder \AutoLISP in the Support File Search Path and Trusted Locations in the Options Menu of AutoCAD. I can't seem to find a way to get around this. Do I need to digitally sign each lsp file?
  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. LEGEND.LSP Hi anyone can modify the code so it can create legends for both and linetypes with their layer name in description. It's a lee mac's program which creating legend in model space. If by touching the viewport it can make legend at layout whatever showing in the viewport it will be a great help.
  23. 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
  24. to this...I have so many data and need to make this type of drawing can anyone suggest lisp or script to make the drawing possible easily...POP to POP will get connected by different GP. Thanks in advance
  25. I'm trying to make an annotative text style that matches orientation. I've got this so far: (entmakex '( (0 . "STYLE") (100 . "AcDbSymbolTableRecord") (100 . "AcDbTextStyleTableRecord") (2 . "My TEXT3") (70 . 0) (40 . 0.09375) (41 . 1.0) (50 . 0.0) (71 . 0) (42 . 0.0) (3 . "romans.shx") (4 . "") (-3 ("AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) (1070 . 1) (1002 . "}") ) ) )) The last bit obviously turns on annotative but I can't find where I might enable the orientation match. Is there more xdata I can add to enable this?
×
×
  • Create New...