Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/22/2024 in all areas

  1. Another Example: I wrote this back in the 90's (believe it or not) and still maintain it for drawing ANSI plug gages. It fully draws everything with Visual LISP. I Don't even use it anymore, but it's a good resource that I use as a test bed for trying out better code, and keeping myself exercised in LISP programming.
    2 points
  2. There are many ways to skin this cat (cond ((and txt (wcmatch (cdr (assoc 0 (entget txt))) "*TEXT")) also works.
    2 points
  3. I don't know about the OP, but I tried that and it didn't work. I also tried using (entupd) and that also doesn't change it even thought the actual entity list shows the changed values. Also, if you use the properties pallet and update the closed status, it updates everything correctly.
    1 point
  4. Honestly - I attempted at one time to make code for altering splines with (entmake), trying to account for all the changes. I failed miserably! Using the activeX methods and properties are MUCH easier.
    1 point
  5. Cad's entmake lisp is probably the closest thing your going to get. you just select what you want and it will generate the entmake code. Why not have a template drawing or lee mac's Steal lisp with the steal all option?
    1 point
  6. Once you get the DWG, you can use ENTGET to transform an entity in a list of DXF codes. Yes, you could walk in the AutoCAD's database and transform the entities one by one. But probable you should include the nongraphic entities too. Say if a line must be placed on an inexistent layer, AutoCAD will create that layer "on the fly". But you must deal with text styles, dimstyles and so on. Also if there are inserts, you must define the blocks first. About the Xrefs -better don't even mention it. To make the long story short: in theory it's possible, for some drawings it is easier, for other ones is more complicated.
    1 point
  7. I have moved your thread to the AutoLISP, Visual LISP & DCL Forum.
    1 point
  8. guys, You have been most helpful. I now have further things and leads to study. Thank You very much
    1 point
  9. Good comment Johnathan, like the old saying crawl, walk then run. The array part can still be used.
    1 point
  10. I think it's more of a practice. It's their first code after all. Always good to start somewhere.
    1 point
  11. Another why not draw 1 and use array ? (defun c:stamps (/ w h c r a b pt) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "Enter values " "Width " 5 4 "100" "height " 5 4 "100" "Number columns" 5 4 "5" "Number rows" 5 4 "5" "Dist between columns" 5 4 "20" "dist between rows" 5 4 "20"))) (setq w (atof (nth 0 ans)) h (atof (nth 1 ans)) c (atoi (nth 2 ans)) r (atoi (nth 3 ans)) a (atof (nth 4 ans)) b (atof (nth 5 ans)) ) (setq pt (getpoint "\nPick lower left point for rectang ")) (command "_RECTANG" "_non" pt "_non" (list (+ (car pt) w) (+ (cadr pt) h))) (command "array" (entlast) "" "Rectangular" r c (+ b h) (+ a w) ) (princ) ) Multi GETVALS.lsp
    1 point
  12. Just as the above has shown, it completely works. There are other ways as well, but since you have just started using AutoLISP, I thought I'd leave some comments: (defun c:stamps ( / _getfunc a b c h offset r start w) (defun _getfunc (fnc msg bit) ;; Define a function to make use of initget. ;| Initget is a function which can be used to restrict numerical user inputs: https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-9ED8841B-5C1D-4B3F-9F3B-84A4408A6BBF |; (initget bit) (fnc msg) ) (and ;| Using 'and' introduces the short-circuit evaluation, in which conditional processsing stops as soon as the first value returns nil. All get- functions (except getstring) returns nil upon pressing Enter |; (setq w (_getfunc getdist "\nEnter the width of the rectangle <exit>: " 6)) ;; A value of 6 (bits 2 and 4) ensure that the user enters a positive value and not 0 (setq h (_getfunc getdist "\nEnter the height of the rectangle <exit>: " 6)) ;; Using getdist allow the user to also specify two points to define the distance. (setq c (_getfunc getint "\nEnter the number of columns <exit>: " 6)) (setq r (_getfunc getint "\nEnter the number of rows <exit>: " 6)) (setq a (_getfunc getdist "\nEnter the distance between columns <exit>: " 4)) (setq b (_getfunc getdist "\nEnter the distance between rows <exit>: " 4)) ;; Comment one line or the other depending on the insertion point being located at (0.0 0.0), or to a point specified by the user. ;(setq start '(0.0 0.0)) (setq start (getpoint "\nSpecify point to place rectangles <exit>: ")) (progn (setq offset '(0.0 0.0)) (repeat r (repeat c (command "_RECTANG" "_non" (mapcar '+ start offset) "_non" (mapcar '+ start offset (list w h))) (while (not (zerop (getvar "cmdactive"))) (command "")) ;; This ensure that the Space/Enter key keeps getting pressed until the command is over. ;; Not entirely necessary, but I always use it for good practise. (setq offset (list (+ (car offset) w a) (cadr offset))) ) (setq offset (list 0.0 (+ (cadr offset) h b))) ) ) ) (princ) ;; Exit the command quitely. Always use this, good common AutoLISP programming practise for a clean command line exit. )
    1 point
  13. another way as fuccaro stated using wildcards: (cond ((and txt (wcmatch (cdr (assoc 0 (entget txt))) "TEXT,MTEXT"))
    1 point
  14. Fuccaros code tests for text being selected, if you want text OR mtext you need to change the check line: (cond ((and txt (= (cdr (assoc 0 (entget txt))) "TEXT")) to include (or....) Untested replace with something like this: (cond ((and txt (or (= (cdr (assoc 0 (entget txt))) "TEXT") (= (cdr (assoc 0 (entget txt))) "MTEXT") ) ; endor ) ; end and
    1 point
  15. This should work. (defun c:pp() (setq txt (car (entsel))) (cond ((and txt (= (cdr (assoc 0 (entget txt))) "TEXT")) (command "copy" txt "" pause pause) (command "textedit" "L" "") ) (t "wrong selection")) ) It can be improved...
    1 point
×
×
  • Create New...