Recent Posts

Pages: [1] 2 3 ... 10
1
AutoLISP (Vanilla / Visual) / Re: Lisp to count text in drawing
« Last post by Tharwat on Today at 12:14:24 PM »
You can enter a search pattern.

Code: [Select]
(setq str (strcat "*" (getstring "\nEnter search string ") "*"))
(setq s (ssget "_X" '((0 . "TEXT,MTEXT")(cons 1 str)))
- What if a user pressed enter ?
- You need to read about quote function and list to be able to give accurate solution than running to threads just to post.
2
.NET / Re: Previews or Thumbnails
« Last post by cmwade77 on Today at 12:10:10 PM »
I think I must be missing something here, here is the code I have:

Code - C#: [Select]
  1.      activeDoc.SendStringToExecute("_.qsave\n", false, false, false);
  2.  

The above line doesn't execute until after your code returns control to AutoCAD. Unless it's being called from the application context, I would use the Editor's Command() method.
Except the drawing isn't open in the editor.
3
AutoLISP (Vanilla / Visual) / Re: overlap layers
« Last post by mhy3sx on Today at 11:33:54 AM »
I try but select lines inside layer and not only overlap with layer1

Code - Auto/Visual Lisp: [Select]
  1. (defun c:overlaplayers ( / ss s1 s2 s3 i e x e1 e2 e3 e4 ii p1 p2 lst inside? get-polyline-vertices)
  2.  
  3.  
  4.   ;; Select all entities on the specified layers
  5.    (setq ss (ssget "_A" (list (cons 8 "layer1,layer2,layer3,layer4"))))
  6.  
  7.   ;; Initialize selection sets for each layer
  8.   (progn
  9.     (setq s1 (ssadd))
  10.     (setq s2 (ssadd))
  11.     (setq s3 (ssadd))
  12.     (setq s4 (ssadd))
  13.  
  14.     ;; Iterate through the selection set and add entities to their respective layer selection set
  15.     (repeat (setq i (sslength ss))
  16.       (setq e (ssname ss (setq i (1- i))))
  17.       (setq x (entget e))
  18.       (cond
  19.         ((= (strcase (cdr (assoc 8 x))) "layer1")
  20.           (ssadd e s1))
  21.         ((= (strcase (cdr (assoc 8 x))) "layer2")
  22.           (ssadd e s2))
  23.         ((= (strcase (cdr (assoc 8 x))) "layer3")
  24.           (ssadd e s3))
  25.                       ((= (strcase (cdr (assoc 8 x))) "layer4")
  26.           (ssadd e s4))
  27.       )
  28.     )
  29.  
  30.     (defun inside? (pt pl / minx maxx miny maxy)
  31.       (setq minx (apply 'min (mapcar 'car pl)))
  32.       (setq maxx (apply 'max (mapcar 'car pl)))
  33.       (setq miny (apply 'min (mapcar 'cadr pl)))
  34.       (setq maxy (apply 'max (mapcar 'cadr pl)))
  35.       (and (>= (car pt) minx) (<= (car pt) maxx)
  36.            (>= (cadr pt) miny) (<= (cadr pt) maxy))
  37.     )
  38.  
  39.  
  40.     (defun get-polyline-vertices (e / obj len inc pt pts)
  41.       (setq obj (vlax-ename->vla-object e))
  42.       (setq inc 0.0)
  43.       (setq pts '())
  44.       (while (<= inc len)
  45.         (setq pt (vlax-curve-getPointAtDist obj inc))
  46.         (setq pts (cons pt pts))
  47.         (setq inc (+ inc (vlax-curve-getDistAtParam obj 1.0)))
  48.       )
  49.       (reverse pts)
  50.     )
  51.  
  52.     (foreach e1 (vl-remove-if 'listp (mapcar 'cadr (ssnamex s1)))
  53.       (setq pl (get-polyline-vertices e1))
  54.       (foreach e2 (vl-remove-if 'listp (mapcar 'cadr (ssnamex s2)))
  55.         (if (inside? (vlax-curve-getStartPoint (vlax-ename->vla-object e2)) pl)
  56.           (entmod (subst (cons 8 "layer5") (assoc 8 (entget e2)) (entget e2)))
  57.         )
  58.       )
  59.       (foreach e3 (vl-remove-if 'listp (mapcar 'cadr (ssnamex s3)))
  60.         (if (inside? (cdr (assoc 10 (entget e3))) pl)
  61.           (entmod (subst (cons 8 "layer5") (assoc 8 (entget e3)) (entget e3)))
  62.                        
  63.         )
  64.       )
  65.                 (foreach e4 (vl-remove-if 'listp (mapcar 'cadr (ssnamex s4)))
  66.         (if (inside? (cdr (assoc 10 (entget e4))) pl)
  67.           (entmod (subst (cons 8 "layer6") (assoc 8 (entget e4)) (entget e4)))
  68.                        
  69.         )
  70.       )
  71.     )
  72.   )
  73.   (princ)
  74. )
  75.  


Thanks
4
AutoLISP (Vanilla / Visual) / overlap layers
« Last post by mhy3sx on Today at 09:41:45 AM »
Hi, I have a drawing with a close polyline in Layer1  and overlap layer2 , layer3, and layer 4 . I want to move to Layer 2 and 3 to layer 5 and layer 4 to layer 6 (only the overlap parts)

Look the drawing dwg

I want this lisp because I have to convert a lot of drawings

Thanks

5
BricsCAD is a almost perfect clone for AutoCAD, but many users are missing the GeomCal functionality. This problem is solved with the Lisp-application CADCAL, which can be downloaded for free from www.archtools.de/cadcal.zip. CADCAL brings the same functionality as GeomCal, including the possibility to use GeomCal calculations in Lisp like in (cal "PLT(end,end,/3)"). You can get an overview of CADCAL at www.archtools.de/cadcal.html.

CADCAL has some more functions than GeomCAL, i.e. PGR(<p1>,<p2>) which divides the distance between P1 and P2 in the Golden Ratio, oder PCG(<p1>,<p2> ... <pn>) which returns the center of gravity of a polygon over all points in the function's argument.

And now CADCAL also can be used with a dialog and a history od previously calles math expressions. The dialog is called with the command DDCAL and should be self explaining. The history is stored inside the dwg and will be restored when you reopen the dwg. All results of all math expressions in the history are stored too and can be recalled. DDCAL can be called transparently from any running CAD command, and the results of the calculations as well as the recalled results of previous results from the history list can be used directly as input to the running command. The ZIP also contains a demo DWG file with a history of CADCAL expressions for a first view at this functionality.

CADCAL is programmed in Lisp only, and therefore should work in AutoCAD, BricsCAD and all similar CAD applications as well. CADCALs parser first translates the string containing the math expression into an evaluable Lisp expression. The user can do this too using the CC-STR->LISP function, i.e. using (CC-STR->LISP "PLD(end,end,100)"). Because any math expression needs only one single translation within the same DWG-Session, CADCAL is rather fast. In AutoCAD overall CADCAL is about 5 to 10% slower than GeomCal, and in BricsCAD because the very fast Lisp interpreter CADCAL is about 10 times faster than GeomCal.

The DDCAL functionality is new and therefore CADCAL is still in beta stadium. Please let me know what you think of CADCAL. If you have any ideas for additional functionality, then please let me know.



6
AutoLISP (Vanilla / Visual) / Re: Lisp to count text in drawing
« Last post by BIGAL on June 02, 2024, 09:05:29 PM »
You can enter a search pattern.

Code: [Select]
(setq str (strcat "*" (getstring "\nEnter search string ") "*"))
(setq s (ssget "_X" '((0 . "TEXT,MTEXT")(cons 1 str)))
7
You need your alignment to have a common point on both alignments then it should work automatically. I would then remove the labelling of the alignment at fixed chainage near the intersection point if necessary.
eg 20.85 remove 20.00.

PS CIV3D etc.
8
.NET / Re: PropertySetDefinition with a List data type
« Last post by Jeff_M on June 02, 2024, 03:10:11 PM »
I have tried a lot of the various solutions to this issue, none of which have worked. This one seemed to be the most promising. However I still cannot get the ComboBox populated with the list. Attached is a fully working test project which exhibits this. Any help getting this working will be much appreciated.
9
AutoLISP (Vanilla / Visual) / Re: Lisp to count text in drawing
« Last post by Mjf1999 on June 02, 2024, 10:20:09 AM »
@HOSNEYALAA, thank you for your reply.

No need for example drawings, you may have the following texts in the drawings (i.e. glass1, glass2, brick1, brick2, steel1, steel2, wood), the mentioned lisp will list and table all the above texts, but if I want to list and table only glass than the lisp need to give a search/find option.

For now my only option is to have the listed table and to delete all other unwanted text manually.
10
AutoLISP (Vanilla / Visual) / Re: most common value in a list (mode)
« Last post by Lee Mac on June 01, 2024, 08:47:45 AM »
Adapting the code to yield multiple values representing the mode is relatively straightforward -
Code - Auto/Visual Lisp: [Select]
  1. (defun multimode ( lst fuz / cnt dif itm len rtn )
  2.     (while lst
  3.         (setq len (length lst)
  4.               itm (car lst)
  5.               lst (vl-remove-if '(lambda ( x ) (equal itm x fuz)) (cdr lst))
  6.               dif (- len (length lst))
  7.         )
  8.         (cond
  9.             (   (= cnt dif)
  10.                 (setq rtn (cons itm rtn))
  11.             )
  12.             (   (< cnt dif)
  13.                 (setq cnt dif rtn (list itm))
  14.             )
  15.         )
  16.     )
  17.     (reverse rtn)
  18. )
Code - Auto/Visual Lisp: [Select]
  1. _$ (multimode '(1 2 3 3 4 5) 0.1)
  2. (3)
  3. _$ (multimode '(1 2 3 3 5 4 5) 0.1)
  4. (3 5)
Pages: [1] 2 3 ... 10