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. 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. 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
  3. 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.
  4. 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.
  5. 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
  6. 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.
  7. 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
  8. 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
  9. 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) )
  10. 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; }
  11. 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
  12. Dears, AUTOLIPS works on the english version but i want to use it on the frensh version, any kind of support Thanks
  13. 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,
  14. Can we extend inside polylines and Trim outside polylines to selected polyline boundary. See the attached Image
  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. 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?
  17. 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.
  18. 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.
  19. 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
  20. 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
  21. 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?
  22. Hi there, I'm AM and new to the forum I'm creating a set of easy lisp routines for my team. I've loaded the following lisp file into AutoCAD and it works fine when typing the function ColorOffsetV031 into the command line within AutoCAD. However, when I try create a new command that will run the lisp with a macro like ^C^CColorOffsetV031 or ^C^C_ColorOffsetV031 so I can then add it to a ribbon/tab/tool palette, I get the following error: "_ColorOffsetV031 Unknown command "COLOROFFSETV031". Press F1 for help." I'm honestly not sure what I'm doing wrong. I've tried different ways of loading the lisp file, from just dropping the file into AutoCAD, adding it to the Startup Suite, loading it as an application etc. I've created 'buttons' like this before, and I feel so silly asking such a simple question; It's probably something really simple that I just can't pick up on... Even if someone can point me in the direction of a related post from someone else I would be very grateful The lisp: ; Define the tool/function name and variables (defun C:ColorOffsetV31 ( / EName EInfo EColor Group ans ansColor) (setvar "CMDECHO" 1) ; Set the options for user choice (initget "Orange Red Yellow Green Cyan Blue Magenta White L-Grey") ; Ask for user input on color for offset (setq ans (cond ((getkword "\nChoose offset object color [Orange/Red/Yellow/Green/Cyan/Blue/Magenta/White/L-Grey] or ENTER for Orange")) ("Orange"))) ; Set ansColor as input color (cond ((= ans "Orange") (setq ansColor 30)) ((= ans "Red") (setq ansColor 1)) ((= ans "Yellow") (setq ansColor 2)) ((= ans "Green") (setq ansColor 3)) ((= ans "Cyan") (setq ansColor 4)) ((= ans "Blue") (setq ansColor 5)) ((= ans "Magenta") (setq ansColor 6)) ((= ans "White") (setq ansColor 7)) ((= ans "L-Grey") (setq ansColor 8)) ; Should not happen but just here incase no input is given, set ansColor to BLACK (t (setq ansColor 250)) ) ;----------------------------- ; Start OFFSET (command "OFFSET" pause) ; Do the following with OFFSET (while (= 1 (logand 1 (getvar "CMDACTIVE"))) (command pause) ; While OFFSET command is on (while (= 1 (logand 1 (getvar "CMDACTIVE"))) (command pause) ; Set the current entity to be used as the last clicked entity (setq EName (entlast)) ; Get entity info (setq EInfo (entget EName)) ; If the colour of the object isn't known (if (not EColor) ; Match ans to EColor (setq EColor ansColor) ) ; Change the colour (entmod (append EInfo (list (cons 62 EColor)))) ) ) (setvar "CMDECHO" 0) (princ) ) Here's a copy of the command itself too Thanks, AM
  23. I have a drawing that has two different blocks (see attached), what I needed to do was transfer over the attributes of one block over to the other (both have different tags). For example copying over attributes in "rev0_date" from the first block tag over to "revslot1date" in the second block tag , I ran across some code in the forums that did just that created by Lee Mac.The problem with it is it only transfers one attribute over, I modified it a little but its still not exactly what I need. The way it currently works is - It asks me to choose the first block with the attributes to copy, once selected it then asks me to choose the second block that will have the attributes pasted to it, once I've selected them, it then pastes the first specified tag attribute in the first block to the second, after that I have to repeat the process again, clicking the block with the attribute to copy and then choosing the second block to paste, I have to keep repeating these steps, clicking the first block then the second over and over until all the tag attributes have been copied over. My question is how can I stop having click the first and then second block over and over again for each tag and instead only have to go through the process once (click first block, then second and then transfer all the attributes over at once). Here is my current code (sorry if its a mess I'm very new to this): (defun c:blockswap ( / _SelectBlockWithTag a b des src tag ) (vl-load-com) (setq DAT1A "Rev0_Date" ; Source Attribute Tag 1 DES1A "Rev0_Desc" ; Source Attribute Tag 2 REV1A "Rev0" ; Source Attribute Tag 3 RDB1A "Rev0_Drawn_By" ; Source Attribute Tag 4 REV1B "RevSlot1Number" ; Destination Attribute Tag 3 DES1B "RevSlot1Description" ; Destination Attribute Tag 2 DAT1B "RevSlot1Date" ; Destination Attribute Tag 1 RDB1B "RevSlot1DrawnBy" ; Destination Attribute Tag 4 ) (defun _SelectBlockWithTag ( tag / e a ) (setq tag (strcase tag)) (while (progn (setvar 'ERRNO 0) (setq f (car (entsel (strcat "\nSelect Block with attribute " tag ": ")))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, Try Again.") ) ( (not f) nil ) ( (and (eq "INSERT" (cdr (assoc 0 (entget f)))) (= 1 (cdr (assoc 66 (entget f)))) ) (if (not (setq z (vl-some (function (lambda ( x ) (if (eq tag (strcase (vla-get-tagstring x))) x) ) ) (vlax-invoke (vlax-ename->vla-object f) 'getattributes) ) ) ) (princ (strcat "\nBlock does not contain tag " tag ".")) ) ) ( (princ "\nInvalid Object Selected.") ) ) ) ) z ) (and (setq aa (_SelectBlockWithTag DAT1A)) (setq ab (_SelectBlockWithTag DAT1B)) ) (vla-put-textstring ab (vla-get-textstring aa)) (and (setq ba (_SelectBlockWithTag DES1A)) (setq bb (_SelectBlockWithTag DES1B)) ) (vla-put-textstring bb (vla-get-textstring ba)) (and (setq ca (_SelectBlockWithTag REV1A)) (setq cb (_SelectBlockWithTag REV1B)) ) (vla-put-textstring cb (vla-get-textstring ca)) (and (setq da (_SelectBlockWithTag RDB1A)) (setq db (_SelectBlockWithTag RDB1B)) ) (vla-put-textstring db (vla-get-textstring da)) (princ) ) drawing.dwg
  24. Hii all...I found a multiline polyline lisp from online, its gonna ask how many line and their offset distance...but its assigning layer automatically, can anyone do the changes so it will ask which layer I want to choose for my each line and it should automatically take the linetype as by layer...if I am choosing even no. of line, then the path I am drawing its automatically think that as center line and offset the distance, can anyone makes changes so it will make one line in my drawn path and ask me in which side I want to allocate how many line... multi line.lsp
  25. Hey, Can Anyone help by providing a lisp which will clear all the objects outside of my layout print in all the pages automatically.... please find attachment...I want to keep only object of only the white pages and remove other objects outside of that white space... Thank you in advance
×
×
  • Create New...