Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/04/2025 in all areas

  1. You can use this to write to Excel Note not supported in LT24+. Dont have Excel open, just write to the cell using row and column rather than write to a csv. ;; Thanks to fixo ;; ;; = Set Excel cell text = ;; ;; ;; (defun xlsetcelltext ( row column text) (setq cells (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Cells")) (vl-catch-all-apply 'vlax-put-property (list cells 'Item row column (vlax-make-variant (vl-princ-to-string text) vlax-vbstring))) ) ;; Try to get or create Excel instance (setq myxl (vl-catch-all-apply 'vlax-get-or-create-object '("Excel.Application"))) (if (vl-catch-all-error-p myxl) (progn (prompt "\nError: Could not start Excel.") (exit) ) ) (if (= (vlax-get-property (vlax-get-property myXL 'WorkBooks) 'count) 0) (vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add) ) (vla-put-visible myXL :vlax-true) (vlax-put-property myxl 'ScreenUpdating :vlax-true) (vlax-put-property myXL 'DisplayAlerts :vlax-true)
    2 points
  2. @BIGAL Has a really nice multi-radio button routine that looks like it would work.
    1 point
  3. @Steven P That is a good academic exercise to learn from, but the OP did not want to scale all the location coordinates of the text. He wanted the X and Y straight from the text location without scaling, then using the VALUE in the text to get the Z coordinate multiplied by 1000 (Meters to Millimeters). I.e. if the text object is located at X=1200, Y=700, and the Value in the text is "10.4", the point would be located at X=1200, Y=700, and Z=10400.
    1 point
  4. That's no problem - if it helps everyone out then all is good.
    1 point
  5. Your not very clear on what you want. You might also mention what you want to do with the selection. I hope @Steven P doesn't mind, I adapted his code to type in the search parameters. See if this is what you want? ;;; Select all the matching texts/mtexts of the file at the same time. ;;; ;;; https://www.cadtutor.net/forum/topic/74112-lisp-to-select-multiple-text-and-mtext-values-entered/#findComment-671522 ;;; ;;; By Steven P ;;; ;;; SLW210 (a.k.a. Steve Wilson) Changed original to add typed in selection for search. ;;; ;;; https://www.cadtutor.net/forum/topic/74112-lisp-to-select-multiple-text-and-mtext-values-entered/page/2/#findComment-672082 ;;; (defun c:SATM ( / MyEnt MyText MySS FinalSS acount EntData txtString ) ;; Prompt for search string instead of selecting a MTEXT entity (setq MyText (getstring T "\nEnter text to search for: ")) ;; Select all TEXT and MTEXT entities in the drawing (setq MySS (ssget "X" '((0 . "TEXT,MTEXT")))) ;; Create an empty selection set for matched entities (setq FinalSS (ssadd)) (setq acount 0) ;; Loop through all entities and match their text content (while (< acount (sslength MySS)) (setq MyEnt (ssname MySS acount)) (setq EntData (entget MyEnt)) (setq txtString (strcase (cond ((cdr (assoc 1 EntData))) ; TEXT or MTEXT first part ((cdr (assoc 3 EntData))) ; Additional MTEXT ))) (if (and txtString (wcmatch txtString (strcat "*" (strcase MyText) "*"))) (setq FinalSS (ssadd MyEnt FinalSS)) ) (setq acount (1+ acount)) ) ;; Optional: highlight matching entities (if (> (sslength FinalSS) 0) (progn (sssetfirst nil FinalSS) (princ (strcat "\nFound " (itoa (sslength FinalSS)) " matching entities.")) ) (princ "\nNo matching text found.") ) ;; do what you want here with found texts (princ) )
    1 point
  6. @pkenewell thank you for that, it works perfectly.... One day i will understand how lisp language works, then i will retire and never use it again
    1 point
  7. So a wildcard - caractere generique - is a modifier added to some text that some functions use to do other things. In this case '*' is a wild card meaning any other characters, a string of characters or non at all: "*text" will find 'Text' and also 'mtext'. Here is a better (English Language) description than I can write with the different wildcards listed https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-EC257AF7-72D4-4B38-99B6-9B09952A53AD In my examples above you can generally replace 'mtext' with '*text' to select both forms (and also rtext which is rarely used I think) For example (setq MySS (ssget (list (cons 0 "MTEXT")(cons 1 (strcat "*" MyText "*"))))) Can be to capture both types of text (setq MySS (ssget (list (cons 0 "*TEXT")(cons 1 (strcat "*" MyText "*"))))) To automatically select all the texts in the page you can change (ssget (list (.... or (ssget '(( to add a modifier to the function, for everything add '_X' (setq MySS (ssget "_X" (list (cons 0 "*TEXT")(cons 1 (strcat "*" MyText "*"))))) Again a link with a better description and more modfiers: https://lee-mac.com/ssget.html
    1 point
  8. An interesting feature is that if you select a text like L1, the numbering continues to L9, then comes M0...M9, etc.
    1 point
×
×
  • Create New...