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 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) )
  2. 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
  3. 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
  4. 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.).
  5. Hello, I am looking for a lisp the can place a block along a polyline every 500 feet. I know about using the measure command, and have made a lisp to use it, but one of the blocks that I have to use has an attribute. Measure does not work with attributed blocks. Is there already a lisp out there that will work like measure with attributes blocks or does anyone have any ideas that could do this?
  6. Hi, Can anyone help me to write a lisp function to sort the points (assume the intersection points) on a polyline? With my code, I have a polyline object and a set of intersection points on it. I need to calculate the cumulative distance between those points and vertex points consecutively. Thanks,
  7. Hello, guys! I have a little question... Is there some way to open / edit a drawing with autolisp without display that drawing? For example... When we are working with VBA, we can use the code ActiveWindow.Visible = False to not show the active window. Can we do something like it in autolisp?
  8. Hello, guys! I'm new here. So, please, be gentle. I had a problem with a routine. I have to open all the drawings in the same folder, compare a specific area of the drawing with a reference and change that area, if necessary. But I have a lot of references to compare, so I need to do that many times. I've already got a batch to open all the drawings in the same folder. So I just modified it to compare the area with the reference and it worked greatly. The only problem is: When i put that batch inside a loop instruction (to change the reference that will be compared), the batch didn't worked. The following error appears: ; error: bad argument type: streamp nil Here goes the code. Could someone help me? (defun c:testloop (/) (setq c 1) (while ( (c:opendrawings) (setq c (1+ c)) ); end while ); end function to test the loop (defun c:opendrawings (/ dwglist dwgname dwgpre file openfile uhoh len) (vl-load-com) (if (and (setq dwgpre (getvar 'dwgprefix)) (setq dwglist (vl-sort (vl-remove (strcat dwgpre (getvar 'dwgname)) (mapcar '(lambda (dwgname) (strcat dwgpre dwgname)) (vl-directory-files dwgpre "*.dwg") ) ) ' ) ) (setq uhoh "Readonly drawings will not be processed!" ) (setq len (strlen uhoh)) ) (progn (setq openfile (open (setq file (strcat dwgpre "myscript.scr")) "w")) (progn (foreach f dwglist (if (and (not (Is_ReadOnly f)) (/= (checkAttFile f) 1) ) (progn (write-line (strcat "_.open \"" f "\"") openfile) (write-line "_.audit _y" openfile) ; (write-line "_.qsave _.close" openfile) ) (setq uhoh (strcat uhoh "\n" f)) ) ) (close openfile) (command "_.script" file) (if (= (strlen uhoh) len) (princ "All drawings successfully processed...") (alert uhoh) ) ) ) ) (princ) ); end function to open all the drawings
  9. Hello, I am trying to draw a solid object by AutoLISP. But I got stuck while drawing an arc. Please see below picture where I got stuck. I need this arc parallel to the lines below it. I tried some UCS command but at that time arc shown up somewhere irrelevant. Couldn't figure it out. I'm doing something wrong. (I can post my .lsp here however it might be confusing for you as it contains many variables defined by me) Can anybody help please?
  10. I am looking for a lisp that will allow me to convert survey figures to flat polylines. Currently I have to select them explode which makes 3dpolylines then convert to 2dpolylines. I then use the flatten command. I have tried making a lisp that uses (command "_explode") and (command "_flatten") and am having trouble getting them to work. Does anyone have any suggestions?
  11. Hello, I have a drawing with approximately 4400 points in it. and a file folder with the same number of files. What i am looking for is a lisp routine that will use the point description and then create a hyperlink to the file in the folder with the name that is the same as the description. So if i have a point thats description is 43804152000, the lisp routine would go to the folder where all the hyperlink files are saved and hyperlink to the file named 43804152000. I have zero knowledge in lisp routines and would appreciate any help! Thanks,
  12. Is it possible using AutoLISP to define a variable name from the command line when running a function? I want to input the name when running it from the command line. Can I do this and still have the variable be global? If so, how would I go about that? Thanks in advance.
  13. Hi, I need a LISP for selecting similarobjects according to area of the object. As I am not familiar in creating LISPS any help would be appreciable. Thanks & Best Regards Vinay
  14. This is the part of code. I am getting the ; error: bad list of points How we will make list of points pt1 and pt2 to pass in ssget "_F". please help (setq txt (entsel "Select text: ")) (setq oText (vlax-ename->vla-object (car txt))) (setq pt1 (vlax-safearray->list (vlax-variant-value (vlax-get-property oText 'InsertionPoint)))) (setq x1 (car pt) y1 (cadr pt)) (setq angle_obj (vlax-get-property oText 'Rotation)) (setq pt2 (polar pt (+ angle_obj PI 90) 0.3)) (setq x2 (car pt) y2 (cadr pt)) (setq ss (ssget "_F" '((x1 y1) (x2 y2)) ))
  15. Hello.. Not familiar with autolisp or scripts I work for a earthworks company, and we are looking for a way to have an excel worksheet to update progress completion by coloring a property another colour in autocad. Example - lot 1 10% complete, and lot 10 is 30% complete as per excel data. I would like lot 1 (10%) to be light green and lot 10(30%) to be a darker green and darker shades for higher % completion and for the autocad drawing to update as the excel data sheet is updated. I have aproximatly 400 lots to program in this way if possible. Each lot will have 10 conditions (ie 10%, 20%, 30%... to 100%) Thank you
  16. How to transfer my custom icons, menus, toolbar in my computer to other computer.
  17. hi guys, my name is ramdan i live in Indonesia, I want to Ask, how to make amnote in AutoCAD Mechanical with Autolisp ? thanks,
  18. I think I'm encountering the same problem that was not resolved here. I'm trying to set all the layers of an xref to layer 251. I found two codes online, posted below. CVX: (defun c:cvx (/ ent_data);;changes all layers in selected xref to color 251 (setq ent_data (entget (car (entsel)))) (command "-layer" "Color" 251 (strcat (cdr (assoc 2 ent_data)) "*")"") ) X251: (defun C:X251 (/ EN L X ad layers) (command "UNDO" "BEGIN") (setq EN (nentsel "\nSelect Xref: ") L (cdr (assoc 8 (entget (car EN)))) X (substr L 1 (vl-string-position (ascii "|") L)) ) (setq AD (vla-get-ActiveDocument (vlax-get-Acad-Object)) layers (vla-get-Layers ad)) (if (/= (vl-string-search "|" L) nil) (progn (vlax-for layer layers (if (/= (vl-string-search (strcat X "|") (vla-get-name layer)) nil)(vla-put-Color layer 251)) ) (command ".REGEN") ) (princ "Not an Xref!") ) (prin1) (command "UNDO" "END") ) I used the CVX routine for a while, until I discovered that it doesn't work if I select xrefs that are attached to overlaid xrefs. So I tried switching to the X251 routine, but if I use UNDO, the changes aren't reflected until I REGEN the drawing. I tried using an undo group as suggested in the linked post, but that didn't change the result. Any advice?
  19. I have a plot setup to plot all the layout tabs in a drawing. I have provided the users the options to select the paper size, plot style, and orientation. These are stored as user variables (PDFPS, PST, and PLO). I have the setup working great, but I am trying to set it up where if the user hasn't selected one of the variables, the command will be cancelled. I have tried an if statement, but I wanted to evaluate all three variables at once. I'm thinking it should be doable, just have been able to figure it out. Any help is appreciated. The code below is the code that plots all the layouts and places them in the PDF folder for each project. ^C^C^C(foreach LL (layoutlist)(setvar "ctab" LL)(command (setq DL (substr (getvar "dwgprefix") 1 (- (strlen (getvar "dwgprefix")) 13))) (setq DN (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4))) (strcat DL DN);(setq FS (strcat DL "52 PDFs" (chr 92) DN "-" (getvar "CTAB") ".pdf")) "plot" "yes" "" "AutoCAD PDF (General Documentation)" PDFPS "Inches" PLO "No" "Extents" "1:1" "Center" "Yes" PST "Yes" "No" "No" "No" FS "Yes" "Yes" "Yes"));(alert "If all settings were selected, PDFs have been made of all layout sheets and saved in the PDFs folder for this project. They were saved as Project Name-Layout Name"); For reference, I have a code that evaluates each variable and displays a message. (if (= nil PDFPS) (alert "No paper size was selected. Please cancel command and select paper size.") (strcat PDFPS))
  20. I've incorporated and created many LISP functions for surveying purposes in AutoCAD. I've been wanting to share them, so here goes. A lot of the functions reference other functions. I've used the naming scheme: mfcb* for My Functions CBass (me) mfcbLM for My Functions Lee Mac (because he is awesome) Many of these functions have been the work of others and I have revised them to my needs. Use them as you see fit. Enjoy! AutoCAD Blocks Edit: Minor text fixes. Sorry about that. Edit2: Optimizations. Edit3: Optimizations and error fixing. Edit4: More optimizations and a few new functions. Edit5: Optimized SPL function. Edit6: Fixed c:CLOSEST (iNdx was causing infinite loop). Edit7: Fixed multiple selections with c:MASK command (forgot to nil the XData and it would error). Edit8: Formatted Benchmark.lsp for readability. Edit9: Revised XData functions to preserve other application XData. Created menus for the functions. Edit10: Added dropbox link to AutoCAD blocks. Benchmark.lsp PointCodeList.txt acaddoc.lsp Global Functions.LSP Menu.zip
  21. I introduce myself my name is Luciano and 30 years working on 2d and 3d. I have a problem that now haunts for years and only you "GURU" of the Lisp language you can perhaps bring myself giving me a great mano.Vi thank you in advance. special nesting.dwg
  22. I am writing a routine that requires that I remove objects from a selection set while still keeping the original set around. After running into issues, I created a test routine to see how ssdel is operating. I want it to remove selB from selC, while keeping selA and selD untouched to hold the original selection. It is removing selB from all related selection sets though. Why is it doing this, and how can I fix it? (defun c:TD () ;Test Delete (setq selA(ssget)) ;get base selection A (setq selB(ssget)) ;get selection B to remove from selection C (setq selC selA) ;copies selection A and removes selection B to return the difference (setq selD selA) ;extra variable to test how ssdel works (setq i 0) ;index (repeat (sslength selB) ;repeat for each entity in selB (ssdel (ssname selB i) selC) ;intended to remove selB from selC. It is also removeing selB from selA, which I don't want. (setq i (1+ i))) ;increment ) ;Functions below are used to test which geometry is contained in which selection set (defun c:dela () ;delete geometry in selection A (If(/= nil selA)(command ".erase" selA "")(princ "\n selA is empty. Run TD to initialize"))(princ)) ;if selA contains entities, delete them. If not, display error. (defun c:delb () ;delete geometry in selection B (If(/= nil selB)(command ".erase" selB "")(princ "\n selB is empty. Run TD to initialize"))(princ)) ;if selB contains entities, delete them. If not, display error. (defun c:delc () ;delete geometry in selection C (If(/= nil selC)(command ".erase" selC "")(princ "\n selC is empty. Run TD to initialize"))(princ)) ;if selC contains entities, delete them. If not, display error. (defun c:deld () ;delete geometry in selection d (If(/= nil selD)(command ".erase" selD "")(princ "\n selD is empty. Run TD to initialize"))(princ)) ;if selD contains entities, delete them. If not, display error.
  23. Hello, guys! I need a lisp to rename the current open file. I already have a routine that takes the current file name and creates a string with the new file name (Just six numbers in the old name needs to change)... But I coudn't change the old name for the new name. I've tried to use the (Vl-File-Rename), but I think that i didn't use it right.... Here's go the code: (defun C:changename (n1 n2 n3 n4 n5 n6) (setq new_number (strcat (itoa n1) (itoa n2) (itoa n3) (itoa n4) (itoa n5) (itoa n6))) (setq old_name (strcat (getvar "DWGPREFIX") (getvar "DWGNAME"))) (setq size (strlen old_name)) (setq final (- size 18 )) ; (setq start_name (substr old_name 1 final )) (setq end_name (substr old_name (+ final 7) (- size final))) (setq new_name (strcat start_name new_number end_name)) (alert old_name) (alert new_name) (vl-file-rename old_name new_name) ); end defun The old name is: D:\Profiles\s-Andre.Almeida\Desktop\Autocad\3-157941-012-005.dwg The new name, for example, could be: D:\Profiles\s-Andre.Almeida\Desktop\Autocad\3-666666-012-005.dwg I just need to change the names with the (vl-file-rename) could someone help me?
  24. Hello, guys! I'm creating a lisp to open multiple DWG's in a directory and alterate a number at a especific position. I have a function (called txt) to write the number at a position and I have another function (called change_all) to open every DWG in the directory and execute the function "txt". I want that the "Change_all" asks me the number and then execute the "txt" to write that number in all DWG's. The functions are already working, but i couldn't call the "txt" with the parameter number previously defined Here are the code: (defun c:txt (tval) ; (setq num0 (ssget "_C" '(347.06 18.12) '(350.90 18.12))) ; (command ".erase" num0 "" ); (setq pt1 '(346.5 15.84)) ; (if (not (tblsearch "Layer" "TEXT")) (command "-layer" "m" "TEXT" "") ) ;_ end if (entmake (list '(0 . "TEXT") '(8 . "TEXT5") (cons 10 pt1) (cons 40 4.5) (cons 1 tval) '(50 . 0.0) '(7 . "ROMANS") '(71 . 0) '(62 . 4) '(72 . 0) '(73 . 0) ) ;_ end list ) ;_ end entmake (*error* "") (princ) ) ;_ end defun (defun c: change_all (/ dwglist dwgname dwgpre file openfile uhoh len) (vl-load-com) (if (and (setq dwgpre (getvar 'dwgprefix)) (setq dwglist (vl-sort (vl-remove (strcat dwgpre (getvar 'dwgname)) (mapcar '(lambda (dwgname) (strcat dwgpre dwgname)) (vl-directory-files dwgpre "*.dwg") ) ) ' ) ) (setq uhoh "Readonly drawings will not be processed!" ) (setq len (strlen uhoh)) ) (progn (setq openfile (open (setq file (strcat dwgpre "myscript.scr")) "w")) (setq num (getstring t "\nType the numer: ")) ; (progn (foreach f dwglist (if (and (not (Is_ReadOnly f)) (/= (checkAttFile f) 1) ) (progn (write-line (strcat "_.open \"" f "\"") openfile) (write-line "(C: (txt num))" openfile) ; (write-line "_.qsave _.close" openfile) ) (setq uhoh (strcat uhoh "\n" f)) ) ) (close openfile) (command "_.script" file) (if (= (strlen uhoh) len) (princ "All drawings successfully processed...") (alert uhoh) ) ) ) ) (princ) ) ; End Defun Could someone help me, please?
  25. Hi Everyone, We have browsed the forum looking for a Lisp Routine for creating Z values from point clouds. Lee Mac has came up with something which works well (great work Lee). Though we are looking to modify this to suit our workflow: Basically we want to pick a point and bring through the z value as text. (which the lisp below works fine) though not having the option to choose between x,y,z and only picking the z value every time would be beneficial. Having a fixed offset and text size too rather than having the option to choose Next we need the lisp to bring in some text for the selected level i.e creating text with the remark DL. Once we have one code for this lisp we can then alter this to bring in other remarks such as CL WHL CHL USB etc etc. Then we can customise each lisp with a button in CAD. One Last thing is the lisp below creates a Cross from two drawn lines. Does anyone know how to make this a separate entity like a Symbol/Block and change it so its square to the model space unlike the current cross If anyone can help with this it would be fantastic and heavily aid our workflow. The code below is as Lee Mac has posted (defun c:ptlab (/ Text _PromptWithDefault _Cross Pt pos) ;; Lee Mac ~ 30.03.10 (defun Text (pt hgt str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 7 (getvar 'TEXTSTYLE)) (cons 1 str)))) (defun _PromptWithDefault (f arg d) (cond ((apply f arg)) (d))) (defun _Cross (p h / l) (setq l (sqrt (* 0.5 h h))) (mapcar (function (lambda (p1 p2) (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2))))) (list (polar p (/ pi 4.) l) (polar p (/ (* 3 pi) 4.) l)) (list (polar p (/ (* 5 pi) 4.) l) (polar p (/ (* 7 pi) 4.) l)))) (setq *Coord* (cond (*Coord*) ("Y")) *tHgt* (cond (*tHgt* ) ((getvar 'TEXTSIZE))) *thOff* (cond (*thOff*) (0.15)) *tvOff* (cond (*tvOff*) (0.15)) *cSze* (cond (*cSze* ) ((getvar 'TEXTSIZE)))) (setq pos '(("X" . 0) ("Y" . 0) ("Z" . 2))) (initget "X Y Z") (mapcar (function set) '(*Coord* *tHgt* *thOff* *tvOff* *cSze*) (mapcar (function _PromptWithDefault) '(getkword getdist getdist getdist getdist ) (list (list (strcat "\nSpecify Coord to Label [X/Y/Z] <" *Coord* "> : ")) (list (strcat "\nSpecify Text Height <" (rtos *tHgt*) "> : ")) (list (strcat "\nSpecify Horizontal Text Offset <" (rtos *thOff*) "> : ")) (list (strcat "\nSpecify Vertical Text Offset <" (rtos *tvOff*) "> : ")) (list (strcat "\nSpecify Cross Height <" (rtos *cSze*) "> : "))) (list *Coord* *tHgt* *thOff* *tvOff* *cSze*))) (while (setq pt (getpoint "\nPick Point to Label <Exit> : ")) (_Cross (setq pt (trans pt 1 0)) *cSze*) (Text (polar (polar pt 0. *thOff*) (/ pi 2.) *tvOff*) *tHgt* (rtos (nth (cdr (assoc *Coord* pos)) pt)))) (princ)) Thanks in Advance Mark
×
×
  • Create New...