Recent Posts

Pages: [1] 2 3 ... 10
1
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

2
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.



3
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)))
4
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.
5
.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.
6
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.
7
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)
8
AutoLISP (Vanilla / Visual) / Re: most common value in a list (mode)
« Last post by kdub_nz on May 31, 2024, 11:33:53 PM »
Quote
The mode is the most common number that appears in your set of data. To find the mode count how often each number appears and the number that appears the most times is the mode.
https://www.ncl.ac.uk/webtemplate/ask-assets/external/maths-resources/statistics/descriptive-statistics/mean-median-and-mode.html#:~:text=Mode-,Definition,most%20times%20is%20the%20mode.

Quote
Mode: The most frequent number—that is, the number that occurs the highest number of times.
https://www.khanacademy.org/math/statistics-probability/summarizing-quantitative-data/mean-median-basics/a/mean-median-and-mode-review

Seems 'mode' is not an Cardinal value, just the number that appears most . . nor an analysis of the other numbers.

. . . so my expectation would be to return a single number, or a list if there are multiple modes

Having two modes is called "bimodal".

Having more than two modes is called "multimodal".

I s'pose the handling of a list with an equal amount of each number would depend on the use case.


//--
edge cases can be a killer.

9
AutoLISP (Vanilla / Visual) / Re: most common value in a list (mode)
« Last post by ymg on May 31, 2024, 10:56:54 PM »
As far as I know you can have more than one mode.  Also if every item as the same count mode should be undefined.

Simply doing a vl-sort on the countitems routine of Lee give you the modes at a glance as wwell as the frequency of each item.

Code: [Select]
;; Count Items  -  Lee Mac                                    ;
;; Returns a list of dotted pairs detailing the number of     ;
;; occurrences of each item in a supplied list.               ;

(defun CountItems ( l / x c )
   
    (if (setq x (car l))
        (progn
            (setq c (length l)
                  l (vl-remove x (cdr l))  
            )
            (cons (cons x (- c (length l))) (CountItems l))
        )
       
    )
   
)

(defun mode (l)
   (setq l (vl-sort (countitems l) '(lambda (a b) (> (cdr a) (cdr b))))) 
)



Sample call:
Code: [Select]
_$ (mode '(1 2 3 3 3 3 4 5 6 6 7 8 8 8 8))
((3 . 4) (8 . 4) (6 . 2) (1 . 1) (2 . 1) (4 . 1) (5 . 1) (7 . 1))

10
.NET / Re: Previews or Thumbnails
« Last post by retsameht on May 31, 2024, 07:53:32 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.
Pages: [1] 2 3 ... 10