Recent Posts

Pages: 1 ... 8 9 [10]
91
AutoLISP (Vanilla / Visual) / Help : filter dimension layer
« Last post by mhy3sx on June 30, 2024, 01:32:13 PM »
Hi I want to to search the drawin and if any dimensions in the drawing to move them to layer DIM, but if not any dimensions to
Code: [Select]
    (princ "No dimensions found.") 

and aboard the code.

The code bellow works perfect if dimension exist in drawing , but if there is no dimension gives me this error

Code: [Select]
Current layer: DIM
Enter an option [?/New/Make/Set/Color/Ltype/LWeight/Plot/ON/OFF/Freeze/Thaw/LOck/Unlock/Rename/Description/DELete/stAte/TRansparency]: DIM
Invalid keyword.


Code - Auto/Visual Lisp: [Select]
  1. (defun c:DLDL (/ sel1 CLAYER )
  2.    (command "_.Tilemode" 1) ; ;Switch from Layout Tab To Model Tab before stating LISP
  3.  
  4.   (if (setq sel1 (ssget "X" '((0 . "DIMENSION") (-4 . "<NOT") (8 . "ARROWLINE") (-4 . "NOT>")))) ; SELECT ALL DIMENSION
  5.      (progn
  6.       (setq OLDLAYER (getvar "CLAYER")) ;GET CURRENT LAYER
  7.       (setvar "CLAYER" OLDLAYER) ; SET ACTIVE LAYER TO PREVIOUS
  8.          
  9.          (if (=(tblsearch "layer" "DIM") nil)
  10.       (command "_layer" "_m" "DIM" "_c" "7" "" "_lw" "0.30" "" "")
  11.      );end if
  12.          
  13.       (command "CHPROP" sel1 "" "LAYER" "DIM" "")  ; CHANGE DIMENSION LAYER TO NEW LAYER
  14.       (command "._draworder" sel1 "" "_f")
  15.           (command "-DIMSTYLE" "R" "STANDARD")
  16.      );end progn
  17.     (princ "No dimensions found.") ; Handle case when no dimensions are selected
  18.   );end if
  19. ;Layer 0
  20. (mapcar 'setvar '(clayer cecolor celtype celweight) (list "0" "BYLAYER" "BYLAYER" -1))
  21.     (princ)
  22. )
  23. );end def
  24.  

Thanks
92
First of all, with linear hatchings like you showed in picture, HATCHGENERATEBOUNDARY command won't work well like if there was SOLID hatchings. But it's on you to try to recreate boundary, you can also try it throungh HATCHEDIT command... When you get boundary, or if you already had them stored in some layer, good for you, but if you don't have them, consider overdrawing boundaries - perhaps with removing (erasing) old and using BPOLY with picking point - this is fastest method... Then go to BHATCH command, select boundary and use inherit properties from old perforated hatchings... When hatching created new hatch, select both back and top hatchings, use ERASE command and use "r" remove "l" last entity (hatch)... I doubt there is faster way to remedy openings from old texts...
93
AutoLISP (Vanilla / Visual) / Re: Help: Insert Hatch with transparency
« Last post by mhy3sx on June 30, 2024, 10:05:31 AM »
Thanks ribarm   :smitten:
94
AutoLISP (Vanilla / Visual) / Re: Help: Insert Hatch with transparency
« Last post by ribarm on June 30, 2024, 09:56:09 AM »
Have you tried to switch this two lines :

Code - Auto/Visual Lisp: [Select]
  1.               (command "_.-hatch" "_s" sset "" "_P" "solid" "")
  2.               (setvar 'CETRANSPARENCY 80)  ; Set hatch transparency to 80% ,BUT IS NOT WORKING !!!!
  3.  

Try with :

Code - Auto/Visual Lisp: [Select]
  1.               (setvar 'CETRANSPARENCY 80)
  2.               (command "_.-hatch" "_s" sset "" "_P" "solid" "")
  3.  
95
AutoLISP (Vanilla / Visual) / Help: Insert Hatch with transparency
« Last post by mhy3sx on June 30, 2024, 09:44:31 AM »
Hi I am trying to  hach a close polyline with transparency, but I can not set transparency !!

The code is

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ la ss i sset p1 p2)
  2.   (if (not (tblsearch "LAYER" "HATCH"))
  3.     (vl-cmdf "_.layer" "_m" "HATCH" "_c" "40" "" "")
  4.   )
  5.  
  6.   (setq la (getvar "clayer"))
  7.   (command "-layer" "S" "HATCH" "")
  8.  
  9.   (if (setq ss (ssget "_:L" '((0 . "LWPOLYLINE"))))
  10.     (progn
  11.       (repeat
  12.         (setq i (sslength ss))
  13.         (setq sset (ssname ss (setq i (1- i))))
  14.         (if (and
  15.               (eq (car (setq p1 (cdr (vlax-curve-getStartPoint sset))))
  16.                    (car (setq p2 (cdr (vlax-curve-getEndPoint sset))))
  17.               )
  18.               (eq (cadr p1)
  19.                   (cadr p2)
  20.               )
  21.             )
  22.             (progn
  23.               (command "_.-hatch" "_s" sset "" "_P" "solid" "")
  24.               (setvar 'CETRANSPARENCY 80)  ; Set hatch transparency to 80% ,BUT IS NOT WORKING !!!!
  25.             )
  26.           )
  27.         )
  28.       )
  29.     )
  30.     (princ "\n No closed Polylines found !! ")
  31.  
  32.  
  33.   ; Hatch back
  34.   (setq hss (ssget "x" '((0 . "HATCH"))))
  35.   (command "draworder" hss "" "b")
  36.   (setvar "clayer" la)
  37.   (princ)
  38. )
  39.  

Thanks
96
Instead of dragging each vertex and closing each open area in the hatch, does anyone know of a faster way?  I will have hundreds of drawings with open areas where there was once text. Any help would be very much appreciated!
97
AutoLISP (Vanilla / Visual) / Re: Block Manager [Option 2]
« Last post by 3dwannab on June 29, 2024, 07:38:54 AM »
I take it this is no longer been developed? I tried this in 2025 and it's giving lots of errors.
98
Reading about Apache Parquet and Arrow. Itís very interesting, and apparently extremely fast.
Memory layout is by column instead of by row, is enforced 64 byte aligned for AVX-512.
https://arrow.apache.org/docs/format/Columnar.html  :mrgreen:

Iím wondering what youíre doing with this with regards to CAD?
IMHO, this is something that is best read into a compute engine, I.e. Pandas, then maybe returning the results of your analysis to lisp.
99
AutoLISP (Vanilla / Visual) / Re: Group list of numbers by fuzz value
« Last post by ribarm on June 27, 2024, 06:51:27 PM »
Here is my version... It should cover all attempts that depended on unsorted numbers... That's why pre sorting... Here is the result that is correct and I think that it's fastest one, if you don't include presorting which is neccessity...

Code - Auto/Visual Lisp: [Select]
  1. (defun groupnumsbyfuzz ( lst fuzz / _vl-sort-i x y r )
  2.  
  3.   (defun _vl-sort-i ( lst fun )
  4.     (mapcar (function (lambda ( x ) (nth x lst))) (vl-sort-i lst fun))
  5.   )
  6.  
  7.   (setq lst (_vl-sort-i lst (function <)))
  8.   (while (setq x (car lst))
  9.     (if (and (cadr lst) (<= (abs (- x (cadr lst))) fuzz))
  10.       (setq y (cons x y))
  11.       (if y
  12.         (setq r (cons (reverse (cons x y)) r) y nil)
  13.         (setq r (cons (list x) r))
  14.       )
  15.     )
  16.     (setq lst (cdr lst))
  17.   )
  18.   (reverse r)
  19. )
  20.  
  21. (setq *lst* (list 360.243 378.578 388.578 479.098 488.516 489.098 500 506.926 507 511.829 519.16 520.502 520.917 521.829 522.216 616.657 620.048 624.996 626.657 629.326 720.487 899.991 899.994 899.996 900.002 900.005 900.005 900.005 999.999 1000.0 1000.0 1000.0 1000.01 1000.01 1000.01 2922.88 3109.41 3379.1 3400 3517.33 3521.58 3900 4000.0 4000 4000.0 4000.0 4000.0 5108.05 5183.91 5252.41 5258.41 5273.26 5273.32 5273.72 5294.62 5434.47 5438.9 5438.94 5444.94 5459.34 5459.84 5477.59 5609.36 5609.42 5630.26 5755.84 5811.98 5900.78 5919.05 5998.51 6157.25))
  22.  
  23. (groupnumsbyfuzz *lst* 1.5)
  24. ((360.243) (378.578) (388.578) (479.098) (488.516 489.098) (500) (506.926 507) (511.829) (519.16 520.502 520.917 521.829 522.216) (616.657) (620.048) (624.996) (626.657) (629.326) (720.487) (899.991 899.994 899.996 900.002 900.005 900.005 900.005) (999.999 1000.0 1000.0 1000.0 1000.01 1000.01 1000.01) (2922.88) (3109.41) (3379.1) (3400) (3517.33) (3521.58) (3900) (4000.0 4000.0 4000.0 4000 4000.0) (5108.05) (5183.91) (5252.41) (5258.41) (5273.26 5273.32 5273.72) (5294.62) (5434.47) (5438.9 5438.94) (5444.94) (5459.34 5459.84) (5477.59) (5609.36 5609.42) (5630.26) (5755.84) (5811.98) (5900.78) (5919.05) (5998.51) (6157.25))
  25.  

M.R.
100
see if this helps

Code - Auto/Visual Lisp: [Select]
  1. (DEFUN c:changeInsidePolys (/ EDATA LSTPOLSINSIDE POLSS SSPOLSINSIDE VPOL VTX)
  2.   (IF (= (TBLSEARCH "layer" "BLD") nil)
  3.     (COMMAND "_layer" "_m" "BLD" "_c" "10" "" "")
  4.   )
  5.   (COND
  6.     ((NOT
  7.        (SETQ
  8.          Polss (SSGET "_X" '((0 . "LWPOLYLINE") (8 . "layer1") (70 . 1)))
  9.        )
  10.      )
  11.      (alert "\nNothing selected...")
  12.     )
  13.     (T
  14.      (FOREACH pl (VL-REMOVE-IF 'LISTP (MAPCAR 'CADR (SSNAMEX Polss)))
  15.        (SETQ edata (ENTGET pl))
  16.        (SETQ vtx (massoc 10 edata))
  17.        (COND
  18.          ((NOT
  19.             (AND (SETQ ssPolsInside
  20.                         (SSGET "CP"
  21.                                vtx
  22.                                '((0 . "LWPOLYLINE") (8 . "layer2") (70 . 1))
  23.                         )
  24.                  )
  25.                  (SETQ LstPolsInside
  26.                         (VL-REMOVE-IF 'LISTP (MAPCAR 'CADR (SSNAMEX ssPolsInside)))
  27.                  )
  28.             )
  29.           )
  30.           (princ "\n There's not polyline inside")
  31.          )
  32.          (T
  33.           (FOREACH pol LstPolsInside
  34.             (IF
  35.               (AND (inside_p (mu:centroide (SETQ vpol (massoc 10 (ENTGET pol))))
  36.                              vtx
  37.                    )
  38.                    (SETQ ssPolsInside
  39.                           (SSGET "WP"
  40.                                  vpol
  41.                                  '((0 . "*TEXT") (8 . "layer3"))
  42.                           )
  43.                    )
  44.               )
  45.                (PROGN
  46.                  (VLA-PUT-LAYER (VLAX-ENAME->VLA-OBJECT pol) "BLD")
  47.                  (VLA-PUT-LAYER
  48.                    (VLAX-ENAME->VLA-OBJECT (SSNAME ssPolsInside 0))
  49.                    "BLD"
  50.                  )
  51.                )
  52.             )
  53.           )
  54.          )
  55.        )
  56.      )
  57.     )
  58.   )
  59.   (PRINC)
  60. )

edit @kerry : add AutoLisp code formatting tag
Code - Auto/Visual Lisp: [Select]
  1.  
Pages: 1 ... 8 9 [10]