Jump to content

Leaderboard

  1. BIGAL

    BIGAL

    Trusted Members


    • Points

      263

    • Content Count

      14,287


  2. Lee Mac

    Lee Mac

    Trusted Members


    • Points

      128

    • Content Count

      20,585


  3. Tharwat

    Tharwat

    Trusted Members


    • Points

      89

    • Content Count

      6,959


  4. steven-g

    steven-g

    Trusted Members


    • Points

      88

    • Content Count

      2,701



Popular Content

Showing content with the highest reputation since 04/22/2020 in all areas

  1. 6 points
    Just a note to say thanks for maintaining this site. It's a pleasure to come here, read a question, type out a response and see it instantly appear to help the other user(s). Image attachments via drag+drop work flawlessly too. It is noticed and appreciated. Cheers!
  2. 5 points
    Also the best users, mods and admin!
  3. 5 points
    I agree also great forum, the biggest out there is the worst site and they just dodge around the edges of the problems by saying contact our support request department
  4. 5 points
    Totally inappropriate response Jamin. Good luck with your next CAD problem. The members who have posted in this thread include 2 forum moderators and collectively have a total of about 65,000 posts.
  5. 4 points
    Hi @rkmcswain and all who have commented - thanks for your kind words. It has been a pleasure to keep this forum in good order over so many years (the CADTutor site is 25 years old this year!). Naturally, a forum isn't anything without its members, so I thank you all, in return, for being such a great community who continue to post brilliant content and .give your time freely to help others. Long may it continue!
  6. 4 points
    For what it's worth, here's an existing program to handle elliptical arcs too.
  7. 4 points
    Having a bit of spare time, I thought I would make a hatch pattern similar to the OS marsh block marsh1.pat
  8. 4 points
    Options, User Preferences, Right Click Customization, put a check mark in the upper left box 'turn on time-sensitive right-click. Also look into the system variables added in 2021 so with trim or extend you won't have to use the RMB or hit enter.
  9. 4 points
    Give this a try .. welcome to CadTutor (defun c:foo (/ a d el s) ;; RJP » 2020-05-18 (vlax-for l (vla-get-layers (setq d (vla-get-activedocument (vlax-get-acad-object)))) (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a)))) ) (if (setq s (ssget "_X" '((0 . "DIMENSION")))) (foreach e (mapcar 'cadr (ssnamex s)) (vlax-for a (vla-item (vla-get-blocks d) (cdr (assoc 2 (setq el (entget e))))) (entmakex (append (entget (vlax-vla-object->ename a)) (list '(8 . "Busted_Dims") '(62 . 8) (assoc 410 el)) ) ) ) ;; Entdel does not work on layouts (vl-catch-all-apply 'vla-delete (list (vlax-ename->vla-object e))) ) ) (foreach l a (vlax-put l 'lock -1)) (princ) ) (vl-load-com)
  10. 3 points
    This seems to work: (setvar 'measurement 1) (command "._-SCALELISTEDIT" "_Reset" "_Yes" "_Exit")
  11. 3 points
    I wasn't aware there were any others. I must get out more!
  12. 3 points
  13. 3 points
    Perhaps this? http://www.lee-mac.com/steal.html
  14. 3 points
    Sounds like you need a new draftsman. Can they explain exactly what the concern is about? Since what I draw on company time belongs to the company, I am required to send what my bosses ask me to send.
  15. 3 points
    Deleting all write-enabled dimensions (i.e. those residing on unlocked layers) from a drawing is relatively straightforward and can be achieved by iterating over the drawing database and deleting all objects whose objectname property matches "AcDb*Dimension*", as the following code demonstrates: (defun c:deldim ( ) (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (= :vlax-false (vla-get-isxref blk)) (vlax-for obj blk (if (and (wcmatch (vla-get-objectname obj) "AcDb*Dimension*") (vlax-write-enabled-p obj)) (vla-delete obj) ) ) ) ) (princ) ) (vl-load-com) (princ) The above will remove all dimensions from all layouts & block definitions. However, deleting MText containing specific words isn't quite so easy, as the MText content could potentially be interspersed with MText formatting codes, which would need to be removed prior to testing whether the content contains one of the target words.
  16. 3 points
    You can achieve this using the wildcard not operator ("~") : (sssetfirst nil (ssget "_X" (list '(0 . "TEXT,MTEXT") '(1 . "~*NOTAS PARTICULARES*") (cons 410 (getvar 'ctab))))) However, if you wanted to exclude multiple patterns by separating the patterns using a comma (e.g. "PATTERN1,PATTERN2") you should note that the not operator will only apply to the first wildcard pattern in the delimited string (e.g. "~PATTERN1,PATTERN2" will still include "PATTERN2") : _$ (wcmatch "PATTERN1" "~PATTERN1,PATTERN2") nil _$ (wcmatch "PATTERN2" "~PATTERN1,PATTERN2") T And so if you were looking to exclude multiple patterns, you could use either: (sssetfirst nil (ssget "_X" (list '(0 . "TEXT,MTEXT") '(-4 . "<NOT") '(1 . "PATTERN1,PATTERN2") '(-4 . "NOT>") (cons 410 (getvar 'ctab))))) Or: (sssetfirst nil (ssget "_X" (list '(0 . "TEXT,MTEXT") '(1 . "~PATTERN1") '(1 . "~PATTERN2") (cons 410 (getvar 'ctab))))) Since the filter list for an ssget expression implements an implicit AND logic.
  17. 3 points
  18. 3 points
    The duplicate elements present in each list make this task slightly trickier than it would otherwise be - here is an alternative solution: (defun f ( a b ) (mapcar '(lambda ( x / z ) (setq z b) (list x (foreach y x (setq z (LM:removeonce y z)))) ) a ) ) (defun LM:removeonce ( x l / f ) (setq f equal) (vl-remove-if '(lambda ( a ) (if (f a x) (setq f (lambda ( a b ) nil)))) l) ) _$ (f a b) ( ((750.0 500.0 500.0) (400.0)) ((750.0 500.0 400.0) (500.0)) ((750.0 500.0 400.0) (500.0)) ((500.0 500.0 400.0) (750.0)) ((750.0 500.0) (500.0 400.0)) ((750.0 500.0) (500.0 400.0)) ((750.0 400.0) (500.0 500.0)) ((500.0 500.0) (750.0 400.0)) ((500.0 400.0) (750.0 500.0)) ((500.0 400.0) (750.0 500.0)) ((750.0) (500.0 500.0 400.0)) ((500.0) (750.0 500.0 400.0)) ((500.0) (750.0 500.0 400.0)) ((400.0) (750.0 500.0 500.0)) )
  19. 3 points
    Use an alphanumerical sorting function to interpret & sort numerical data within the string, rather than sorting character-wise, e.g. to sort layouts alphanumerically, you might use: (defun c:sortlayouts ( / ls1 ls2 ord ) (vlax-for lyt (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (if (= :vlax-false (vla-get-modeltype lyt)) (setq ls1 (cons (strcase (vla-get-name lyt)) ls1) ls2 (cons lyt ls2) ) ) ) (setq ord 0) (foreach idx (LM:alphanumsort-i ls1) (vla-put-taborder (nth idx ls2) (setq ord (1+ ord))) ) (princ) ) ;; Alphanumerical Sort-i - Lee Mac ;; Sorts a list of strings containing a combination of alphabetical & numerical characters and returns the indices. (defun LM:alphanumsort-i ( lst ) (vl-sort-i (mapcar 'LM:splitstring lst) (function (lambda ( a b / x y ) (while (and (setq x (car a)) (setq y (car b)) (= x y) ) (setq a (cdr a) b (cdr b) ) ) (cond ( (null x) b) ( (null y) nil) ( (and (numberp x) (numberp y)) (< x y)) ( (numberp x)) ( (numberp y) nil) ( (< x y)) ) ) ) ) ) ;; Split String - Lee Mac ;; Splits a string into a list of text and numbers (defun LM:splitstring ( str ) ( (lambda ( l ) (read (strcat "(" (vl-list->string (apply 'append (mapcar (function (lambda ( a b c ) (cond ( (or (= 34 b) (= 92 b)) (list 32 34 92 b 34 32) ) ( (or (< 47 b 58) ;(and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)) ) (list b) ) ( (list 32 34 b 34 32)) ) ) ) (cons nil l) l (append (cdr l) '(( ))) ) ) ) ")" ) ) ) (vl-string->list str) ) ) (vl-load-com) (princ)
  20. 3 points
    Concrete hatch has for a long time been a disappointment for some. The reason being that people are hatching some concrete in Svalbard in a drawing that has its origin on the equator and using mm as units! When one looks at the hatch definition, the distances and angles are not defined to enough decimal places. So I thought I would try and see if I could do better using trigonometry to calculate the amounts. Non-rational numbers need to be defined to as many decimal places as possible if they are to be used a long way from the origin. But the hatch definition file has a line limit of 80 characters. Any longer than that, and one gets a warning in AutoCAD. Here is the file definition and a picture of the hatch a long way from the origin. Those able enough can copy the file and overwrite the supplied Concrete Hatch. *aaconc, updated concrete hatch (random dot and stone pattern) 50, 0,0, 4.1297503417,-5.8978947189, 0.75,-8.25 355, 0,0, -2.0378120728,7.3723683986, 0.60,-6.6 100.4514447435,.598,-.0523,5.73058713914,-6.93976736215,0.63740192,-7.0114211171 46.1842,0,2,6.19462551259,-8.84684207832,1.125,-12.375 96.6356447435,.889,1.862,8.5958807087,-10.4096510432,0.9561028796,-10.5171316757 351.1842,0,2,7.7432818907,11.0585525979,.9,-9.9 21,1,1.5,4.1297503417,-5.8978947189,0.75,-8.25 326,1,1.5,-2.0378120728,7.3723683986,0.6,-6.6 71.4514447435,1.497,1.164,5.73058713914,-6.93976736215,0.6374019197,-7.011421117 37.5, 0,0, 2.123,2.567, 0,-6.52,0,-6.7,0,-6.625 7.5, 0,0, 3.123,3.567, 0,-3.82,0,-6.37,0,-2.525 -32.5, -2.23,0, 4.6234,2.678, 0,-2.5,0,-7.8,0,-10.35 -42.5, -3.23,0, 3.6234,4.678, 0,-3.25,0,-5.18,0,-7.35 *eldon
  21. 3 points
    The Rectangle command is just a command that creates a 4 sided polygon using the length and width dimensions that you provide. Once the command is finished, you're left with a closed polyline. That's why, when you select the rectangle and look at its properties, it lists the object as a polyline, not a rectangle. So there are no length or width values.
  22. 3 points
    If you like this way then just let me know to write such a working routine for you for free.
  23. 3 points
    This (sub)function is part of a larger appie I'm currently working on (not sure how I'm gonna name the larger app yet , for now called it RlxBlockSync but also entertaining the idea to call RFD, redefine for dummies ) Anyways, this sub dynamically creates a dialog and takes 'commatized' strings for input. Few years ago I wrote Tokkie, this basically does the same , just a little different and with less code. I was inspired by a similar function master L created and later Grrr made something like that. The reason I use commatized / csv strings is so I can save the output of this function as a string in the registry. Added little test function which generates 3 list boxes but you can have as many LB's as you like, the only limitations are your imagination and the width of your monitor. I hope by analyzing the test function (c:t1) you understand how you can use this function. ; multiple input listbox function : mlist = ( ( description1 (labels1) (defaults1) ) ...) (defun milf ( mlist / get_lb_width commatize de-commatize _ufo toggle fn fp dcl lb-width old-props new-props plist tmp out) ; get max strlen from list arguments for milf (defun get_lb_width (l) (apply 'max (mapcar 'strlen (apply 'append (mapcar 'de-commatize (mapcar 'cadr l)))))) ; (commatize '("a" "b" "c")) -> "a,b,c" (defun commatize (l) (apply 'strcat (cdr (apply 'append (mapcar '(lambda (x) (list "," x)) l))))) ; (de-commatize "a,b,c") -> ("a" "b" "c") (defun de-commatize (s / p)(if (setq p (vl-string-search "," s))(cons (substr s 1 p)(de-commatize (substr s (+ p 2))))(list s))) ; use filter on : (_ufo "*" '("door" "table" "floor")) (_ufo "o" '("door" "table" "floor")) (defun _ufo ( f l ) (if (and (= (type f) 'STR) (/= f "")) (vl-remove-if '(lambda (s)(not (or (eq f "*") (vl-string-search (strcase f)(strcase s))))) l))) ; adds / removes [0] or [X] before each item in listboxes (defun toggle (k v / lst r s) (if (eq (substr (setq r (nth (atoi v) (setq lst (cdr (assoc k plist))))) 2 1) "X") (setq s "[O] ") (setq s "[X] ")) (setq plist (subst (cons k (setq lst (subst (strcat s (substr r 5)) r lst))) (assoc k plist) plist)) (start_list k)(mapcar 'add_list lst)(end_list)(set_tile k v)) ; calculated width of list boxes by finding longest string (setq lb-width (+ (get_lb_width mlist) 5)) (if (not (setq fp (open (setq fn (vl-filename-mktemp ".dcl")) "w"))) (princ "\nUnable to create temporary dcl file") (progn (write-line "milf:dialog {label=\"Multiple Input Listbox Function (RLX 5/'20)\";:row {" fp) (setq lb 0) (foreach item mlist (write-line (strcat ":column {label=\"" (car item) "\";:list_box{height=16;width=" (itoa lb-width) ";key=\"lb" (itoa (setq lb (1+ lb))) "\";}}") fp)) (write-line "}ok_cancel;}" fp)(if fp (progn (close fp)(gc))) (if (not (and (< 0 (setq dcl (load_dialog fn))) (new_dialog "milf" dcl))) (princ "\nUnable to start dialog milf") (progn (setq lb 0) (foreach item mlist (setq old-props (de-commatize (cadr item)) new-props (de-commatize (caddr item))) (setq l (mapcar '(lambda (x)(if (member x new-props)(strcat "[X] " x)(strcat "[O] " x))) old-props)) (setq lb-id (strcat "lb" (itoa (setq lb (1+ lb)))) plist (cons (cons lb-id l) plist)) (start_list lb-id) (mapcar 'add_list l) (end_list) (action_tile (strcat "lb" (itoa lb)) "(toggle $key $value)") ) (action_tile "accept" "(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)") (setq drv (start_dialog)) (unload_dialog dcl)(vl-file-delete fn) ) ) ) ) (if (= drv 1) (mapcar '(lambda (x)(commatize (mapcar '(lambda (y)(substr y 5)) x))) (mapcar '(lambda (x)(_ufo "[X]" x))(mapcar 'cdr (reverse plist)))) nil) ) (defun c:t1 ( / result-list animals breakfast music) (setq animals "Aardvark,Baboon,Camel,Dragons,Easterbunny,Firebird,Godzilla,Hobbit,Idiot,Phoenix") (setq breakfast "Anna Nicole,Beyoncé Knowles,Carmen Electra,Daenerys Targaryen,Ella Enchanted,Gal Gadot,Sophie Turner") (setq music "Andrea Bocelli,Electric Light Orchestra,Earth Wind & Fire,George Michael,Lara Fabian,Queen") (setq result-list (milf (list (list "Animals" animals "Dragons,Phoenix") (list "Breakfast" breakfast "Gal Gadot,Sophie Turner") (list "Music" music "Electric Light Orchestra,Lara Fabian") ;;; add as many list as you want limited only by the size of the screen ) ) ) (princ "\n\nYou made the following selections : ") (mapcar '(lambda (label value) (princ (strcat "\n\n" label "\nvalue : " value))) '("Animals :" "Breakfast :" "Music :" ) result-list) (princ "\n\n") (princ) ) I can show you how other app looks , but that's not finished yet (if ever) so will get back to that later Awell... hope I didn't forget any sub functions that are allways loaded automatically on my own pc (autoload & forget) but if so let me know (wouldn't be the first time I forgot something and probably not the last time) happy coding
  24. 3 points
    Sengna, you didn't drag the command bar, you merely stretched it. It is still covering your tabs. It appears that your command line is not docked nor is it locked into place. If it were locked you would not have been able to stretch the command line. If it were docked, it would not cover your tabs. Below are some helpful images. Before trying to move your command bar, click the aforementioned three bars in the lower left of the AutoCad window. Notice the list of selections. There is one called LOCKUI which means Lock User Interface. If it is not checked, you can move your AutoCad window elements including the command line. If it is checked you cannot move any of it. Once you get your command line docked, with the number of lines you need showing, go back and check LOCKUI so it won't move again.
  25. 3 points
    Customization
  26. 3 points
    Another one (defun disspacify (str / regexp) (if (setq regexp (vlax-get-or-create-object "vbscript.regexp")) (progn (vlax-put-property regexp 'global actrue) (vlax-put-property regexp 'pattern " +") (vlax-invoke regexp 'replace (vl-string-trim " " str) " ") ) ) ) _$ (disspacify " This is a normal string. ") "This is a normal string." _$ [Edit]: Why not full regular expression... Plus, the dot or comma inside the string needs special treatment: (defun disspacify (str / regexp) (if (setq regexp (vlax-get-or-create-object "vbscript.regexp")) (progn (vlax-put-property regexp 'global actrue) (foreach x '( (" +[.]|[.]" . ". ");"end ." to "end. " (" +[,]|[,]" . ", ");"mid ," to "mid, " (" +" . " ");replace multiple spaces ("^ +| +$" . "");remove start and end space(s) ) (vlax-put-property regexp 'pattern (car x)) (setq str (vlax-invoke regexp 'replace str (cdr x))) ) ) ) ) _$ (disspacify " This is a double sentence ,the other one is not .This is a normal string . ") "This is a double sentence, the other one is not. This is a normal string." _$
  27. 3 points
    another, delta (defun c:tt (/ p1 p2 en obj ) (and (setq p1 (getpoint "Specify point ")) (setq p2 (getcorner p1 "opposite corner ")) (setq en (entmakex (list '(0 . "LINE") (cons 10 p1) (cons 11 p2)))) (setq obj (vlax-ename->vla-object en)) (princ (strcat "\nArea=" (rtos (apply '* (mapcar '(lambda (a b) (+ a (abs b))) '(0 0) (vlax-get obj 'delta) ) ) 2 3 ) " M\U+00B2" ) ) (entdel en) ) (princ) ) WCS
  28. 3 points
    Thanks @Tharwat and @dlanorh and @ hanhphuc Sorry for my late reply The lisps were shown working great and I think beautiful thanks ALL
  29. 3 points
    @Dadgad, I figured you were being smart since I knew you are senior to me. Being referenced as a young gun definitely cracks me up. I thank you for the kind words. You were always the voice of reason and always treat the posters with professionalism and I learned from the best. I feel like I had an interesting career and tried to always learn and strive to do better. When I went from the board to AutoCAD I knew very little about the program, just what I could learn in a 2 month class at the community college. I was very worried about measuring up and consequently spent way too many hours away from work doing nothing much else but teaching myself more about AutoCAD. I remember when we did a presentation on AutoCAD in ~1991 using slides and creating a slide show. Everyone’s mind were blown and we were rock stars for a day or two. A few of us figured out how to create a virtual drive in the memory on our computers (~1990) and copy the AutoCAD.exe file there and then start the program. This was all done with a DOS file, I think it was called a batch file but my memory is not that great anymore. It was noticeably faster to do it that way and was possible back when the program was so small. Even though I learned on R9 the first company I worked for had bootleg copies of R8 (v2.6) and we used that for about a year. After that they bought R9 licenses and I was still able to copy the program and put it on my home computer, in fact my boss encouraged it. I have used Action Recorder a time or two but never really got into the habit of remembering it was there. It got better over the years and the few times I thought to use it I did like the result. In the bad old days of the early 90’s CADalyst magazine would publish a lisp file each month. I would copy those by typing what was printed and of course I would make at least two typos and the thing wouldn’t work. So off I went trouble shooting the lisp file and finally finding my mistakes. I did learn quite a bit about rudimentary lisp writing but I have forgotten most of that. These days if I need something I just look on Lee-Mac’s web site and can often find an awesome program that is light years ahead of what I could do. I have donated to his site a few times but certainly not near enough. The post of the ‘clipped’ viewports was not something I can claim credit for. I learned about that somewhere else and simplified what they had done and added step by step instructions. I will post the drawing since I do still have it. Digging up old posts of mine on the Ribbon: man I hated that when it first came out. I am often too quick to judge a new feature like that but with time and learning to customize it I definitely became a fan. I agree, there used to me more general questions from new users but I assume the number of new users of AutoCAD is going way down with the advent of BIM and 3D programs like Inventor. I can see myself still looking in and posting if I have something to offer. As you said, more questions on programming and fewer on actually using the program. Thanks again. viewport in viewport 2007.dwg
  30. 3 points
    Dadgad, I may be younger than you but I am 66 and retiring at the end of this week! (May 29,2020) I moved from board drafting in 1988 to AutoCAD V2.6 (R8) and over the years always tried to embrace the new commands and UI while keeping many old school functions. I like a good customized Ribbon and all the contextual tabs. Good luck everyone.
  31. 2 points
    Its not like that. The codes that I posted allow the user to select as many as they want then you need after that to iterate the selection set and do your stuff at each entity object. e.g: (if (setq ss (ssget '((0 . "*POLYLINE") (8 . "DWG_SHEET") (-4 . "<AND") (-4 . "&=") (70 . 1) (-4 . "AND>")))) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i)))) ;; one entity which is eaual to single selection like, (car (entsel "\nSelect object :")) ;; do your stuff here .... ) )
  32. 2 points
    version 2 ; Join end of 2 multiple lines convert to pline ; By Alan H March 2021 (defun c:joinends ( / pt1 pt2 start end swapends) (defun ah:swapends (pt / temp d1 d2 ent) (setq ent (entget (ssname (ssget pt)0 ))) (setq lay (cdr (assoc 8 ent))) (setq end (cdr (assoc 11 ent))) (setq start (cdr (assoc 10 ent))) (setq d1 (distance pt end)) (setq d2 (distance pt start)) (if (< d1 d2) (progn (setq temp end) (setq end start) (setq start temp) ) ) (command "erase" (cdr (assoc -1 ent)) "") (princ) ) (setq oldsnap (getvar 'osmode)) (prompt "\nPick points eg left and right of lines") (setq pt1 (getpoint "\Pick 1st point ")) (setq pt2 (getpoint pt1 "\Pick 2nd point ")) (setq lst (list pt1 pt2)) (setq ss (ssget "F" lst (list (cons 0 "*line")))) (setq lay (cdr (assoc 8 (entget (ssname ss 0))))) (setq lst2 '()) (repeat (setq x (sslength ss)) (setq ent (ssname ss (setq x (- x 1)))) (setq obj (vlax-ename->vla-object ent)) (setq pt3 (vlax-curve-getclosestpointto obj pt1)) (setq dist (distance pt1 pt3)) (setq lst2 (cons (list dist pt3) lst2)) ) (setq lst2 (vl-sort lst2 '(lambda (x y) (< (car x)(car y))))) (setq lst '()) (setq x 0) (setvar 'osmode 0) (repeat (/ (sslength ss) 2) (setq lst '()) (setq pt3 (nth 1 (nth x lst2))) (ah:swapends pt3) (setq lst (cons (list (car start) (cadr start))lst)) (setq lst (cons (list (car end)(cadr end)) lst)) (setq pt4 (nth 1 (nth (+ x 1) lst2))) (ah:swapends pt4) (setq lst (cons (list (car end)(cadr end)) lst)) (setq lst (cons (list (car start) (cadr start))lst)) (setq x (+ x 2)) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 8 lay) (cons 90 (length lst)) (cons 70 1)) (mapcar (function (lambda (p) (cons 10 p))) lst) ) ) ) (setvar 'osmode oldsnap) (princ) )
  33. 2 points
    Nice .. FWIW if you create the circle like so it will retain all by object properties too: (defun c:el2cir (/ cen cnt en ent maj mad) (if (setq ss (ssget '((0 . "ELLIPSE")))) (repeat (setq cnt (sslength ss)) (setq ent (entget (setq en (ssname ss (setq cnt (1- cnt)))) '("*")) cen (cdr (assoc 10 ent)) maj (cdr (assoc 11 ent)) mad (distance '(0.0 0.0 0.0) maj) ) (if (= (cdr (assoc 40 ent)) 1.0) ;; (progn (command "._circle" "_non" cen mad) (entdel en)) (and (entmake (append '((0 . "CIRCLE")) (vl-remove-if '(lambda (x) (vl-position (car x) '(-1 0 100 330 5 11 40 41 42))) ent) (list (cons 40 mad)) ) ) (entdel en) ) ) ) ) (princ) )
  34. 2 points
    I don't work in feet god bless metric makes life so much easier. Anyway my take on metres to feet. Tried to get distof to work. ; tol 1/16" (setq a 3.25 str "") (setq ar (/ a 0.3048)) (setq ai (fix (/ a 0.3048))) (setq b (- ar ai)) (setq str (strcat (rtos ai 2 0) "'")) (IF (> b (/ 0.0625 12.0)) (progn (setq c (* 12.0 b)) (setq inch (fix c)) (setq str (strcat str (rtos inch 2 0) "\"")) (setq frac (* (- c inch) 16.0)) (if (/= (fix frac) 0.0) (setq str (strcat str (rtos frac 2 0) "/16" )) ) ) ) (princ str)
  35. 2 points
    Since when does the draftsman decide what is going to be included in a drawing? If the company is obligated to provide a client with a drawing then they must do so or they risk losing the client's business. Ask the draftswoman to name the specific tools and techniques she is "unwilling" to share. Then remind her the company is not obligated to retain her as an employee.
  36. 2 points
    If you are a student, you can get an educational version free of charge, good for one year. You must provide proof that you are a student. See this page.
  37. 2 points
    The value of 0.924999...955 is a consequence of the accuracy problems associated with the double-precision floating-point format used to store real numbers in computer memory - this is described in more detail here, here, and here. Your code demonstrates one possible way to cater for this, however, note that your method would yield undesirable results for measurements such as 0.9249: _$ (rtos (distof (rtos 0.9249 2 3) 2) 2 2) "0.93" _$ (rtos 0.9249 2 2) "0.92" As such, a safer way to account for the rounding of doubles would be to add a small tolerance to the original value prior to rounding, e.g.: _$ (rtos (+ 1e-8 0.924999999999955) 2 2) "0.93" _$ (rtos (+ 1e-8 0.9249) 2 2) "0.92" However, note that retrieving the dimension measurement value and rounding to a given number of decimal places may still not yield a string which matches that displayed by the dimension, as a result of dimension style configuration - to obtain the value displayed by the dimension, you can obtain the MText content found within the dimension block, e.g.: ;; Get Dimension String - Lee Mac ;; Returns the displayed content of a dimension (defun LM:getdimstring ( ent / enx rtn ) (if (and (setq enx (entget ent)) (wcmatch (cdr (assoc 0 enx)) "*DIMENSION") (setq ent (tblobjname "block" (cdr (assoc 2 enx)))) (setq ent (entnext ent) enx (entget ent) ) ) (while (and ent (null rtn)) (if (= "MTEXT" (cdr (assoc 0 enx))) (setq rtn (cdr (assoc 1 enx))) ) (setq ent (entnext ent) enx (entget ent) ) ) ) rtn )
  38. 2 points
    If you supply a partial DXF list to the entmod function, only those groups included in the list will be modified (provided that there are sufficient groups present to identify the entity in the drawing database), as such, I believe you would need to delete & recreate the entity with the relevant groups removed, e.g.: (defun c:test ( / ent enx ) (if (and (setq ent (car (entsel))) (= "MTEXT" (cdr (assoc 0 (setq enx (entget ent))))) ) (if (entmake (vl-remove-if '(lambda ( x ) (= 3 (car x))) enx)) (entdel ent) (princ "\nUnable to create modified entity.") ) (princ "\nNothing selected or object wasn't MText.") ) (princ) )
  39. 2 points
    I didn't notice the flip action behaving that way, it could be a version issue. neat block, and really neat method, looks like I have to read up on this, and practice, I can see this in my future.
  40. 2 points
    You fed them after midnight, didn't you? Never feed them after midnight. And whatever you do, don't get them wet.
  41. 2 points
    You should have access to the AutoCAD Architectural Toolset, it does spiral stairs and rails. It took me only a few hours to figure out how to make a custom rail into a 4 board fence, so customization seems easy. I just did a few simple spiral stairs, seems simple enough. If needed in Autocad you'll need to Convert to 3D Solids.
  42. 2 points
    I know I have an elderly version of AutoCAD, but these instances are a challenge to me. After converting to my version, the speed improved immensely when I set SHADEMODE to 2D.
  43. 2 points
    If you want to be able to select which blocks you want to update things get a little bit more complex but you asked , so don't blame the dragon. ;;; https://www.cadtutor.net/forum/topic/71349-lisp-to-set-all-properties-inside-a-block-to-byblock/ ;;; Rlx 17 oct 2020 (defun c:t1 ( / max-num-of-rows start-column result-list blk AllBlockObjects AllNestedBlocks n i lst done) (cond ((not (setq blk (car (entsel "\nSelect block to process : ")))) (princ "\nDrink less or get glasses because you missed.")) ((not (vl-consp (setq AllBlockObjects (GetAllBlockObjects blk)))) (princ "\nHope you didn't pay for this block because its empty.")) ((not (vl-consp (setq AllNestedBlocks (GetAllNestedBlocks AllBlockObjects)))) (princ "\nNo nested blocks in this block")) (t (list->toggle:create_dialog (acad_strlsort (rdup (mapcar 'car AllNestedBlocks))) nil "Select nested blocks to pimp") (foreach x result-list (if (= (cdr x) "1")(setq lst (cons (car x) lst)))) (setq i 0)(pimp (vlax-ename->vla-object blk))(setq i (1+ i)) (vlax-for b (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-for o b (cond ((setq n (block-n o)) (if (and (member n lst) (not (member n done))) (progn (pimp o) (setq i (1+ i) done (cons n done))))) (t (pimp o))))) (vl-cmdf "_ATTSYNC" "N" "*") ) ) (princ (strcat "\nUpdated " (if i (itoa i) "nada") " blocks")) (princ) ) (defun pimp (o) (vla-put-color o 0)(vla-put-linetype o "ByBlock") (vla-put-Lineweight o -1)(vla-put-EntityTransparency o "ByBlock")) ; (setq lst (GetAllBlockObjects (car (entsel)))) (defun GetAllBlockObjects ( b / e l) (vlax-for o (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))(cdr (assoc 2 (entget b)))) (setq l (cons o l)))) (defun block-n (o) (if (and (= 'vla-object (type o))(eq (vla-get-objectname o) "AcDbBlockReference")) (if (vlax-property-available-p o 'EffectiveName) (vla-Get-EffectiveName o) (vla-Get-Name o)) nil)) ; (setq lst (GetAllNestedBlocks (GetAllBlockObjects (car (entsel))))) (defun GetAllNestedBlocks ( l / n r ) (foreach o l (if (setq n (block-n o)) (setq r (cons (cons n o) r)))) r) ;remove duplicates (defun rdup ( i / o ) (vl-remove-if '(lambda (x) (cond ((vl-position x o) t) ((setq o (cons x o)) nil))) i)) ;--- List->Toggle --------------------------------------- Begin of List->Toggle ------------------------------------------ List->Toggle --- ; max-num-of-rows / start-column / result-list -> global vars needed because dialog will be recreated if resized (defun list->toggle:create_dialog ( %lst %dflt $msg / max-dialog-width dialog-fn dialog-fp dialog-id action-list split_list-list l collie max-column-length max-str-len number-of-columns max-num-of-colums-per-dialog ) ; limit of the maximum size of dialog and maximum rows per column (setq max-dialog-width 120) (or max-num-of-rows (setq max-num-of-rows 10)) ; start column will be reset when number or rows is changed (or start-column (setq start-column 0)) (or result-list (setq result-list (mapcar '(lambda (x)(cons x "0")) %lst))) ; split_list up list in columns where each column has max-num-of-rows (setq split_list-list (split_list %lst max-num-of-rows) max-str-len (apply 'max (mapcar 'strlen %lst)) number-of-columns (length split_list-list) max-column-length (apply 'max (mapcar 'length split_list-list)) max-num-of-colums-per-dialog (fix (/ max-dialog-width (+ max-str-len 5)))) ; 5 = togglewidth (guess) ; open dialog for writing (setq dialog-fp (open (setq dialog-fn (vl-filename-mktemp ".dcl")) "w")) ; write header (write-line (strcat "split_list:dialog {label=\"" $msg "\";") dialog-fp) ; write body start (write-line ":boxed_row {" dialog-fp) (setq column-index start-column) (if (> (setq n (+ start-column number-of-columns)) max-num-of-colums-per-dialog) (setq n max-num-of-colums-per-dialog)) (repeat n (setq collie (nth column-index split_list-list) l (length collie) ) (write-line ":column {alignment=top;" dialog-fp) (foreach item collie (write-line (strcat ":toggle {label=\"" item "\";key=\"tg_" item "\";}") dialog-fp) (setq action-list (cons item action-list)); used later by action_tile's ) (repeat (- max-num-of-rows l)(write-line ":row {height=1.5;}" dialog-fp)) (write-line "}" dialog-fp) (setq column-index (1+ column-index)) ) ; write body end (write-line "}" dialog-fp) ; write footer (write-line (strcat "spacer;:concatenation {alignment=centered;children_fixed_width=true;" ":button{label=\"&Less Rows\";key=\"bt_less_rows\";mnemonic=\"L\";}" ":button{label=\"&More Rows\";key=\"bt_more_rows\";mnemonic=\"M\";}" ":button{label=\"&Prev.Page\";key=\"bt_prev_page\";mnemonic=\"P\";}" ":button{label=\"&Next Page\";key=\"bt_next_page\";mnemonic=\"N\";}}") dialog-fp) (write-line (strcat "spacer;:concatenation {alignment=centered;:button{label=\"Select All\";key=\"bt_select_all\";}" ":button{label=\"Clear All\";key=\"bt_clear_all\";}:button{label=\"Default\";key=\"bt_default\";}" "spacer;spacer;ok_cancel;}}") dialog-fp) (and (not (setq dialog-fp (close dialog-fp))) (< 0 (setq dialog-id (load_dialog dialog-fn))) (new_dialog "split_list" dialog-id) (progn (mapcar '(lambda (x)(set_tile (strcat "tg_" (car x)) (cdr x))) result-list) (mapcar '(lambda (x)(action_tile (strcat "tg_" (car x)) "(list->toggle:update_tile $key $value)")) result-list) (action_tile "accept" "(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)") (action_tile "bt_clear_all" "(list->toggle:set_all_toggles 0)") (action_tile "bt_select_all" "(list->toggle:set_all_toggles 1)") (action_tile "bt_less_rows" "(if (list->toggle:change_rows -1)(done_dialog 2))") (action_tile "bt_more_rows" "(if (list->toggle:change_rows +1)(done_dialog 2))") (action_tile "bt_prev_page" "(if (list->toggle:change_page -1)(done_dialog 3))") (action_tile "bt_next_page" "(if (list->toggle:change_page +1)(done_dialog 3))") (action_tile "bt_default" "(list->toggle:apply_defaults)") (setq drv (start_dialog))(unload_dialog dialog-id)(vl-file-delete dialog-fn) ) ) (cond ((or (= drv 2)(= drv 3))(list->toggle:create_dialog %lst %dflt $msg))) (princ) ) (defun list->toggle:set_all_toggles (i) (foreach tg action-list (set_tile (strcat "tg_" tg) (itoa i))) (setq result-list (mapcar '(lambda (x)(cons x (itoa i))) %lst))) (defun list->toggle:change_rows (i) (if (< 4 (+ max-num-of-rows i) 25) (progn (setq max-num-of-rows (+ max-num-of-rows i))(setq start-column 0)) nil)) (defun list->toggle:change_page (i) (if (and (<= 0 (+ start-column i))(<= (+ start-column i) (- number-of-columns max-num-of-colums-per-dialog ))) (setq start-column (+ start-column i)) nil)) (defun list->toggle:update_tile ($k $v) (setq result-list (subst (cons (substr $k 4) $v) (assoc (substr $k 4) result-list) result-list))) (defun list->toggle:apply_defaults () (if (and (vl-consp result-list) (vl-consp %dflt)) (foreach item %dflt (if (assoc item result-list) (progn (setq result-list (subst (cons item "1") (assoc item result-list) result-list)) (set_tile (strcat "tg_" item) "1"))))) ) ; (lst-strcat '("A" "B" "C") "+") -> "A+B+C" (defun lst-strcat (%l $s) (apply 'strcat (cdr (apply 'append (mapcar (function (lambda (x) (list $s x))) %l))))) ; (split_list '(1 2 3 4 5 6 7 8 9) 4) (split_list '(1 2 ) 4) (defun split_list (l n / _sub) (defun _sub (a b c / r) (if (not (<= 1 c (- (length a) b)))(setq c (- (length a) (1- b)))) (repeat c (setq r (cons (nth (1- b) a) r) b (1+ b)))(reverse r))(if l (cons (_sub l 1 n) (split_list (_sub l (1+ n) nil) n)))) (defun list->toggle:show_result (%l / tmp s) (cond ((or (not (vl-consp %l)) (vl-every ''((x)(= (cdr x) "0")) %l)) "None") ((vl-every ''((x)(= (cdr x) "1")) %l) "All") (t (foreach x %l (if (= (cdr x) "1")(setq tmp (cons (car x) tmp)))) (if (vl-consp tmp)(setq s (lst-strcat (reverse tmp) "+"))) (cond ((not (string-p s)) "Nothing selected") ((> (strlen s) 100) "List too long to show")(t s))) ) ) ; example for subfolder selection (defun getfolder ( msg / fl sh ) (if (and (setq sh (vlax-create-object "Shell.Application")) (setq fl (vlax-invoke sh 'browseforfolder 0 msg 0 ""))) (setq fl (vlax-get-property (vlax-get-property fl 'self) 'path))(setq fl nil))(release_me (list sh)) fl) (defun c:LT-test ( / fol lst dflt max-num-of-rows start-column result-list) (setq dflt '("E" "FGA" "G" "GE" "GX" "HV" "S" "TC" "U")) (if (and (setq fol (getfolder "Targetfolder")) (vl-consp (setq lst (vl-remove-if '(lambda (x)(member x '("." ".."))) (vl-directory-files fol nil -1))))) (progn (list->toggle:create_dialog lst dflt "Select subfolders") (alert (list->toggle:show_result result-list)))) (princ) ) ;--- List->Toggle ---------------------------------------- End of List->Toggle ------------------------------------------- List->Toggle --- Kurpulio2.lsp
  44. 2 points
    Quite a few answers on the web already:
  45. 2 points
    ;;;https://www.theswamp.org/index.php?topic=56258.0 ;; @Tharwat (defun c:Test (/ int sel ent) (and (or (/= 4 (logand 4 (cdr (assoc 70 (entget (tblobjname "LAYER" "wall")))) ) ) (alert "Layer name <wall> is locked ! unlock then try again" ) ) (setq int -1 sel (ssget "_X" (list '(0 . "LWPOLYLINE") '(8 . "wall") (cons 410 (getvar 'CTAB)) ) ) ) (setvar 'FILLETRAD 0.25) (while (setq int (1+ int) ent (ssname sel int) ) (command "_.FILLET" "_Polyline" ent) ) ) (princ) )
  46. 2 points
    I can imagine that solution has some real potential in the Revit world, too. I'm hoping that it is not brand specific but rather something in the application that helps.
  47. 2 points
    The reason my favorite math class was Geometry is that it is somewhat intuitive, and visual, whence my love of drafting. This is totally antithetical to how I feel about Trigonometry, man was I glad when that class ended. Respect for those (wannabe accountants? )who have the patience to look up all those decimal heavy sines and cosines. I'd greatly prefer the hour or two spent learning some parametric essentials!
  48. 2 points
    Frequently, after a topographic survey, I have to prove the obtained area of a Lot of Land. This lisp creates a table with the analytical method of the Gauss's area formula. I do not need absolute precision, but logically (owing to rounding) by increasing decimal units you can get a result as close to the real one. It is still to be completed, but I never have time to finish it. You can change the nonsense I wrote in English AreaG.LSP
  49. 2 points
    The other dimension is 8000.00000029. In fact when the precision is set to 8 places of decimals, some of the dimensions do not seem to be exact. The overall length is 63999.99999925. Probably near enough not to matter, but when exactness is available, why not use it?
  50. 2 points
    I thought that the shape could lend itself to a hatch pattern, so I started writing one. But priorities changed and I have only managed to write half. But changing the hatch angle to 90 enabled the whole pattern to be drawn. So I claim two clicks
  • Newsletter

    Want to keep up to date with all our latest news and information?
    Sign Up
×
×
  • Create New...