Jump to content

Search the Community

Showing results for tags 'autolisp'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...

  1. What command can I use to find a block by its name in my drawing and then delete it?
  2. Hi, I'm trying to query the variable "Weight" and if it has the content "50" I want to define a new variable: "Stamp" with the content "internal". Is WCMATCH the right command for this? (if (= wcmatch Weight "50") (progn (setq stamp "intern"))) (princ)
  3. Hi all, I am trying to write a lisp that will create a DropDown list in Autocad. With the selection from the fields I want to execute different commands that I have defined before. (defun c:create_dropdown () (setq choise1 command1) (setq choise2 command2) (setq choise3 command3) (setq choise4 command4) (strcase (initget (getkword [choise1/choise2/choise3/choise4])))) )
  4. Hello all. I need a lisp that will merge all layouts, that start with a certain name, into one PDF file. I have already made some progress with this Lisp. With the dwgprops I get information about the current file path, which I then merge all with the stract command. This also works, only the command "-Export" "ak" can only print one sheet. The number of layouts that start with "Plan..." are always different. Does anyone have an idea which command works instead for publish all Layouts, that beginns with the same name? The -publish command always asks me for a dsd file. (defun c:Documentsheets ( / pdfName ) (vl-load-com) ;--------- get variabel für contact - number: (setq acadObject (vlax-get-acad-object)) (setq acadDocument (vla-get-ActiveDocument acadObject)) (setq dProps (vlax-get-Property acadDocument 'SummaryInfo)) (vla-getCustomByIndex dProps 4 'myValue1 'myValue2) (setq contact myValue2) (princ) ;--------- get variable for order - number: (setq acadObject (vlax-get-acad-object)) (setq acadDocument (vla-get-ActiveDocument acadObject)) (setq dProps (vlax-get-Property acadDocument 'SummaryInfo)) (vla-getCustomByIndex dProps 5 'myValue1 'myValue2) (setq order myValue2) (princ) ;-------- (setq Pathone "\\\\company.lan\\xyz\\erp\\land\\contact\\") (setq Pathtwo "\\order\\") (setq Paththree "\\folder\\") ;-------- (command "_Qsafe") (foreach layname (vl-remove-if-not '(lambda (ln) (vl-some '(lambda (n) (wcmatch ln n) ) '("Plan*") ) ) (layoutlist) ) (setvar "ctab" layname) (setq pdfName (strcat Pathone Contact Pathtwo Order Paththree (strcat order "_Drawing") ) ) ) (if (findfile pdfName) (command "-EXPORT" "PDF" "Ak" "N" pdfName "J") (command "-EXPORT" "PDF" "Ak" "N" pdfName) ) )
  5. Hello, After a sidestep to Clojure, of course back to AutoLisp. I have quite some exeperience with AutoLisp and on and off I worked with it for almost 20 years now. (Auto)Lisp is known amongst AutoCAD users but further on, the whole lisp-thing doesn't ring a bell with most programmers that I meet. They work with SQL, HTML, XHTML, Java, C# or maybe (V)BA. I stayed interested in Lisp, although limited to AutoLisp. Recently. I discovered that there is a new Lisp called Clojure that is becoming big in the programming world. Possibly due to the fact that it translates to Java or javascript before anything is executed. But this aside. I learned that Clojure is first class because it is capable of accepting a function as a parameter and clojure functions can produce functions. There's a whole lot more to be discoverd about this great language but I leave that to the reader. The subject 'Clojure' is easily found on the web. By taking this interest in Clojure I learned a lot about AutoLisp too. On this page at the subject of 'Closures' halfway the page, there is an example showing how a function is produced in Clojure. Realy, it took me quite some time to grasp it. After that I wanted to know if this could be done with AutoLisp as well. After trials with defun-q-list-set/ref (which also work) I came up with the following. Hart of the solution is (eval (append '(lambda . . Is it the best way to do this? I don't know. Is it useful? I doubt it but see below. Is it interesting? Highly (for me!) (defun messenger-builder (greeting) (setq greeting (strcat "\n" greeting " ")) (eval (append '(lambda (who)) (list (list 'princ (list 'strcat greeting 'who)) '(princ))))) (setq hello-er (messenger-builder "Hello") goodbye-er (messenger-builder "Goodbye")) (defun c:greet_the_world () (hello-er "World!")) (defun c:say_goodbye () (goodbye-er "Everyone!!")) AutoLisp does a great job in AutoCAD. Perfect, but as a Lisp it is less thoroughly designed than Clojure. This shows off in the example above. Clojure handles the subject of producing functions easier. Maybe my example is ill-constructed. I could not find a better solution. Question also is, can we think of any usufull application of this in AutoCAD. Although I took another route in the example, the designated functions for this are (I think) defun-q-list-set/ref. I suppose they are there for a reaon. Or is it all limited to the s::startup example?
  6. Hi to all. I really appreciate the content of this page and so I wanted to ask if anyone has any idea how we could use AutoLISP to design a water supply and sewerage system in our floor plan. Thanks in advance.
  7. Hi Guys, I have several layouts when drawing, which also have different names. I want to save in a Lisp all layouts that start with a specific name in a certain folder as PDF. I am new in lisp, but i have managed to write a lisp that selects the correct location for me. Unfortunately only all layouts are printed. (defun c:Dokument_Export () (command "-EXPORT" "PDF" "ALLE" (strcat (substr (getvar "DWGPREFIX") 1 70) "\\08_Auftragsbestätigung\\" (strcat (substr (getvar "DWGNAME") 1 8) "_Zeichnung") ) ) ) You have any idea? Thanks in advance.
  8. Hello everyone! So, i am doing a school project in which i want to select all circles of a given radius and then move them all in the arithmetic mean of all centers. The arithmetic mean is no problem, everything works fine, till i add the "more complex" filter. Here is the part of the code: (initget 7) (setq radius (getint "\nEnter radius: ")) (setq ss (ssget "X" '((0 . "CIRCLE") (-4 . "=") (40 . radius)))) The thing is, when i swap (40 . radius) with, lets say, (40 . 10)... it works for all circles with the radius equal to 10. But i want to give the radius by keyboard. And i get the error from the title. Also... if i put a (princ radius) before the filter, it shows me the value of radius.
  9. Hello everyone, is there anyone who have lisp routine for drawing clothoides (spirals) between two arcs or "S" curve and who is willing to share it? I hope so that is not to much to ask for. Best Regards!
  10. 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é
  11. hello all;I'm using the code bellow, but i need to click on almost 2000 road cross sections one by one, indeed that is time consuming. it would be more general if the code can select all green lines at ones and then the red lines. mean that, if there be 2000 road cross sections for example; the code can select all cross sections and report a cut and fill file separately for each section (the same as AreaLabelV1-9.lsp of Mr.Lee Mac does)appreciate if anyone can help metnx ;;; Cut & Fill by ymg ; ;;; ; (defun c:cf (/ ** *acdoc* a are b bnd c cutcol d dir dl1 dl2 e fillcol hcol intl len1 len2 p p0 p1 p2 pm pol1 pol2 sp1 sp2 spe ss1 ss2 totcut totfill txt txtlayer varl) (vl-load-com) (defun *error* (msg) (mapcar 'eval varl) (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*"))) (princ (strcat "\nError: " msg)) ) (and *acdoc* (vla-endundomark *acdoc*)) (princ) ) (setq varl '("OSMODE" "CMDECHO" "DIMZIN" "PEDITACCEPT") varl (mapcar (function (lambda (a) (list 'setvar a (getvar a)))) varl) ) (or *acdoc* (setq *acdoc* (vla-get-activedocument (vlax-get-acad-object)))) (vla-startundomark *acdoc*) (setvar 'CMDECHO 0) (setvar 'DIMZIN 0) (setvar 'OSMODE 0) (setq cutcol 1 fillcol 3 ; Cut is Red, Fill is Green ; totcut 0 totfill 0 ; Total Cut and Total Fill ; txtlayer "Text" ; Name of Layer for Cut and Fill Values ; ) (while (not (setq ** (princ "\nSelect Reference Polyline:") ss1 (ssget "_+.:L:S" '((0 . "LWPOLYLINE"))) ) ) (princ "\nYou Must Select a Polyline:") ) (while (not (setq ** (princ "\nSelect Proposed Polyline:") ss2 (ssget "_+.:L:S" '((0 . "LWPOLYLINE"))) ) ) (princ "\nYou Must Select a Polyline:") ) (setq pol1 (ssname ss1 0) len1 (vlax-curve-getDistAtParam pol1 (vlax-curve-getEndParam pol1)) pol2 (ssname ss2 0) len2 (vlax-curve-getDistAtParam pol2 (vlax-curve-getEndParam pol2)) sp1 (vlax-curve-getstartpoint pol1) spe (vlax-curve-getendpoint pol1) sp2 (if (vlax-curve-isClosed pol2) (setq lst2 (listpol pol2) disl (mapcar '(lambda (a) (distance sp1 a)) lst2) ** (plineorg pol2 (nth (vl-position (apply 'min disl) disl) lst2)) ) (vlax-curve-getstartpoint pol2) ) dir (if (< (/ pi 2) (angle sp1 spe) (/ (* 3 pi) 2)) -1 1) ) ; Getting all the intersections between poly. ; (setq intl (intersections pol1 pol2)) (if (> (length intl) 1) (progn ; Computing distance of intersections on each polyline ; (setq dl1 (mapcar '(lambda (a) (getdistoncurve pol1 a)) intl) dl2 (mapcar '(lambda (a) (getdistoncurve pol2 a)) intl) ) ; If both polyline are closed add first Intersection to end of list ; ; We also add a distance to each distances list ; (if (and (vlax-curve-isClosed pol1) (vlax-curve-isClosed pol2)) (setq dl1 (append dl1 (list (+ (car dl1) len1))) dl2 (append dl2 (list (+ (car dl2) len2))) intl (append intl (list (car intl))) dir (if (iscw_p (listpol pol1)) -1 1) ) ) ; Finding points at mid-distance between intersections on each polyline ; ; Calculating midpoint between mid-distance points to get an internal point; ; Creating a list of all these points plus the intersection points ; (setq pm (mapcar '(lambda (a b c d e) (list (midpoint (setq p1 (getptoncurve pol1 (rem (* (+ a b) 0.5) len1))) (setq p2 (getptoncurve pol2 (rem (* (+ c d) 0.5) len2))) ) p1 p2 e ) ) dl1 (cdr dl1) dl2 (cdr dl2) intl ) ) (foreach i pm (setq p (car i) ; Midpoint between p1 p2 ; p0 (cadddr i) ; Intersection Point ; p1 (cadr i) ; Midpoint of Intersections on Reference Polyline ; p2 (caddr i) ; Midpoint of Intersections on Proposed Polyline ; ) (if (> (abs (onside p2 p0 p1)) 1e-3) ; Not Colinear ; (progn (vl-cmdf "._-BOUNDARY" p "") (setq are (vla-get-area (vlax-ename->vla-object (entlast))) bnd (entlast) ) (if (minusp (* (onside p2 p0 p1) dir)) (setq totfill (+ totfill are) hcol fillcol) (setq totcut (+ totcut are) hcol cutcol) ) (vl-cmdf "._-HATCH" "_CO" hcol "." "_P" "SOLID" "_S" bnd "" "") (entdel bnd) ) ) ) (setq p (cadr (grread nil 13 0)) txt (strcat "{\\C3;Fill: " (rtos totfill 2 2) " m2\\P\\C1;Cut: " (rtos totcut 2 2) " m2}") ) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 8 txtlayer) (cons 100 "AcDbMText") (cons 10 p) (cons 40 3.0) (cons 1 txt) ) ) (command "_MOVE" (entlast) "" p pause) ) (Alert "Not Enough Intersections To Process !") ) (*error* nil) ) (princ "\nCalculates Cut & Fill Between Two Intersecting Polylines") (princ "\nCF to start...") (defun midpoint (p1 p2) (mapcar '(lambda (a b) (* (+ a b) 0.5)) p1 p2) ) ; onside by ymg ; ; Negative return, point is on left of v1->v2 ; ; Positive return, point is on right of v1->v2 ; ; 0 return, point is smack on the vector. ; ; ; (defun onside (p v1 v2 / x y) (setq x (car p) y (cadr p)) (- (* (- (cadr v1) y) (- (car v2) x)) (* (- (car v1) x) (- (cadr v2) y))) ) ; ; ; Is Polyline Clockwise by LeeMac ; ; ; ; Argument: l, Point List ; ; Returns: t, Polyline is ClockWise ; ; nil, Polyline is CounterClockWise ; ; ; (defun iscw_p (l) (if (equal (car l) (last l) 1e-8) (setq l (cdr l))) (minusp (apply '+ (mapcar (function (lambda (a b) (- (* (car b) (cadr a)) (* (car a) (cadr b)))) ) l (cons (last l) l) ) ) ) ) ;; ; ;; Return list of intersection(s) between two VLA-Object or two ENAME ; ;; obj1 - first VLA-Object ; ;; obj2 - second VLA-Object ; ;; mode - intersection mode (acExtendNone acExtendThisEntity ; ;; acExtendOtherEntity acExtendBoth) ; ;; Requires triplet ; ;; ; (defun Intersections (obj1 obj2) (or (= (type obj1) 'VLA-OBJECT) (setq obj1 (vlax-ename->vla-object obj1))) (or (= (type obj2) 'VLA-OBJECT) (setq obj2 (vlax-ename->vla-object obj2))) (triplet (vlax-invoke obj1 'intersectwith obj2 acExtendNone)) ) ;; ; ;; triplet, Separates a list into triplets of items. ; ;; ; (defun triplet (l) (if l (cons (list (car l) (cadr l) (caddr l))(triplet (cdddr l)))) ) (defun getdistoncurve (e p) (vlax-curve-getDistatParam e (vlax-curve-getparamatpoint e (vlax-curve-getclosestpointto e p) ) ) ) (defun getptoncurve (e d) (vlax-curve-getpointatparam e (vlax-curve-getparamatdist e d)) ) ;; ; ;; listpol by ymg (Simplified a Routine by Gile Chanteau ; ;; ; ;; Parameter: en, Entity Name or Object Name of Any Type of Polyline ; ;; ; ;; Returns: List of Points in Current UCS ; ;; ; ;; Notes: On Closed Polyline the Last Vertex is Same as First) ; ;; ; (defun listpol (en / i l) (repeat (setq i (fix (1+ (vlax-curve-getEndParam en)))) (setq l (cons (trans (vlax-curve-getPointAtParam en (setq i (1- i))) 0 1) l)) ) ) ;; plineorg by (gile) (Modified into a function by ymg) ; ;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ ; ;; change-polyline-start-point/td-p/2154331 ; ;; ; ;; Function to modify origin of a closed polyline ; ;; ; ;; Arguments: ; ;; en : Ename or VLA-Object of a Closed Polyline. ; ;; pt : Point ; ;; ; ;; Returns: Point of Origin if successful, else nil. ; ;; ; (defun plineorg (en pt / blst d1 d2 d3 n norm obj pa plst) (if (= (type en) 'ENAME) (setq obj (vlax-ename->vla-object en)) (setq obj en en (vlax-vla-object->ename obj)) ) ;; bulgratio by (gile) ; ;; Returns a bulge which is proportional to a reference ; ;; Arguments : ; ;; b : the reference bulge ; ;; k : the ratio (between angles or arcs length) ; (defun bulgratio (b k / a) (setq a (atan b)) (/ (sin (* k a)) (cos (* k a))) ) ;; Sublist by (gile) ; ;; Returns a sublist similar to substr function. ; ;; lst : List from which sublist is to be extracted ; ;; idx : Index of Item at Start of sublist ; ;; len : Length of sublist or nil to return all items. ; (defun sublist (lst n len / rtn) (if (or (not len) (< (- (length lst) n) len)) (setq len (- (length lst) n)) ) (setq n (+ n len)) (repeat len (setq rtn (cons (nth (setq n (1- n)) lst) rtn)) ) ) (if (and (= (vla-get-closed obj) :vlax-true) (= (vla-get-objectname obj) "AcDbPolyline") ) (progn (setq plst (vlax-get obj 'coordinates) norm (vlax-get obj 'normal) pt (vlax-curve-getClosestPointTo en (trans pt 1 0)) pa (vlax-curve-getparamatpoint obj pt) n (/ (length plst) 2) ) (repeat n (setq blst (cons (vla-getbulge obj (setq n (1- n))) blst)) ) (if (= pa (fix pa)) (setq n (fix pa) plst (append (sublist plst (* 2 n) nil) (sublist plst 0 (* 2 n)) ) blst (append (sublist blst n nil) (sublist blst 0 n)) ) (setq n (1+ (fix pa)) d3 (vlax-curve-getdistatparam en n) d2 (- d3 (vlax-curve-getdistatpoint en pt)) d3 (- d3 (vlax-curve-getdistatparam en (1- n))) d1 (- d3 d2) pt (trans pt 0 (vlax-get obj 'normal)) plst (append (list (car pt) (cadr pt)) (sublist plst (* 2 n) nil) (sublist plst 0 (* 2 n)) ) blst (append (list (bulgratio (nth (1- n) blst) (/ d2 d3))) (sublist blst n nil) (sublist blst 0 (1- n)) (list (bulgratio (nth (1- n) blst) (/ d1 d3))) ) ) ) (vlax-put obj 'coordinates plst) (repeat (setq n (length blst)) (vla-setbulge obj (setq n (1- n)) (nth n blst)) ) (trans pt 0 1) ) nil ) )
  12. So I've been at this Lisp Routine for a little while now. Done a lot of searching and researching. I'm almost at the finish line and I need some help with the last few steps. Or at least, the next to last step. So the ultimate goal here is to use our column grid to generate an indicator at intersections. Grid is created more or less by hand so it will always vary. I decided to use the method of placing blocks with attributes at selected column lines' intersections. I've taken care of selection issues of DTEXT vs MTEXT and assigning LINE objects with said TEXT objects. I've whittled down what I would call the big issues except for one. My final result has been a list of "pairs" like this example: (((-2376.0 -504.001 0.0) L) ((-2376.0 -504.001 0.0) ((-2016.0 -504.001 0.0) L) ((-2016.0 -504.001 0.0) 7.1)...) The first part of each item is a point list followed by the corresponding text/string to be used for the block attributes. Problem is I need to combine the items with the same point so that each item will be as follows (((-2376.0 -504.001 0.0) 8 L) ((-2016.0 -504.001 0.0) 7.1 L)...). Now I believe I can workout the order in which they are listed to suit my purposes, but I'm having trouble just combining the two strings with the same point. After this hurdle, I'll need to insert the block WITH those strings filling in the attributes, but I believe I can figure that part out. I've attached a drawing with a sample grid and the lisp routine I've pieced together so far. Here's the main portion of the code in case that's all someone needs: (defun c:setupint (/ mspc ss_txt ss_lines pntlst grdlst attlst i_pnt i_grd ob_pnt ob_grd pnt1 pnt2 pnt3 ob_strg blk) (setq mspc (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (and (princ "\nSelect Grid Text: ") (setq ss_txt (ssget '((0 . "TEXT,MTEXT")))) (princ "\nSelect Grid Lines: ") (setq ss_lines (ssget '((0 . "LINE")))) (setq pntlst (SF:sortyx (LM:intersectionsinset ss_lines))) (setq grdlst (MT:GrdAcList ss_lines ss_txt)) ) (repeat (setq i_pnt (length pntlst)) (setq ob_pnt (nth (setq i_pnt (1- i_pnt)) pntlst)) (repeat (setq i_grd (length grdlst)) (setq ob_grd (nth (setq i_grd (1- i_grd)) grdlst) pnt1 ob_pnt pnt2 (vlax-curve-getStartPoint (cadr ob_grd)) pnt3 (vlax-curve-getEndPoint (cadr ob_grd)) ob_strg (car ob_grd) ) (if (LM:Collinear-p pnt1 pnt2 pnt3) (setq attlst (cons (list ob_pnt ob_strg) attlst)) ;list of text with corresponding point ) ) ;end repeat grd ) ;end repeat pnt ) (setq blk "setupint") (princ attlst) ;Test Print of list ;;; (foreach itm attlst ;;; (setq p (list (nth 0 (car itm)) (nth 1 (car itm)) (nth 2 (car itm)))) ;;; (princ p) ;;; (vla-insertblock mspc (vlax-3D-point p) blk 1.0 1.0 1.0 0) ;;; ) ) (vl-load-com) (princ) SETUP TEST.dwg setupintV2.lsp
  13. I want to change attribute text in title blocks, calling the block by the block name, not selecting the block, looping thru all the layout tabs. The title block will have the same name on each layout. My titleblock is named TITLEBLOCK30x42, with 2 attributes SHEET-TITLE and SHEET-DESCRIPTION. This thread talks about doing the same thing. None of the small generic code posted in that thread works for me. https://www.cadtutor.net/forum/topic/63734-lisp-code-to-select-block-in-layouts-and-update-attributes/
  14. Hi I work in a company, people come to us with their plot registry, on which are the dimensions (north,east,south,west) and area of their plots. But there are no angles. For example, a plot of 25 * 10 meters with an area (according to the mathematical calculations) should be 250 square meters. But 244.95 is listed on the registry.My question is how do I quickly draw this plot (according to the registry) in AutoCAD? Is there any lisp for this?
  15. Hello guys! New to the forum but have been looking at this forum for help for a few years now and has been very helpful for my auto cad education and career! I have this lisp routine that creates a pline in each side of the original pline to create this stormwater pipe. I've been trying to figure out how I can start the offset from the bottom line instead of the middle pline to no avail. Is there anyone that help me with this? Changing the justification of the dragline could save me hours creating details for work. Thanks a bunch! ; STORMWATER.LSP (defun c:SWPIPE () ;(/ PT PT1 PT2 WID ELAST KTEMP E1 E2 ang1 ang2) (setvar "CMDECHO" 0) (initget 1) (setq PT (getpoint "\nStart point: ")) (command ".PLINE" PT "W" 0 0) (setq PT1 PT PT0 PT) (while (setq PT (getpoint PT "\nNext point: ")) (setq PT2 PT) (command PT) ) (setq ang1 (-(angle pt1 pt2)(/ pi 2)) ang2 (+ ang1 pi)) (command) (SETQ OS (GETVAR "OSMODE")) (setvar "osmode" 0) (initget 4) (setq ELAST (entlast) KTEMP (getdist "\nLine width<0.0>:") WID ktemp ; WID (* (if KTEMP KTEMP 0.0416) (GetVar "LTSCALE"));old UserR1 ; PT1 (reverse (cdr (reverse PT1))) ) (command ".OFFSET" (/ WID 2) (list ELAST PT1) (polar PT1 ang1 0.1)"") (setq E1 (entlast)) (command ".OFFSET"(/ WID 2) (list ELAST PT1) (polar PT1 ang2 0.1) "") (setq E2 (entlast)) (command ".PEDIT" ELAST "W" WID "" ".CHANGE" ELAST"" "P" "LT" "HIDDEN1" "") (redraw E1) (redraw E2) (princ)S (setvar "osmode" 0) ) SWPIPE.LSP
  16. Hi all, I want to select specific block by knowing its name lets say block name "cadtutor block 1" by using (vl-catch-all-apply) method Thanks
  17. marc578

    Draw circles

    Hi, this is my first post. I am trying to draw five circles, one in the centre (x=0, y=0) and the other four, located in each quadrant of circle located in (0,0). I have written the script below but, I does not work. The circles with negative coordinates are drawn on top of the other with positive coordinates. I do not understand, why is this behavior, if you know please let me know. (defun C:he () (setq r 10.0) (command "circle" (list 0 0) r "") (command "circle" (list 5 0) r "") (command "circle" (list -5 0) r "") (command "circle" (list 0 5) r "") (command "circle" (list 0 -5) r "") ) Thanks
  18. Hi guys, I'm new to this forum and new to programming with lisp - please be kind.... The code I am writing will draw a 3dPolyline from a specific point to another point (usually with a lower z coordinate), the polyline will then be converted to a spline, a circle will be drawn at the start of the 3dPolyline and extruded along the spline to form a "curved tube". The intention is to use this as a flexible duct from a "spigot" on an A/C duct to a ceiling diffuser. The 3dPoly has to be perpendicular to the start point and end point for obvious reasons - see intentional misalignment picture. Below a portion of the unfinished code to select the start point, select the endpoint, then it must start drawing the 3dpoly from the start point, get a variable number of user input points (in order to define the initial direction and plane) and general path of the flexible duct. The end point of the 3dpoly is already defined with the initial selection of the "Endpoint on Diffuser" although the 2nd last point has to be mathematically determined considering the plane must be perpendicular to the end point. So - after selecting say 3 or 4 user defined points along the path, I want to be able to press enter, and the code must then calculate the 2nd last point and continue drawing the 3dpoly from the last picked point, to the calculated 2nd last point and then to the endpoint. Generally one has to be mindful that the curve of the tube cannot have a "sharp bend" - smooth curves are ideal for the airflow. The diameter of the tube will also change depending on the specific size requirements. Attached a small drawing and picture to show the intent. The crux of my problem: I cannot figure out how to start the 3dpoly command, make it pick the start of the line, then hand over to the user to continue picking 4 or 5 points, press enter, and then continue drawing the 3dpoly with calculated numbers? Would really appreciate some guidance. Maybe use of cmdactive? I really do not know enough to figure this one out. (defun C:Flex250 () (command "_.layer" "_thaw" "HVAC Flex" "_make" "HVAC Flex" "") (setq Prev_OM (getvar "OSMODE")) (setvar "OSMODE" 8) (setq StartPoint (getpoint "\nEnter Start Point on Duct Spigot : ")) (setq EndPoint (getpoint "\nEnter End Point on Diffuser : ")) (setq Z0 (caddr EndPoint)) (setq Z1 (+ (caddr EndPoint) 50)) (setq Z2 (+ (caddr EndPoint) 150)) (setq pt0 EndPoint) (setq pt1 (list (car EndPoint) (cadr EndPoint) Z1)) (setq pt2 (list (car EndPoint) (cadr EndPoint) Z2)) (SetVar "Elevation" (princ (caddr StartPoint))) (command ".3DPoly" (princ Startpoint) (getpoint "\nNext point : ") pt2 pt1 pt0) ) Then a last question - is there a way to ensure the spline's start and finish points are 100% perpendicular to the planes they connect to? Thank you in advance for your input. Test.dwg
  19. Good Day, I want the attached code to run as QDIM in Autocad , My issue in my code that I choose the location of the dimension line after that the dimension appears. I want to see all the dimensions afterwards choose the location like in QDIM command. Thanks (vl-load-com) (defun C:FH ( / *error* doc oVAR ss i pts ptsx ptsy d d0 filter ) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break")) (princ (strcat "\nError: " errmsg))) (foreach e oVAR (setvar (car e) (cdr e))) (vla-endundomark doc) (princ)) ;------------------------------------------------------------------------------------------------------ (vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (foreach e '(CMDECHO ORTHOMODE) (setq oVAR (cons (cons e (getvar e)) oVAR))) (setvar 'CMDECHO 0) (setvar 'ORTHOMODE 0) (if (and (princ "\nNeed blocks, ") (setq ss (ssget (list '(0 . "INSERT")))) (< 1 (setq i (sslength ss))) (while (not (minusp (setq i (1- i)))) (setq pts (cons (cdr (assoc 10 (entget (ssname ss i)))) pts))) (setq ptsx (vl-sort pts '(lambda (p q) (< (car p) (car q))))) (setq ptsy (vl-sort pts '(lambda (p q) (< (cadr p) (cadr q))))) (setq d (abs (/ (- (car (last ptsx)) (caar ptsx)) ;xmax-xmin (if (zerop (setq d0 (- (cadr (last ptsy)) (cadar ptsy)))) ;ymax-ymin 0.001 d0)))) (setq pt (getpoint "\nSpecify dimension line location: ")) (or *DimTypeBDA (setq *DimTypeBDA "Aligned")) (not (initget "Horizontal Vertical Aligned")) (setq *DimTypeBDA (cond ((getkword (strcat "\nType of dimension [" (cond ((> d 1000.) (if (= *DimTypeBDA "Vertical") (setq *DimTypeBDA "Horizontal")) "Horizontal") ((< d 0.001) (if (= *DimTypeBDA "Horizontal") (setq *DimTypeBDA "Vertical")) "Vertical") ("Horizontal/Vertical")) "/Aligned] <" *DimTypeBDA ">: "))) (*DimTypeBDA))) (setq pts (if (or (= *DimTypeBDA "Horizontal") (and (= *DimTypeBDA "Aligned") (> (- (car (last ptsx)) (caar ptsx)) (- (cadr (last ptsy)) (cadar ptsy))))) ptsx ptsy)) (setq i 0) ) (repeat (1- (length pts)) (cond ((= *DimTypeBDA "Horizontal") (command "_.DIMLINEAR" "_none" (nth i pts) "_none" (nth (1+ i) pts) "_H" "_none" pt)) ((= *DimTypeBDA "Vertical") (command "_.DIMLINEAR" "_none" (nth i pts) "_none" (nth (1+ i) pts) "_V" "_none" pt)) (T ;Aligned (command "_.DIMALIGNED" "_none" (nth i pts) "_none" (nth (1+ i) pts) "_none" pt))) (setq i (1+ i))) (princ (strcat "\nError: Wrong selection of at least 2 BLOCKS."))) (foreach e oVAR (setvar (car e) (cdr e))) (vla-endundomark doc) (princ) ) FH Final.LSP
  20. Dear Team member, I have more number of BOQ table in Auto Cad. Need to export that table and text to excel in editable format. Can anyone help and share the lisp for export cad text / table in excel. Thanks. Mohan
  21. I work for a glazing company where we do all our glass sizing manually and am looking for a way to do it automatically. I am not very knowledgeable in Lisp. So we have a block we use to put the sizes into. I was wondering if it is possible for a lisp to read the size of a rectangle that has the block inside of it and put dimensions into the specified area. The block also has multiple Visibility's to fit in different places. There is also multiple visibility's for the reason that I made it for multiple people with different preferences. (See dwg. file below for block). Is this at all possible? Callout_GL.dwg
  22. Hi, I need help. My AutoLISP works well in DWG To PDF but it comes out 1 file per 1 DWG. I want it to be the only PDF file. Can somebody help me with something? (I can't use third party programs) Thank you for your help. The examples are in my attachments. My_Plot.LSP Test.dwg
  23. I can convert my raw AutoLISP (.lsp) codes into Visual Lisp (.VLX) and .FAS application using AutoCAD VLISP IDE. I was looking into Autodesk App Store and downloaded some of the free applications. It was .msi. That means it will install directly on Windows and link-up with installed AutoCAD. I am very new in the App Store. Could you please help me to understand to convert my .lsp or .vlx or .fas into .msi? Thanks.
  24. I did a program in Autolisp, so I want to encript that in order to avoid hacks. What would you recommend me? Because I want rent it. Im a beginner, so I dont know to much about the topic. Thanks to much for your advices
  25. Hello Dear Friends, how to do the automatically offset in between two lines offset centerline for all. kindly find the attached for sample image with drawing. if anyone knows lisp please help me. I am using AutoCAD 2017 Thanks Amarendra HVAC sample Offset.dwg
  • Create New...