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 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
  2. 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) )
  3. 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; }
  4. 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
  5. Dears, AUTOLIPS works on the english version but i want to use it on the frensh version, any kind of support Thanks
  6. 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,
  7. Can we extend inside polylines and Trim outside polylines to selected polyline boundary. See the attached Image
  8. 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 ??
  9. 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?
  10. 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.
  11. 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.
  12. 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
  13. 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
  14. 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?
  15. 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
  16. 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
  17. 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
  18. 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
  19. Hi Guys, I Wanted To Mass Convert Some DWGs To DXFs, So, I looked Around and found some commercial softwares and also some lisp routine, but they didn't workout as i expected so i made a software (to interpret scripts). it works fine in converion of dxfs, so i thought this software might be usefull to some who want to mass convert dxfs, here is the software: AutoCAD Script Writer.zip This Software doesn't Require Installation, (It Runs Directly) ::REQUIREMENTS:: 1. AutoCAD which supports LISP routines (eG; full versions of AutoCAD 2010, But not AutoCAD LT Versions) ::Usage:: 1. In The "Location Of Files To Be Processed" Box, Paste The Location Where U have ur dwg files. (Default value is "D:\SomeFolder"). Dont Give A Root Location Such As "D:\" or "C:\" etc; 2. In The "Command" Box, The Default Code Is Written For DXF Conversion, U can modify and write ur own Macros here, (If U know Acad Scripting Language) 3. Pressing the "Create Script" Button will create a "Script.scr" file at the location of the dwg files 4. Now Open AutoCAD, Now Press [Control]+[N] In AutoCAD, A New Window will be opened 5. Now All U Have To Do Is Drag The "Script.scr", into the AutoCAD's Canvas (which is a blank black window usually) 6. And thats it, autocad will start converting the DWGs to DXFs Thanks To Lee-Mac, dbroada & Bill-Tillman for giving me the answer and idea to my previous post,
  20. My boss may have just asked for the impossible, but he wants a lisp to be able to window select multiple text then window select lines near the text, and have the text align to the line or polyline that is closest to the text. I have something that allows me to pick a line then a text, but I have no idea how to do this. Any help is greatly appreciated, this is way above my ability. The attached pictures show before and after.
  21. Greetings, I´m trying to extract and sum specific data attributes from blocks in my drawing. While Lee Mac's Global Attribute Extractor & Editor is excellent, I need some help with two minor modifications: 1. How to select a certain group of blocks of my interest (by indicating a window selection) and not the entire drawing? 2. My blocks have two attributes: CODE and AMOUNT. When running MacAtt, I get the data for every instance of the block that is found, like this: Is there a way to sum the amount of instances with the same attribute in CODE in order to get a shorter table like this? Any direction provided will be very appreciated, thanks!
  22. hello i want help for creating lisp for me please ... the lisp will do these functions 1- as the attached image (1a) if i have block with yellow at right and some green blocks 2- i want when i launch the lisp to ask me to draw poly line that i want as in image 2a 3- after that when i draw this path with polyline and press enter the lisp ask me to choose blocks that i want to connect to this polyline and i will choose one by one or multiple blocks then after choosing the blocks and press enter ... the lisp will offset the main polyline that i draw and connect every polyline with the basepoint of the blocks that i choose sequentially as appear in this image 5a (attached DWG) can anyone help me please sample.dwg
  23. Hello everyone i have this code that im working for sometime... (while (not (setq ent (car (entsel "\nSelect rectangle: "))))) What i want is to change the selection option into ssget with layer filter, so that i would not pick the rectangle one by one and will do the same routine for every rectangle in the selection set.
  24. Hi there! I've watched this tutorial and have a few questions: 1. how can I load the full project in the current drawing from Visual Studio Code? Currently, I'm able to only attach the currently opened lsp file and have to load the other manually, one by one. In the visual lisp editor, there was a button to load all the files inside the project. I have a big project divided into a few files that also load an opendcl interface and I need to load them all to debug the whole program or it will not work. 2. how can I compile in fas from vscode? Probably is not possible so I have to use the original visual lisp editor. But how can I load it now? The vlisp command starts the vscode and I don't know how to start the old editor. Thanks! Dennis
  25. So I have been trying to figure this out with several approaches now and I need some help. I would like to send all Wipeouts, or really any specified entity type, within a block to the back of the draw order. Is there a way to do this using Lee Mac's Apply To Block Objects routine? I tried this in conjunction with his draw order routines but the MovetoBottom command kept failing. I'm pretty rough with VisualLisp which is part of the issue when trying to troubleshoot his great routines. Or what about this approach? (I dont really understand it, again Visual Lisp) Below is what I tried. I do understand Vanilla Lisp. Visual Lisp I barely know the basics, but eager to learn. Please help me improve my capabilities. I love autolisp. Thank you. The issue is clearly with the lambda function and my improper use of it Im sure. The ssget I am trying to do is incorrect approach for use with his function. ;=========================================================== ; 11/Sep/2020 10:09 AM[Friday] AUTHOR: Brandon Gum ;-- ;DESCRIPTION: ;Select block with wipeout. ;Will send wipeout objects the back of the draw orer ;=========================================================== (defun c:test ( / s ) (princ "\nSelect Block: ") (if (setq s (ssget "_+.:E:S" '((0 . "INSERT")))) (LM:ApplytoBlockObjects (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename (vlax-ename->vla-object (ssname s 0))) '(lambda ( obj ) (BG:WipeoutToBottom)) ) ) (princ) ) (vl-load-com) (princ) (defun BG:WipeoutToBottom( / ) (LM:movetobottom (ssget "X" '((0 . "WIPEOUT")))) ;(princ) );end of defun ;===============Below here are Lee's draw order functions============== My LeeMac Based Approach.LSP
×
×
  • Create New...