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. LISP to query MS SQL Server Database return results as list of strings. (defun getMySqlData ( Name / ) (setq pm Name SQLCon "Server=OurServer;Database=engineering;Trusted_Connection=True" SQLStatement1 "USE enginering SELECT ID FROM Projects WHERE ProjectName = pm" SQLStatement2 "USE enginering SELECT * FROM LineList WHERE ProjectID = ResultsID" ) ; I'm trying to use SQLStatement1 to get the project ID. ; So that I can use it to run this SQLStatement2 ; Then return the results of the above as a list of strings. )
  2. I have tried several combination and gone thru about a 100 posts but I can't figure out what I am doing wrong. I am filtering thru objects and pulling out a 3D coordinate from the database. Then I am turning that into a 3 point list (x y z). Then I want to create a list of those points and add to them to the existing list as the program filters thru the remaining objects from the selection set. (progn (setq unitpoint_orig (vl-string-right-trim ";" (substr (vlax-get entvla 'points) 12))) (if (and(or (= Z_pref "Y")(= Z_pref "y"))(/= Z_height nil)) (progn (setq unitpoint_mod (comma_pull unitpoint_orig "REAL_NUM")) (setq unitpoint (list (car unitpoint_mod) (cadr unitpoint_mod) (caddr Z_height))) ) (setq unitpoint (comma_pull unitpoint_orig "REAL_NUM")) ) (setq unitpoint_lst (append unitpoint_lst 'unitpoint)) ;(command "insert" pl_block unitpoint "1" "1" "0") ) Current Result: (105.13 3165.22 0.0 105.13 3194.65 0.0 105.13 3142.5 0.0) Desired Result: ((105.13 3165.22 0.0)(105.13 3194.65 0.0)(105.13 3142.5 0.0)) Once I get this part working, I am then planning on filtering for duplicates using Lee Mac's subroutines. Then inserting based off those points.
  3. Does anyone have any knowledge on how to extract the point information from a CADMEP entity without having the CADMEP information? Our clients give us there files and we have to place blocks at each hanger. Extracting the coordinates to populate the blocks would be a huge time saver.
  4. Hello All, I have been seeking an individual to write an AutoLISP program for some time using the normal routes, but given availability and contact it has lead me to this forum to see if anyone would be interested. There is a detailed scope available. However in brief; the task requires generation of multiple dwg for a laser marker containing text and hatches from an excel file that contains multiple batches of such data. Before I post anything further, I'd like to check if such discussions are welcome here...
  5. Hello! I just stared working in AutoLISP a few days ago, and I've come across a problem. I need to create a dimension line where the dimension value is dependent on an input value. So if the input is y, then the text on the dimension line should equal 4.5*(y+1) inches, and it also needs to have a character width of 0.75. Currently, it just displays 4 1/2". As I understand it, this would be a real number, meaning I can't concatenate it with the inches symbol. Any help would be greatly appreciated! (defun c:retan (/ p1 p2 p3 p4 x y i j)(setvar "osmode" 0) (setq p1 (getpoint "\nfirst corner of rectangle: ")) (setq x (getint "\nEnter Horizontal Count: ")) (setq y (getint "\nEnter Vertical Count: ")) (setq p3 (list (+ (+ 1.625 (* 0.8125 (- x 1))) (car p1))(+ (+ 1.625 (* 0.8125 (- y 1))) (cadr p1)))) (setq p2 (list (car p1)(cadr p3))) (setq p4 (list (car p3)(cadr p1))) (command "pline" p1 p2 p3 p4 "c") ;c closes the rectangle's fourth side (entmakex (list (cons 0 "DIMENSION") (cons 100 "AcDbEntity") (cons 8 "E-DIMS") ;; 8 Layer (cons 100 "AcDbDimension") (cons 10 (list (- (car P1) 0.7) (cadr P2) 0)) ;; 10 Arrow Node (cons 11 (list (- (car P1) 0.9) (/ (+ (cadr P2)(cadr P1)) 2) 0)) ;; 11 Text Position (cons 70 160) (cons 1 "{\\W0.75;4 1/2\"}") ;; 1 Contents of Dimension Textbox (cons 71 5) ;; 71 Text Alignment (5=centered) (cons 42 0.8125) (cons 53 1.5708) ;; 53 Text Rotation (cons 3 "REW-1_.125txt") (cons 100 "AcDbAlignedDimension") (cons 13 P1) ;; 13 point on line (cons 14 P2) ;; 14 point on line (cons 50 1.5708) ;; 50 Angle (radians) 1.5708 (cons 100 "AcDbRotatedDimension"))) (setvar "osmode" 16383)(princ) )
  6. Hi folks, I need help on fixing the arrowhead. Some drawings come with default setting for Arrowheads as OPEN. When I run an utility (which inserts a leader with custom texts as a block), it inserts arrowheads as open. My requirement is to add Solid arrowheads always. I tried to force it via below code but its not forcing. Can anyone suggest? What could be wrong? (defun Addleader (/ pt1) (setvar "DIMLDRBLK" ".") (while (setq pt1 (getpoint "\nInserting task description note, Specify Arrow End Point or hit Enter to close:")) (Command "_INSERT" "CP TEXT" pt1 "" "" "") (command "explode" "l") );end while ) ;end defun EDIT: I think it has to do something with the default DIMSTYLE. And the block I'm trying to insert it on the Standard dim style. Not sure how to handle this.
  7. I wrote a sub-routine to update drawing borders. There is a command in CADWorx called IGO which creates isometric drawings. I wanted have this command call my function which updates the borders. But my code doesn't work. (defun c:igo ( / ) (setvar "cmdecho" 0) (command "igo") (setvar "cmdecho" 1) (runisoborderupdate) (princ) )
  8. I want to inform you that BabaCAD is updated and you can download new 1.3 release at official website http://www.babacad.com or you can read great reviews at softandapps.info (spain), 4cad.info (poland), download.cnet.com etc... Most important to tell about this new release is AutoLisp compatibility (for most .lsp files). LISP is available as free extension module and you can download it from babacad website. LISP is beta and next updates will come with missing functions and fixes. LISP module comes with examples loaded at startup (chcolor.lsp, drawextent.lsp, gear.lsp). Users can edit bcad.mnu file for loading favorite lisp routines/commands and create custom toolbars (read bcad.mnu in support folder for details). defun c:mycommand (/ var1 var2) is supported so you can define custom commands. Regards, Mirza
  9. In a function how do you get it to not go any further? The code below doesn't exit the function. (if (or (= dir (getroot)) (= dir (strcat (getroot) "\\Titleblocks"))) (progn (princ "\nHey you’re not allowed to delete files from this folder! ") end ) ) Apparently end doesn’t do what I thought it did . . .
  10. If using a Partial customization file that is still in the process of being updated regularly or you’d like that option to updated it, is the best practice to load it via the acad.lsp and your loader through the acad.lsp?
  11. Do you need a separate .dcl file to load each dialog box?
  12. WPerciful

    DCL Questions

    I have 2 questions about a dialog box I wrote. 1. The drop down boxes aren’t wide enough to display all of the text. How do I fix this? 2. Currently in order to select a second line in the list box you have to hold down the shift key. How can I change it so that the selections remain selected without holding down the control key? The command that luanches the dcl (defun c:bprint ( / ) (setq retlist1 nil) ;;; lm:directorydialog ;;; Author: Lee Mac, Copyright © 2013 - www.lee-mac.com ;;; (setq thedirectory (lm:directorydialog "Select folder: " nil 0)) (if (/= thedirectory nil) (setq List1 (vl-directory-files thedirectory "*.dwg")) end ) (setq List2 (list "")) (batch thedirectory List1 List2) (if (/= retlist1 nil) (progn (if (/= (findfile "BPlotData.txt") nil) (setq filedata (readfile (findfile "BPlotData.txt") ) files (cdr filedata) batchplotfiles (list ) ) ) (foreach file files (setq batchplotfiles (append batchplotfiles (list (strcat "open \"" thedirectory "\\" file "\" (mybatchprint) ZOOM E close Y") ) ) ) ) (makefile (strcat (strcat "C:\\Users\\" (getvar "loginname") "\\Documents") "\\" "BatchPlot.scr" ) batchplotfiles ) (command "_.script" (strcat "C:\\Users\\" (getvar "loginname") "\\Documents\\BatchPlot.scr") ) ) ) ) The function the runs the dcl (defun batch ( mydir lista listb / prin ) (setq dir mydir poplist1 (list ) mylist1 lista mylist2 listb ) (setq poplist1 (getplotters) poplist2 (getplotstyles) ) (if (not (setq dcl_id (load_dialog "batch.dcl"))) (progn (alert "The DCL file could not be loaded!") (exit) ) (progn (if (not (new_dialog "batch" dcl_id)) (progn (alert "The BATCH definition could not be loaded!") (exit) ) (progn (start_list "poplist1" 3) (mapcar 'add_list poplist1) (end_list) (start_list "poplist2" 3) (mapcar 'add_list poplist2) (end_list) (start_list "mylist1" 3) (mapcar 'add_list mylist1) (end_list) (action_tile "pickdir" " (setq pickdir \"Yes\")(done_dialog 1)") (action_tile "accept" "(saveVars)(done_dialog 2)") (action_tile "cancel" "(done_dialog 3)") (setq ddiag (start_dialog)) (unload_dialog dcl_id) (if (= ddiag 1) (princ "\nSelect directory . . . ") ) (if (= ddiag 2) (princ "\nPlease wait. . . ") ) (if (= ddiag 3) (princ "\nBatch print has been cancelled! ") ) ) ) ) ) (princ) ) The DLC code batch : dialog { : boxed_column { : row { : popup_list { label ="Choose printer"; key = "poplist1"; height = 15; width = 30; multiple_select = true; fixed_width_font = true; value = "0"; } } : row { : popup_list { label ="Choose plot style table"; key = "poplist2"; height = 15; width = 30; multiple_select = true; fixed_width_font = true; value = "0"; } } : list_box { label ="Choose Item"; key = "mylist1"; height = 15; width = 25; multiple_select = true; fixed_width_font = true; value = ""; } : row { : button { key = "accept"; label = " Print "; is_default = true; } : button { key = "cancel"; label = " Cancel "; is_default = false; is_cancel = true; } } } }
  13. I was making a centerline tool acts kind of like a polyline. The routine will continue to call itself until it no longer gets a value for the getpoint. But that doesn’t exit cleanly. Please help! (defun clin ( point / pt1 pt2 ) (if (/= point nil) (if (= (vl-symbol-name (type point)) "LIST") (progn (setq pt1 point pt2 (getpoint "\nSpecify next point: " pt1) ) (command "line" pt1 pt2 "") (clin pt2) ) ) (princ) ) (princ) )
  14. AutoLISP and VisualLISP expert required for developing and improving our company’s custom LISP routines? We are an Architectural firm and create all our drawings (Plans, Sections, Elevations and Details) in 2D with “Color based plotting (CTBs)”. We mainly use vanilla AutoCAD 2006-2013 and also have BDS Premium subscription. We have a legacy process where we assemble our 2D architectural drawings in a “multi-layered cake” kind of format. Each level/floor has same few layers (e.g. Lvl 1 = W_1, N_1 H_1, Lvl 2 = W_2, N_2, H_2). We use CTB for plotting and have a collection of very simple legacy AutoLisp routines that do the following: • Create new layers per our standards • Isolate layers in modelspace or pspace viewports by the level • Deal with xRef layers • Basic polyline, area, etc. functions • Etc. The job involves developing a single AutoLISP file or a suite of files (*.lsp + *.dcl + *.arx + *.vlx). You will be explained the intent and desired end-result of each routine. You will have a free hand to come up with the code, algorithm and even suggest better ways of doing things. Maybe even adding to the repertoire of macros we have. Here are the criteria for the job. • Your work will be submitted to and evaluated by the CAD Managers and AutoLISP experts in the office. • The AutoLisp code should be well structured, logical, efficient and well documented so we can “tweak” it in future. • The code should be “future proof”, portable and cognizant of changes that AutoDESK can make to AutoCAD in the future • You may suggest newer interface features and ARX/.NET/VBA in addition to DCL for improving the interface. • You will have access via RDP (remote desktop) to our environment (Mixed AutoCAD and ACA 2013) for testing and debugging. • You will use exisiting built-in features, express tools and “open source”internet code rather than re-inventing the wheel. • Generic AutoCAD Architecture features (e.g. AEC Modify Tools) can be used when they are the best option. The quality of your work may lead to an ongoing relationship and contract work. Thank you in advance for your interest and consideration.
  15. How can we copy an object in a drawing and paste it at multiple places using Autolisp. I have a dwg template that having many symbols in it. i have to use that symbols again and again in drawing. which symbol i want to use i select it than right click and copy and paste where i want to use. same thing happens for all the symbols whenever i need them. can we directly copy a particular object (hatch symbols, block etc) and paste it wherever we need it using Autolisp. We don't want to go to the original symbol location to select it and copy it to paste where we want to use it using Autolisp.: roll:
  16. Hi everyone, this is a new plugin for AutoCAD: http://www.yourspreadsheets.co.uk/yourlisp.html It helps me load all lisp files in selected folders, rather than add one by one as AutoCAD Startup Suite. Then, I don't need to copy all my lisps to 1 file, but keep my lisp library in an organized tree hierarchy, while still be able to load them easily.
  17. Does any body have any idea how can we find out the Text and Polyline intersection location using Autolisp? It will be better if we can mark error circles on a perticular layer on the intersection. Thanks in advance
  18. Hi All, I'm doing a lisp and trying to display an error message on the screen to whats wrong and why it can not continue. Here are my error message. It should only be one displayed. Currently its doing both of these. Can someone let me know why its doing this? "*** Error *** Drawing unit is not Metric. Try Inch option" "*** Error *** Drawing unit is not Inches. Try Metric option" Please excuse my "NOT-SO-CLEAN" LISP coding method. I have posted truncated LISP and some of the defun mentioned here are not attached. Thanks, (defun C:PRES2A (/ OIU Dunits) (setq OIU (getvar "insunits")) (initget "I M") (setq Dunits (getkword "\nIs this Inch template or Metric? (I,M) <Inches>:")) (if (= Dunits nil) (setq Dunits "I")) (if (and (= Dunits "I") (= OIU 1) (not (tblsearch "LAYER" "FORMAT")) ) (progn (Inch) (blkrem) (alert "\nblocks cleaning complete.") ); end progn (princ "\n*** Error *** Drawing unit is not Inches. Try Metric option") );end if (if (and (= Dunits "M") (= OIU 4) (not (tblsearch "LAYER" "FORMAT")) ) (progn (Metric) (blkrem) (alert "\nBlocks cleaning complete.") ); end progn (princ "\n*** Error *** Drawing unit is not Metric. Try Inch option") );end if (princ) ) ; end of program
  19. Hi all, I'm stuck inside the while loop and can't come out of it. Can someone help me on this (if possible please provide information on why its not closing). This is just a small function of a much larger lisp that I'm playing with and Esc to exit means complete program termination. Here is how I inteded it to be used for. Once user decides to use drawshapes, and if the answer is one of the keyword (eg. Rectangle) then user should be able draw as many rectangles he likes and if Enter is hit it should come back to main menu again ask for keyword to choose (circle or ellipse). Thanks in advance. (defun drawshapes (/ dtype) (setvar "cmdecho" 1) (setq dtype T) (while dtype (initget (+ 2 4) "R P C E") (prompt "\n*** Enter option R, P, C, E ***") (setq dtype (getkword "\nselect your option: Rectangle, Pline, Circle, Ellipse or hit Enter to close:")) (if dtype (cond ( (= dtype "R") (setq loop T) (while loop (command "_.rectang") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ( (= dtype "P") (setq loop T) (while loop (command "_.PLINE") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ( (= dtype "C") (setq loop T) (while loop (command "_.circle") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ( (= dtype "E") (setq loop T) (while loop (command "Ellipse") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ); end cond ); end if ); end while (setvar "cmdecho" 0) );end defun
  20. Hi to all, I'm curious to know which editor you guys use for Autolisp codes. What all are out there. I'm currently using Notepad and I do not find that easy at all. I havent tried Vlide yet...are there any better options? Thanks,
  21. Hi all, I have a small question here. Is it possible in autoCAD (or via lisp) that when I draw a polyline and when I reach the first point again (from where I have started), the command terminates and give me a closed polyline. And if I dont reach to the first point, it automatically closes to the first point. This is just me make sure I'm not keeping the loop open for hatching? Any help is appriciated.
  22. Hi to all, So, this is my lisp. It does the following: 1) Adds revision clouds to multiple entities 2) Adds Layer (or create if required and add properties) 3) Adds hatch 4) Inserts a block for leader and text (already formated) I have very limited knowledge of the lisp. As you can see I have copied few different codes and combined it to make it work for my application. It works but I know this is not systematic at all. I dont know if my error handeling is correct. One thing that I wish to add is if the revision cloud is too big or too small, it should allow to do that without closing and undoing everything. In other sense, I need undo and reset arc length option in this. Can someone help me on this please? (defun c:RVC6 (/ *error* oce mflag ans) ;************************************Error handling********************************************* (defun *error* (msg) (setvar "cmdecho" OCE) (setq *error* nil) (princ "\nRevision cloud program is done.") (princ) ) ;************************************Program begins********************************************* (setq OCE (getvar "cmdecho") OOS (getvar "osmode") ) (setvar "cmdecho" 0) (setq mflag nil) (while (not mflag) (prompt "\n*** Enter option C, H, L, or E ***") (initget 0 "Cloud Hatch Leader Exit") (setq Ans (getkword "\nconvert to revision Cloud/Hatch/Leader/<Exit>: ")) (if (= Ans nil) (setq Ans "Exit") ) ;end if (cond ( (= Ans "Cloud") (convcloud) ) ( (= Ans "Hatch") (Addhatch) ) ( (= Ans "Leader") (Addleader) ) ( (= Ans "Exit") (setvar "cmdecho" OCE) (setvar "osmode" OOS) (quit) ) ) ;end cond );end while );end defun ;************************************Program ends********************************************** ;*******************************Start of "convcloud" program*********************************** (defun convcloud (/ al ss) (initget (+ 2 4)) (setq al (getreal "Specify Arc length <0.5>:")) (if (= al nil) ;If user do not input a value here (setq al 0.5) ;Consider "Enter" as 0.5 ) ; end if (if (setq ss (ssget '((0 . "LINE,*POLYLINE,CIRCLE,ELLIPSE,SPLINE,ARC")))) (progn (repeat (setq i (sslength ss)) (command "_.revcloud" "a" al al "" (ssname ss (setq i (1- i))) "") (if (not (tblsearch "LAYER" "CONSTRUCTION")) (command "-layer" "N" "CONSTRUCTION" "C" "1" "CONSTRUCTION" "LT" "continuous" "CONSTRUCTION" "") ) ; end if (command ".-layer" "S" "CONSTRUCTION" "C" "red" "" "") (Command "Chprop" "l" "" "la" "CONSTRUCTION" "C" "BYLAYER" "Lt" "BYLAYER" "LW" "BYLAYER" "") );end repeat (princ "\nRevision cloud(s) created on CONSTRUCTION layer.") );end progn (princ "\nNo objects selected.") ) );end defun ;*******************************End of "convcloud" program************************************* ;*****************************Start of "Addhatch" Program ************************************* (defun Addhatch (/ htype selset thisobj setlen entname) (initget 1 "D R") (setq htype (getkword "\nSpecify hatch type? Demo(D)/Rebuild(R):")) (if (= htype "D") (setq htype "ANSI31") ) ;end if (if (= htype "R") (setq htype "DOTS") ) ;end if (princ "\nSelect object(s) to hatch:") (setq selset (ssget)) (if selset (progn (setq thisobj 0) (setq setlen (sslength selset)) (while (< thisobj setlen ) (setq entname(ssname selset thisobj)) (Command "-bhatch" "Advanced" "Style" "Outer" "" "") (command "-bhatch" "p" htype "3" "" "s" entname "" "") (if (not (tblsearch "LAYER" "CONSTRUCTION")) (command "-layer" "N" "CONSTRUCTION" "C" "1" "CONSTRUCTION" "LT" "continuous" "CONSTRUCTION" "") ) ; end if (command ".-layer" "S" "CONSTRUCTION" "C" "red" "" "") (Command "Chprop" "l" "" "la" "CONSTRUCTION" "C" "BYLAYER" "Lt" "BYLAYER" "LW" "BYLAYER" "") (setq thisobj(+ thisobj 1)) ) ; end while (alert "\n ***WARNING*** Hatching could not skip the inner objects. To solve this, Double click hatch and `Add: select objects' and select inner object & click OK") ) ; end progn ) ;end if selset (princ "\nNo objects selected.") );end defun ;*******************************End of "Addhatch" program************************************* ;*****************************Start of "Addleader" Program *********************************** (defun Addleader (/ pt1) (while (setq pt1 (getpoint "\nInserting task description note, Specify Arrow End Point or hit Enter to close:")) (Command "_INSERT" "CP TEXT" pt1 "" "" "") (command "explode" "l") );end while );end defun
  23. Hi, all: I have a trouble with dealing Insert entity. I got a "Block" named "AA", which have one "lwpolyline" entities inside. And then I insert it with "scaling & rotating". The problem is, if I want to get the current outline of "Insert". My process is as below. 1. get "Block entity" from "Insert entity" 2. get "lwpolyline" from "Block entity" 3. transform the "lwpolyline" by vla-transformby(...) function with "Insert entity" rotation, scale ... parameters 4. draw the renewed "lwpolyline" on drawing as outline It works, but I think it cost a lot of times. Is there any convenient way to do this? thanks!
  24. dalivore

    Autolisp Help

    Does anyone know how to create a lisp that will export a csv file with object data and coordinates? Example; od field 1, od field 2,etc... x1,y1,z1,x2,y2,z2,etc.... Ideally it should be able to report all object data fields irregardless of the number. And it should report all xyz coordinates of polylines. I would also need a lisp to import csv files from the above format. If your curious this is all in an attempt to solve the 4 coordinate limits that map3d puts on exporting shape files... If someone has an alternate solution to that, I'm all ears! Dalivore
  25. Hey All, Okay so I have s dynamic block (green in my example) that is built in the x-y plane. I can change its length, width, extend it and rotate it about the base point. Yada yada yada. Bunch of feature that the company I work for needs. When we insert it into a 3D model we position it such that the Y axis becomes the Z axis and the the X axis can be anywhere within the the X-Y plane. I am trying to create a lisp that will move it relative to a second block (red in my example). Does any know a way to get the rotational information for the dynamic blocks. I can't use the "Rotation" from the misc section since it operate in the blocks x-y plane instead of the models x-y plane. I created an image below with Axis. To hopefully clarify. These aren't the actual blocks just example shapes. Hopefully someone can help. I have tried a few things without success.
×
×
  • Create New...