dilluns, 8 de setembre del 2025

VLISP - from wired box to cylindric beams (by Gemini 2.5 Pro)

 ;; -----------------------------------------------------------------------------
;; Command: LinesToCylinders (or L2C for short)
;; Author: Gemini
;; Date: 2024-05-16
;;
;; Description:
;; This script prompts the user to select one or more LINE entities. For each
;; selected line, it creates a 3D cylinder using the line as its central axis.
;; The radius of the created cylinders is fixed at 5 units.
;;
;; How to Use:
;; 1. Load this file into AutoCAD using the APPLOAD command.
;; 2. Type "LINES2CYL" or "L2C" in the command line and press Enter.
;; 3. Select the lines you want to convert into cylinders.
;; 4. Press Enter to confirm your selection. The cylinders will be created.
;; -----------------------------------------------------------------------------

(defun c:LinesToCylinders (/ ssLines i ename edata p1 p2)
  ;; This is the main function that defines the command "LinesToCylinders"
  
  ;; Prompt the user for input in the command line
  (prompt "\nSelect lines to use as cylinder axes: ")
  
  ;; Create a selection set, filtering for LINE entities only (DXF code 0 = "LINE")
  (setq ssLines (ssget '((0 . "LINE"))))
  
  ;; Check if the selection set is not nil (i.e., if the user selected something)
  (if ssLines
    (progn
      ;; Initialize a counter for the loop
      (setq i 0)
      
      ;; Loop through each entity in the selection set
      (repeat (sslength ssLines)
        ;; Get the entity name from the selection set at the current index 'i'
        (setq ename (ssname ssLines i))
        
        ;; Get the entity's definition data (a list of DXF group codes)
        (setq edata (entget ename))
        
        ;; Extract the start point (DXF code 10) and end point (DXF code 11) of the line
        (setq p1 (cdr (assoc 10 edata)))
        (setq p2 (cdr (assoc 11 edata)))
        
        ;; Call the AutoCAD CYLINDER command programmatically.
        ;; The dot "." ensures the standard command is used.
        ;; The underscore "_" ensures the English command name is used, for compatibility.
        ;;
        ;; Command sequence breakdown:
        ;; "._CYLINDER" : Starts the command.
        ;; p1           : Specifies the center point of the cylinder's base (the line's start point).
        ;; 5            : Sets the radius to 5.
        ;; "_A"         : Chooses the "Axis Endpoint" option.
        ;; p2           : Specifies the other end of the axis (the line's end point).
        (command "._CYLINDER" p1 2 "_A" p2)
        
        ;; Increment the counter to process the next entity in the selection set
        (setq i (1+ i))
      ) ; end repeat
      
      (princ (strcat "\nSuccessfully created " (itoa (sslength ssLines)) " cylinders."))
    ) ; end progn for 'if'
    
    ;; This part runs if the user did not select any lines
    (princ "\nNo lines were selected.")
    
  ) ; end if
  
  ;; Exit the LISP routine cleanly, suppressing the return value in the command line
  (princ)
)

;; Define a shorter alias for the command for easier access.
;; Now you can type either "LinesToCylinders" or "L2C".
(defun c:L2C () (c:LinesToCylinders))

(princ "\nLISP file loaded. Type LINES2CYL or L2C to run.")
(princ)

the code has been prompt in Gemini


Conversation with Gemini

in autocad vlisp code. user select a bunch of lines. the code uses the lines as axle to create cylinders radius 5

Show thinking

Of course. I'll create a VLISP file that you can load into AutoCAD. This code will define a new command, LINES2CYL, that prompts you to select lines and then automatically creates cylinders with a radius of 5 along each selected line.

Here is the VLISP code file.

Lines to Cylinders

8 Sept, 17:36

Try again without Canvas

I've created the LISP file for you. To use it, simply load lines_to_cylinders.lsp into your AutoCAD session using the APPLOAD command. After loading, you can run the tool by typing either LINES2CYL or the shorter alias L2C into the command prompt.

 



dijous, 27 de març del 2025

Ollama on windows - LLM on local machine

 https://youtu.be/C7rFk-GbdCg?si=_U1Q1FhrgDkSIYHF

https://medium.com/@Tanzim/how-to-run-ollama-in-windows-via-wsl-8ace765cee12


and saving models to another location

https://youtu.be/uj1VnDPR9xo?si=YP0PokJwynLyYFmY

the path in wsl must be like this (... must be replaced by the user name)

/mnt/c/Users/.../AppData/Local/Programs/Ollama/ollama.exe run gemma3:latest

when in windows is 

C:\Users\...\AppData\Local\Programs\Ollama

dissabte, 15 de març del 2025

EXCEL - Scatter Plot - how to label points as data from col A:A (Alt+F11) - Insert Module

 Sub LabelScatterPlot()
    Dim chartObj As ChartObject
    Dim srs As Series
    Dim i As Integer
    
    ' Change "Sheet1" to your sheet name
    Set chartObj = Sheets("Sheet4").ChartObjects(1) ' First chart on the sheet
    Set srs = chartObj.Chart.SeriesCollection(1) ' First data series

    For i = 1 To srs.Points.Count
        srs.Points(i).ApplyDataLabels
        srs.Points(i).DataLabel.Text = Sheets("Sheet4").Range("A" & (i + 1)).Value
    Next i
End Sub


dimecres, 12 de març del 2025

Dave Thomas al Happy Path Programming (LM Notebook digest)

 El document de "La Joia de Programar amb Dave Thomas" resumeix la conversa amb Dave Thomas al podcast "Happy Path Programming" sobre diversos aspectes de la programació.

La joia de la programació per a Dave Thomas rau en la realització d'una idea o en lliurar alguna cosa, idealment amb un toc distintiu. La necessitat és el motor principal de la seva exploració en la programació, gaudint de buscar múltiples solucions i trobar la "correcta". Compara la programació amb la feina d'un poeta construint "castells al cel", destacant la capacitat única de la indústria per crear des de zero. També ressalta la resiliència davant la fallada com a característica dels bons programadors, veient-la com una oportunitat d'aprenentatge.

Pel que fa a l'impacte de la Intel·ligència Artificial (IA), es mostra escèptic sobre la idea que reemplaçarà completament els programadors, assenyalant les possibles limitacions actuals en la generació i prova de codi. Subratlla la importància de la flexibilitat i l'exploració contínua per part dels programadors.

Dave Thomas expressa una crítica a la programació orientada a classes i defensa els paradigmes funcionals. Argumenta que la gent practica "programació orientada a classes" en lloc de la veritable programació orientada a objectes. Critica l'ús excessiu de la herència.

Feature Using Inheritance (extends Vehicle) Using Composition (implements Movable)
Code Structure Forces everything into a single hierarchy Each class is independent
Flexibility Hard to add new types Easy to add new vehicles
Inheritance Problems Multiple inheritance issues No inheritance problems
Readability Unnecessary properties (e.g., speed for a boat) Each class defines only what it needs

Contrasta la programació OO amb la funcional, argumentant que la funcional aconsegueix més resultats. La seva programació actual tendeix a utilitzar classes només per a l'encapsulació bàsica, amb la major part del codi sent funcions externes. Presenta la idea d'un "super reductor" com l'operació fonamental de la computació. També discuteix el principi de substitució de Liskov (LSP) i la seva rellevància en contextos de "pipelines".

Sobre el Manifest Agile, Dave Thomas considera que la part més valuosa són els quatre valors inicials, que són oberts a la interpretació i representen preferències, no regles. Lamenta com Agile va ser convertit en processos comercials rígids, perdent l'esperit original d'adaptabilitat. Creu que s'hauria de donar als desenvolupadors autonomia i temps per pensar en el seu treball. Critica la tendència a buscar la novetat en tecnologies en lloc de la resolució de problemes reals.

Pel que fa a l'arquitectura de software, proposa un enfocament "agile": començar amb la solució més senzilla possible per obtenir retroalimentació primerenca. Emfatitza la importància de desenvolupar codi aïllat. Sugereix acceptar les decisions dels altres sobre "qüestions religioses".

Finalment, destaca la importància d'entendre les necessitats reals dels clients, distingint entre "vull" i "necessito". Valora un enfocament iteratiu amb entregues primerenques. Qüestiona si la solució sempre és crear software personalitzat. Reflexiona sobre el valor de les interaccions humanes. Menciona l'ús de la IA per refinar preguntes.

En resum, la conversa amb Dave Thomas ofereix una perspectiva reflexiva sobre la programació, emfatitzant la joia, l'exploració, la flexibilitat i la comprensió de les necessitats reals. La seva defensa de la programació funcional i la seva crítica a la programació orientada a classes conviden a la reflexió. La seva perspectiva sobre el Manifest Agile recorda els valors fonamentals d'adaptabilitat.


dissabte, 18 de gener del 2025

Autocad - Script doesn't draw properly

 https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-94994960-5E62-4044-BEF7-9CF91667F641

Solved



Then lines on notes are drawn properly