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. Hello, I have 5000 drawings that contains three specific tables. All these tables are linked to external Excel using data links. The main issue i have is, after the data link is removed the cell content of all three tables remain locked. Is there any way to unlock the cells using lisp??. I know i can do it manually but i don't want to go that route unless it is the only the way to do so. Please take a look at the drawing & lsp file. Trial.dwg Thank you very much. Regards, A AUTOCAD AUTOMATION.LSP
  2. Hi, I am running a version of autocad architecture with a plugin that adds some custom properties to AEC objects such as doors that can be viewed under the design tab of the property palette. I want to make a macro that changes these properties but I don't know how to access them via lisp. When I use the inspect window in the visual lisp viewer the custom properties don't come up and when I use the vla-dump-object function, the custom properties are not listed also. Does anyone have any idea if/how these properties are accessible? Also, can custom property fields be added via autolisp?
  3. Hello everyone, everything good. First apologies for my pessimo ingles. (defun c:Test0008 (/ p1 oFile sFile tmp Separator i ;|Functions|; GetFormatFile aux:SelectFile grdx ) ;;_________________________________________________ (defun GetFormatFile (/ lsts) (or *Format* (setq *Format* "csv")) (setq lsts '(("csv" ";" "[<Csv>/Txt/Xls]") ("txt" " " "[Csv/<Txt>/Xls]") ("xls" "\t" "[Csv/Txt/<Xls>]"))) (setq mens (last (assoc *Format* lsts))) (initget "Csv Txt Xls _csv txt xls") (if (setq tmp (getkword (strcat "\nFormat file;" mens ": "))) (setq *Format* tmp) ) (setq Separator (cadr (assoc *Format* lsts))) ) ;;_________________________________________________ (defun aux:SelectFile ( Extension / ff) (if (setq ff (getfiled "Select File" (if *TmpRutaFile* *TmpRutaFile* "") Extension 1)) (setq *TmpRutaFile* (strcat (vl-filename-directory ff) "\\")) );c.if ff );c.defun ;;_________________________________________________ ; grdx - graphic cross utility (defun grdx (p col size / h) (setq h (/ (getvar "viewsize") size)) (grdraw (list (- (car p) h) (- (cadr p) h)) (list (+ (car p) h) (+ (cadr p) h)) col 0) (grdraw (list (- (car p) h) (+ (cadr p) h)) (list (+ (car p) h) (- (cadr p) h)) col 0) p );c.defun ;;--------------------- MAIN ----------------- (or *Prec* (setq *Prec* 4)) (setq p1 (getpoint "\nPick first point: ")) (while p1 (grdX p1 213 125) (setq lstFile (cons p1 lstFile)) (setq p1 (getpoint " >> Pick Next point: ")) ) (cond (lstFile (initget (+ 4)) (if (setq tmp (getint (strcat "\nPrecisión;<" (itoa *Prec*) ">: "))) (setq *Prec* tmp) ) (GetFormatFile) (setq sFile (aux:SelectFile *Format*)) (cond (sFile (setq i 1) (setq oFile (open sFile "w")) (write-line "COORDINATES OF POINTS" oFile) (write-line (strcat "#" Separator "X" Separator "Y" Separator "Z") oFile) (mapcar (function (lambda (pt) (write-line (strcat (itoa i) Separator (rtos (car pt) 2 *Prec*) Separator (rtos (cadr pt) 2 *Prec*) Separator (rtos (last pt) 2 *Prec*) ) oFile) (setq i (1+ i)) ) ) lstFile );c.mapcar (close oFile) (alert (strcat "File: \n\n[" sFile "]\n\nhas been created.")) ;;(startAPP (strcat "notepad.exe " sFile)) (command "shell" (strcat "start " sFile)) ) ) ) );c.cond (princ) ) (princ) I use this routine that exports coordinates, from points clicked to excel, in Csv / Txt / Xls but the exports in descending order _the last point I clicked is the first_ Can anyone reverse this? Are the points imported in the order they are clicked? --------------------------------------------------------------------------------------- Another thing, the great Lee-mac created a subroutine that would help me a lot if it were attached to the program. this link http://www.lee-mac.com/grtext.html has the subroutine, and here is the demo. (defun c:demo2 ( / *error* pnt str ) (defun *error* ( m ) (princ m) (redraw) (princ)) (while (= 5 (car (setq pnt (grread nil 13 0)))) (redraw) (setq str (mapcar 'rtos (trans (cadr pnt) 1 0))) (LM:DisplayGrText (cadr pnt) (LM:GrText (strcat "X=" (car str) "\nY=" (cadr str))) 3 15 -31) ) (redraw) (princ) ) This subroutine would work as a preview, so I know if I'm clicking the correct location. I thank the help of all you.
  4. Hi, I have several drawings with thousands of individual circles (not blocks) of same radius. All of them I am supposed to change to the equilateral triangle of base & sides length = 10mm. Is it possible to write a program to do this automatically? Thanks in advance.
  5. Hei, Can enyone make autolisp to annotate 3d point z value! Best, MRe
  6. I have created Dynamic Block with grips and Attribute linked to the parameter. Now I override that attribute value to a manual value through a program and change the parameter. Now, when I move the grips of dynamic block, the attribute value linked to it doesn't change and remains as manual value. Is there any way/ program to retrieve the relation between attribute and parameter value? Pls find attached Program and Dynamic Block. You can override linked values of "WIDTH" & "LENGTH" by 'double-clicking' on block and entering manual value. Upload & Run the program with command "DChange". This will change the shape of block as per manual value. After this, when you will stretch the grips of block, it will change the shape; but, the attribute value "WIDTH" & "LENGTH" will not change. Can this linking between Attribute & Parameter revived so that attribute values will change with moving grips? Straight Duct.dwg DChange.lsp
  7. Hi everyone, I'm new to using macros/lisps in AutoCAD, though I do have a small programming background in some other programs. To give you some background on what I'm trying to do: I have a big .dwg file that shows all of the roads in a particular city in the USA, and I have created views of all of the intersections that have crosswalks. All of these intersections have their own intersection IDs, which have a format such as BRI1, BRI2A, BRI3B, BRI4, BRI5, etc., through BRI170. I have already created all of the views from these intersections, and now, in the same .dwg, I am trying to quickly create layouts from a template that show only one view each. I have a .dwt set up for this, and the name of the layout for this template is EB124. I want the layout tabs to be named corresponding to an intersection ID, and then have the viewport show that same view. So, I want layout 1 to be renamed BRI1, and have the viewport view restored to the named view BRI1, and so on for all of the named views. Here are the commands that I used to create a macro for this using the Action Recorder: -layout > t > [select template from file] > EB124 -layout > set > EB124 -layout > rename > EB124 > [ASK FOR USER INPUT, example BRI1] [select the viewport in the new layout and unlock the display] MSPACE -view > restore > [ASK FOR USER INPUT, example BRI1] PSPACE [select the viewport and lock the display] This macro works great, except that I have to press play and enter the intersection ID twice per layout tab. I'm wondering if its possible to create a lisp that does this routine but reads an excel (or other) file and loops through and creates all the layout tabs in one fell swoop? Thanks in advance for all of your help!
  8. Hi, I want a LISP routine which can insert blocks along the polyline. I have two dynamic blocks. They are 'Straight Duct' and 'Elbow90'. Consider I draw a polyline with three XY coordinates i.e. (1,1) , (1,2) and (2,2) and insert rectangular block with desired 'Width'. Here are list of things I want from LISP program: 1. I want 'Straight Duct' to be inserted at mid-points of '(1,1) & (1,2)' and '(1,2) & (2,2)'. 2. Also, those inserted blocks should be rotated with an angle made by those points with horizontal so that 'Straight Duct' remains along the line. Example, Angle made by line joining points '(1,1) & (1,2)' with horizontal is 90 Deg. Hence, Dynamic Block should be rotated by 90 degree about midpoint. 3. Move the grip of 'Straight Duct' (which facing to open end of polyline) to the open end of polyline. Move other grip of 'Straight Duct' to the length of (150+ Width/2) mm less than the intersection point. 4. Insert 'Elbow90' at the point with polar angle 45 Degree to point of intersection and polar radius (150 + Width/2) mm. Also, the grip of elbow should be moved so that width of 'Elbow90' should be as same as that of 'Straight Duct'. Pls refer the attached file for understanding the problem. Can anyone help me out? HVAC Dynamic Blocks 24.04.2018.dwg
  9. this lisp convert polyline segments to arcs . work one line for time . i need select 1000 polylines for times. I'm new in autolisp and i do know what change in the code : (defun c:lwsegs2arced ( / massoclst nthmassocsubst v^v unit _ilp doc lw enx gr enxb p1 p2 p3 b i n ) (vl-load-com) (defun massoclst ( key lst ) (if (assoc key lst) (cons (assoc key lst) (massoclst key (cdr (member (assoc key lst) lst))))) ) (defun nthmassocsubst ( n key value lst / k slst p j plst m tst pslst ) (setq k (length (setq slst (member (assoc key lst) lst)))) (setq p (- (length lst) k)) (setq j -1) (repeat p (setq plst (cons (nth (setq j (1+ j)) lst) plst)) ) (setq plst (reverse plst)) (setq j -1) (setq m -1) (repeat k (setq j (1+ j)) (if (equal (assoc key (member (nth j slst) slst)) (nth j slst) 1e-6) (setq m (1+ m)) ) (if (and (not tst) (= n m)) (setq pslst (cons (cons key value) pslst) tst t) (setq pslst (cons (nth j slst) pslst)) ) ) (setq pslst (reverse pslst)) (append plst pslst) ) (defun v^v ( u v ) (mapcar '(lambda ( s1 s2 a b ) (+ ((eval s1) (* (nth a u) (nth b v))) ((eval s2) (* (nth a v) (nth b u))))) '(+ - +) '(- + -) '(1 0 0) '(2 2 1)) ) (defun unit ( v ) (mapcar '(lambda ( x ) (/ x (distance '(0.0 0.0 0.0) v))) v) ) (defun _ilp ( p1 p2 o nor / p1p p2p op tp pp p ) (if (not (equal (v^v nor (unit (mapcar '- p2 p1))) '(0.0 0.0 0.0) 1e-7)) (progn (setq p1p (trans p1 0 (v^v nor (unit (mapcar '- p2 p1)))) p2p (trans p2 0 (v^v nor (unit (mapcar '- p2 p1)))) op (trans o 0 (v^v nor (unit (mapcar '- p2 p1)))) op (list (car op) (cadr op) (caddr p1p)) tp (polar op (+ (* 0.5 pi) (angle '(0.0 0.0 0.0) (trans nor 0 (v^v nor (unit (mapcar '- p2 p1)))))) 1.0) ) (if (inters p1p p2p op tp nil) (progn (setq p (trans (inters p1p p2p op tp nil) (v^v nor (unit (mapcar '- p2 p1))) 0)) p ) nil ) ) (progn (setq pp (list (car (trans p1 0 nor)) (cadr (trans p1 0 nor)) (caddr (trans o 0 nor)))) (setq p (trans pp nor 0)) p ) ) ) (or doc (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vla-startundomark doc) (if (and (setq lw (entsel "\nPick LWPOLYLINE...")) (= (cdr (assoc 0 (setq enx (entget (car lw))))) "LWPOLYLINE") ) (progn (setq i (fix (vlax-curve-getParamAtPoint (car lw) (vlax-curve-getClosestPointToProjection (car lw) (trans (cadr lw) 1 0) '(0.0 0.0 1.0)) ) ;_ vlax-curve-getParamAtPoint ) ;_ fix p1 (vlax-curve-getPointAtParam (car lw) i) p3 (vlax-curve-getPointAtParam (car lw) (1+ i)) lw (car lw) ) (setq enxb (massoclst 42 enx)) (while (= 5 (car (setq gr (grread t)))) (setq p2 (_ilp (trans (cadr gr) 1 0) (mapcar '+ (trans (cadr gr) 1 0) '(0.0 0.0 1.0)) p1 (cdr (assoc 210 (entget lw))))) (setq b ((lambda (a) (/ (sin a) (cos a))) (/ (- (angle (trans p2 0 lw) (trans p3 0 lw)) (angle (trans p1 0 lw) (trans p2 0 lw))) 2.0) ) ) (setq n -1) (foreach dxf42 enxb (setq n (1+ n)) (if (= n i) (setq enx (nthmassocsubst n 42 b enx)) (setq enx (nthmassocsubst n 42 (+ (cdr dxf42) b) enx)) ) ) (entupd (cdr (assoc -1 (entmod enx)))) ) ) (prompt "\n Nothing selected or picked object not a LWPOLYLINE ") ) (vla-endundomark doc) (princ) )
  10. Hi I have written a Lisp routine (shown below) that measures the distance between two points, and applies a scale factor that is written within the lisp, and displays it within the command line. Although the lisp functions, it may not be the 'cleanest'. I was wondering if it was possible to add a function to the lisp that in addition to displaying the newly calculated distance, will display a bearing. ideally, the bearing displayed would be written in a Degrees Minutes Seconds format, and not directional bearings (Ex. N73°25'45"W would be displayed as 286°34'15"). In the language of the lisp I have written, from 'x1', North is 0°, and the angle is turned clockwise from north, to a line drawn between 'x1' and 'x2'. Any help would be great. If anyone has a lisp that already does this, or can amend my lisp to do it, that would be perfect. Thanks Ahmed ;Use this command to measure the distance between two points while applying a Combined Scale Factor ;Be sure to copy this lisp to your job folder, and set your CSF as required. Do not change CSF outside of job folder. ;Ahmed F. 2017 (defun c:DM () (setq TD 0) (setq x1 (getpoint "\nSelect First Point: ")) (setq x2 (getpoint x1 "\nSelect Second Point: ")) (prompt (strcat (rtos (distance x1 x2)) (rtos (setq TD (+ TD (/(distance x1 x2) 0.999848)))) ) ) (prompt (strcat "\nTotal Distance = " (rtos TD))) (princ) ) thanks again.
  11. Think VLIDE but from the year 2018 instead of 1999. More info: https://www.cadnauseam.com/2018/02/20/bricsys-shows-autodesk-how-to-do-mid-term-updates-again/ Screenshot:
  12. Hello, I would apprecite some reactions on the following tools that I made. Reading about Clojure I came across functionality that is not standard available in AutoLisp. After some thinking I programmed it myself. First 2 functions which do what they are supposed to do: (defun even? (n) (and (= (type n) 'INT) (= (rem n 2) 0))) (defun odd? (n) (and (= (type n) 'INT) (/= (rem n 2) 0))) The questionmark in the functionname seems appropriate. So what to do when you want to filter a list of integers against one of these functions? I constructed the following: (defun filter (f l / a) (foreach i l (if (apply f (list i)) (setq a (append a (list i))))) a) To get you started use the following two commands: (defun c:etest () (filter 'even? (list -5 -4 -3 -2 -1 0 1 2 3 4 5))) (defun c:otest () (filter 'odd? (list -5 -4 -3 -2 -1 0 1 2 3 4 5))) Although short already I wonder if the filter routine could be made more elegant/more logical. One can extend the library with all kinds of name? functions, provided that return T or nil on every call. The questionmark and the name 'filter' are used for logic readability. Try to make a functon that returns T if a value is of type 'STR, otherwise nil. Next use it with the filter function. It's fun and would like to see the variations that you come up with. Regards, André
  13. Hi there, here a thing I want the do with LISP: I want to change multiple Objects with different Layers, that each Layer change to a different Layer. Example: Select entities with (ssget "_:L" '((8 . "Layername1, Layername2, etc"))) Now change Layer: Layername1 → 1_Layername1 Layername2 → 1_Layername2 I don't want to select each entity and than change its Layer. I want to do all entities at the same time with one command.
  14. Hi, I have a Lisp that paste a file in a folder that require admin access, but is not all users that have a admin access account. So, there is some way to get the admin access with Lisp? Like, write my admin username and password in the Lisp file, and when required, use these information? Thanks!
  15. Hello all, I've posted on SEVERAL forums trying to get an answer to this problem, I've compiled so many different Lisp routines that I've lost count, but none have quite been able to do what i want. i've attached a dwg with two blocks in it, the scope of what I'm trying to accomplish is at the bottom of this code: (defun BKVZ ( / blk idx obj sel vis ) (setq blk "WELD DETAIL" ;; Block Name vis "EQUAL WELD" ;; New Visibility State ) (if (setq sel (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," blk))))) (repeat (setq idx (sslength sel)) (if (= (strcase blk) (strcase (LM:blockname (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))))) (LM:SetVisibilityState obj vis) ) ) ) (princ) ) ;; I would like the visibility state of several different dynamic blocks ;; to reference a text field within the drawing, and the blk variable to be used for several different dynamic ;; blocks within my drawing. for example in this drawing i have two dynamic blocks, and two text fields that ;; represent the visibility states that i want to use for the blocks (this value will change so i want to use it as a ;; variable to change the db viz prop) . I would like to be able to use this code to change the vis states of ;; several blocks within the same dwg, each of which would have a text field that will display the present vis state. ;; if i have to use setq blk1, blk2, blk3, etc to represent each block that is fine, but with several different possible ;; vis states, i would like that varible to reference the text field. so as the text field changes, so does the vis state of the ;; dynamic block. ANY HELP WOULD BE APPRECIATED. THANK YOU!! NEW-LISP-TRIAL.dwg
  16. Hello all. First off let me thank Lee Mac for all that he does with LISP and how he helps others out. He is a great value to the community. Now for the question I have been trying to get his Tip of the day lisp working. I have the lisp in my startup suite, it and the text file are both in a support file search path, and it does not show a tip at the start of the day. The Lisp does load because I can type (LM:tip) and it shows a tip, it just does not show anything for the first dwg of the day. Could the issue be that I am using Civil 3D 2015, maybe so variable that is causing the problem? http://www.lee-mac.com/tipoftheday.html
  17. I have been experimenting with generating variables through code rather than defining them manually. The problem is that when the program creates them, they are defined as global variables. Is there a way to generate them as local variables instead? Below is the sample code that I wrote for testing it. ;ListToVariables creates variables named testvar0, testvar1, testvar2, etc. ;Each newly created variable contains the contents of the correlated slot from testlist. (defun c:test ( / testlist ) (setq testlist (list "aaa" "bbb" "ccc" "ddd" "eee")) (ListToVariables testlist) ) (defun ListToVariables ( listname / i ) (setq i 0) (repeat (length listname) (set (read (strcat "testvar" (rtos i 2 0))) (nth i listname)) (setq i (1+ i)) ) (princ) )
  18. What is the way to add already highlighted objects to a selection set? I feel like I have seen the answer before but I cant remember what I searched to find it. Like how you can select object before you use the move command and autocad will move the objects that were already selected. I am looking to use the TSPACEINVADERS command and have the selected text then have a red circle put around them. Thank you for any help in advance.
  19. I have a bit a head scratcher. I want a lisp that when run I will be able to select the whole drawing and all the mleaders will automatically justify to the side that the leader and arrow is on. Occasionally our leaders get move and it is time consuming to change them individually. Any help would be greatly appreciated.
  20. I have the code below to place a block on a point. Then array that block based on information given by the user. Then move all of the blocks so that the insertion point is the top and center of all the blocks. It works fine sometimes but about half the time it it skips the first move command. Could someone tell me what I am missing? (DEFUN C:COMEDARRAY ( / OLDL NOR NOC CEB CEP ) (SETQ OLDL (GETVAR "CLAYER")) (COMMAND "_LAYER" "SET" "ELEC-CE" "") (SETQ NOR (GETINT "\nENTER NUMBER OF COMED ROWS: ")) (SETQ NOC (GETINT "\nENTER NUMBER OF COMED COLUMNS: ")) (setq CEP1 (getpoint "\nPICK INSERT POINT FOR BLOCK: ")) (COMMAND "_INSERT" "S:\\LightSett\\LISP FILES\\LISP USED BLOCKS\\COMED PROFILE.DWG" CEP1 "" "" "") (SETQ CEB (ENTLAST)) (COMMAND "_ARRAY" CEB "" "R" NOR NOC 0.6667 0.3333) (SETQ CEP (SSGET '((0 . "INSERT")))) (COMMAND "_MOVE" CEP "" CEP1 (cons (- (CAR CEP1) (/ (* NOC 0.3333) 2)) (CDR CEP1))) (COMMAND "_MOVE" CEP "" CEP1 (LIST (CAR CEP1) (- (CADR CEP1) (* NOR 0.6667)) (CADDR CEP1))) (command "layer" "set" OLDL "") (PRINC) )
  21. Is there a quick and practical way to get X & Y values on a polyline other than by way of "LIST". because I need the X & Y value just like the 2nd image. Thank you Master. img 1 : https://drive.google.com/open?id=0B1KbDu2x_byvU2F6NlpvNWJrU0k img 2 : https://drive.google.com/open?id=0B1KbDu2x_byvVE9qdmpBLWcxWHM
  22. Hi Lisp Legends, Actually i am new to autolisp, just now reviewed cadtutor.net, excellent works done by members here. Thanks in advance to those peoples:) I need a urgent help from you friends.... actually I need to align text(as shown in attachment) to three different positions of a block(red coloured). Is there any lisp to get the text aligned to those positions. further explained in attached image Please revert for clarification if any required. Awaiting for your response. Thanks amb sample.dwg
  23. I want to create a auto lisp programme for following As input i want to select one line from model space in auto cad and as output i want table that display length of line and whenever i change length of line, table should automatic update new length I am using auto cad 2014
  24. 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.
  25. Hello, I have a question for all those lisp masters out there. The company that I work for has had me learning and creating lisp for them for a couple months now and we are starting to get a library of lisp built up. Currently I have all of the lisp being loaded at startup through the appload command. I have decided to use Lee Mac's Autoloader when necessary, but I was wondering at how many lisp would it be wise to do that for instead of at startup? Right now the PCs in the office are not filling slow (They are what I would consider to be in the middle of the road in power.).
×
×
  • Create New...