Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/27/2023 in all areas

  1. I just discovered this and anybody wanting to do things with Excel should welcome this, it has multiple functions. I use a couple of FIXO functions now and his efforts to talk to Excel had a huge catalogue. Please note these functions expect a coder has a good knowledge of lisp and how to use defuns etc. XLFIXOLIB.zip
    3 points
  2. (defun c:t1 ( / ss l mid-pt ss->el) (defun mid-pt (e / x) (setq x (entget e))(mapcar '* (mapcar '+ (cdr (assoc 10 x)) (cdr (assoc 11 x))) '(0.5 0.5 0.5))) (defun ss->el (ss / i l) (setq i 0)(repeat (sslength ss)(setq l (cons (ssname ss i) l) i (1+ i))) l) (if (setq ss (ssget (list (cons 0 "Line")))) (setq l (vl-sort (ss->el ss) '(lambda (a b) (< (cadr (mid-pt a)) (cadr (mid-pt b))))))) (setq ss (ssadd) i -2) (while (setq e (nth (setq i (+ i 2)) l))(ssadd e ss)) (command "chprop" ss "" "color" "red" "") ) load code , start with t1 or (c:t1) , select the lines with window or crossing (no problem selecting the leaders also because they are filtered out anyway so don't worry , be happy) et voila...
    2 points
  3. @Subidoooo (setq ang (/ (* (cdr (assoc 42 (entget (car (entsel "select the dim"))))) 180.0) PI)) as assoc 42 show angle in radian
    1 point
  4. Why code I just selected the view and did select a view and rotate eg 90 & -90 and 180 all done. If you want like a box answer lee-mac has get a bounding box of multiple objects so can use that for say a copy or move and rotate placing views side by side.
    1 point
  5. One of the simplest way to edit multiple dwg's is a script it tells the CAD what to do like a command line sequence, you can run lisp programs as well. I have used this on like 100 dwgs but they were small dwg's so the open modify and close was like 2-3 seconds per dwg. open dwg1 (load "mylisp") Close Y open dwg2 (load "mylisp") Close Y open dwg2 (load "mylisp") Close Y There are various programs out there that help write the script like pick a directory and get all the dwg names. I have been making scripts for CAD since Acad 1.7. Look at Scriptpro. In more recent times you can use Accoreconsole which will edit the Autocad dwg without opening it, again you need a working lisp 1st, it uses a script but the script is as simple as (load "mylisp") as the close is done in the lisp. It can be ran as a windows batch program on a directory. https://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html a good reference https://forums.autodesk.com/t5/forums/replypage/board-id/130/message-id/444989
    1 point
  6. Emmanuel Multi toggles will do the dcl for "please choose". Examples at top of code. Returns a list (0 1 0 1 1 1 0) etc 1 is selected toggle is on. Multi toggles.lsp I have sent you PM re send data to excel direct no csv.
    1 point
  7. @elli0t Find attached lisp and result dwg the new command is LAST-CELL sum table last cell.LSP sum Tables last cell.dwg
    1 point
  8. Here's part of the request If somebody wants to handle this dialog part, please do This just saves the file with the same path and filename as the drawing. command DWH for Dataextraction With Handle ; --- writeCSV ---------------------------------------------------------------- ;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/need-a-lisp-for-export-text-to-csv/td-p/9605224 (defun writeCSV ( csvfile dblist dlm / file_w lines text record val) ; function to write .csv file: By Roland.R71 ; Follows csv standards, as far as there are any. ; csvfile = path+filename to use. example: c:\\temp\\mydata.csv ; dblist = a 'database' list of values. (a list of lists) ; dlm = the delimiter to use. example: , ; \t (tab) etc. ; Function checks for delimiter inside values, adds quotes if found. ; ; Example code: ; (setq lst (list '("1" "2" "3") '("4" "5,1" "6") '("7" "8.1" "9") '("" "" ""))) ; (writeCSV "c:/temp/test.csv" lst ",") ; ; example csv file: ; 1,2,3 ; 4,"5,1",6 ; 7,8.1,9 ; ,, (setq file_w (open csvfile "w")) (foreach record dblist (setq i 0 text "") (while (< i (length record)) (setq val (cond ((nth i record))("")) val (cond ((vl-string-search dlm val)(strcat "\"" val "\""))(val)) text (strcat text val) i (1+ i) ) (if (< i (length record)) (setq text (strcat text dlm)) ) ) (write-line text file_w) ) (close file_w) ) (defun c:DWH ( / ss i ent obj type handle layer color len area closed hyperlink row rows) (setq ss (ssget (list (cons 0 "*POLYLINE,SPLINE,REGION,INSERT,CIRCLE,POLYGONS")))) (setq i 0) (setq rows (list (list "TYPE" "HANDLE" "LAYER" "HYPERLINK" "COLOR" "AREA" "LENGTH" ))) (repeat (sslength ss) (princ "\n") (setq ent (ssname ss i)) (setq obj (vlax-ename->vla-object ent)) ;; in case we need visual lisp functions ;; These properties exist for every object ;; type of entity (setq type (cdr (assoc 0 (entget ent)))) ;; entity handle (setq handle (cdr (assoc 5 (entget ent)))) ;; layer (setq layer (cdr (assoc 8 (entget ent)))) ;; color (if (assoc 420 (entget ent)) (setq color (cdr (assoc 420 (entget ent)))) ;; true color (setq color (cdr (assoc 62 (entget ent)))) ;; indexed color ) (setq color (if color (rtos color 2 0) " ")) (princ " ") (princ color) ;;;; properties for some types. and each has a different way of getting it ;;;; ;; length. ;; blocks don't have a length. ;; regios have a perimeter ;; circles have a circumference ;;(setq len (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj))) (setq len 0) (cond ( (= type "CIRCLE") (setq len (vla-get-circumference obj)) ) ( (= type "REGION") (setq len (vla-get-perimeter obj)) ) ( (= type "SPLINE") (setq len (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj))) ) ( (or (= type "LWPOLYLINE") (= type "POLYLINE")) (setq len (vla-get-Length obj)) ) ) ;; Area. only closed objects have it. Not closed splines/polylines don't. (setq area 0) (cond ( (= type "CIRCLE") (setq area (vla-get-area obj)) ) ( (= type "REGION") (setq area (vla-get-area obj)) ) ( (= type "SPLINE") ;; (assoc 70) is even -> not closed. odd -> closed (if (= 1 (rem (cdr (assoc 70 (entget ent))) 2 )) (setq area (vla-get-area obj)) ) ) ( (or (= type "LWPOLYLINE") (= type "POLYLINE")) (if (= 1 (cdr (assoc 70 (entget ent)))) (setq area (vla-get-area obj)) ) ) ) (setq hyperlink "") ;; Hyperlink ;; https://www.cadtutor.net/forum/topic/41225-read-and-create-an-hyperlink/ (vlax-for hyp (vla-get-hyperlinks obj) (setq hyperlink (vla-get-url hyp)) ) ;; "TYPE" "HANDLE" "LAYER" "HYPERLINK" "COLOR" "AREA" "LENGTH" (setq rows (append rows (list (list type handle layer hyperlink color (rtos area 2 4) (rtos len 2 4) ;; CSV export expents strings, not numbers. feel free to change the number of digits (now 4) )))) ;;(princ " *** ") (setq i (+ i 1)) ) ;;(princ rows) ;;(writeCSV csvfile dblist dlm) (writeCSV (strcat (getvar "dwgprefix") (getvar "dwgname") ".csv") rows ",") (princ (strcat "File saves as: " (getvar "dwgprefix") (getvar "dwgname") ".csv")) (princ ) )
    1 point
×
×
  • Create New...