Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/19/2022 in all areas

  1. ;; Change this (foreach x b (entdel (last x)) (setq r (vl-remove x r))) ;; to this (foreach x b (append (entget (last x)) '((8 . "Duplicate"))) (setq r (vl-remove x r)))
    1 point
  2. (setq lst (cons '("TITLE") lst)) ;replace this line (setq lst (cons (vl-filename-base (getvar 'dwgname)) lst)) ;with this --edit also near the end
    1 point
  3. Unfortunately this is a known bug in AutoCAD - I'm not aware of a way to circumvent this.
    1 point
  4. Divide c by 1000 when its a number. replace the last part of the lisp. (foreach r lst (setq col 0) (vla-SetRowHeight tab row (* 1.5 ht)) (foreach c r (vla-SetText tab row col (if (numberp c) (rtos (/ c 1000) 2 3) ;change 3 to show that many decimal places (vl-princ-to-string c) ) ) (setq col (1+ col)) ) (setq row (1+ row)) ) )
    1 point
  5. The 'upgrade' to the forum software a few years ago caused every occurrence of "8)" within code blocks to be removed rendering many thousands of code posts unusable; I've now updated my earlier post to reinstate the missing characters.
    1 point
  6. Here is most of what you want. Command EPL There are a few problems though. - The order. If you want the same order as the numbers you wrote next to the polylines, then you must pick them one by one, in that same order - The circle is a bit of a problem. I think only returns half its length. Maybe better not use circles. - units. My table will return the same values as you can see in the properties. You divide by a factor 100 for some reason. I don't. (vl-load-com) (defun inserttable (lst pt / ht htc tab i j row tb acObj acDoc space width_cols) ;; settings, text height, cel height (setq ht 12.0) (setq htc 30.0) (setq width_cols (list 80.0 270.0 110.0 120.0 160.0 )) ;; document, model space, ... (setq acObj (vlax-get-acad-object) acDoc (vla-get-activedocument acObj) space (vlax-get acDoc (if (= 1 (getvar 'cvport)) 'PaperSpace 'ModelSpace)) ) (setq tab (vla-addtable space (vlax-3d-point pt) (length lst) (length (cadr lst)) (* 1.1 ht) (* 10.0 ht) )) ;; (vla-SetTextHeight tab 1 ht) (vla-SetTextHeight tab 2 ht) (vla-SetTextHeight tab 4 ht) (vla-put-VertCellMargin tab (* 0.3 ht)) (vla-put-HorzCellMargin tab (* 0.3 ht)) (setq i 0) (repeat (length lst) ;; iterates the rows (vla-setrowHeight tab i htc) (setq row (nth i lst)) (setq j 0) (repeat (length row) ;; iterates the cols in the row ;; (textbox (list (cons 1 (to_string x)) (cons 7 (getvar 'textstyle)) (cons 40 ht) )) (vla-SetColumnWidth tab j (nth j width_cols) ) (vla-SetText tab i j (nth j row) ) (setq j (+ j 1)) ) (setq i (+ i 1)) ) ;; default Autocad expects a title row. If the first row has more than 1 cel, let's unmerge this row (if (> (length (nth 0 lst)) 1) (vla-unMergeCells tab 0 0 0 0) ) ;; Merge last row, to show total ;; MergeCells minRow, maxRow, minCol, maxCol (vla-MergeCells tab (- (length lst) 1) (- (length lst) 1) 0 3) tab ) ;; test of inserttable (defun c:ila ( / ) (inserttable (list (list "P.NO" "EASTING" "NORTHING" "ELEV." "REMARKS") (list "P1" "20.5" "30.5" "40.5" "Hello") (list "P2" "50.5" "60.5" "70.5" "World!") ) (getpoint "\nInsert point of table: ") ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; length of polyline, or most other (curved) lines, spline, ... (defun length_curve (ent / ) (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Export Polyline Lengths (defun c:EPL ( / plines i pline data lay len hei tot total) (setq hei (getreal "\nHeight: ")) (setq plines (ssget (list (cons 0 "LWPOLYLINE,POLYLINE,CIRCLE")))) (setq data (list (list " ") ;; Empty Title (list "NO" "Layer" "Length" "Height" "Total") ;; column titles ) ) (setq i 0) (setq total 0.0) (repeat (sslength plines) (setq pline (ssname plines i)) ;;(setq lst (vlax-get (vlax-ename->vla-object pline) 'coordinates)) ;;(if (= "AcDb2dPolyline" (vla-get-ObjectName (vlax-ename->vla-object pline))) ;; polyline or 2D polyline ? ;; (setq pts (3d-coord->pt-lstrjp lst)) ;; (setq pts (2d-coord->pt-lst lst)) ;;) (setq len (length_curve pline)) (setq tot (* len hei)) (setq lay (cdr (assoc 8 (entget pline)))) (setq data (append data (list (list (itoa (+ i 1)) ;; number lay ;; Layer (rtos len 2 3) ;; length (rtos hei 2 3) ;; height (rtos tot 2 3) ;; total ) ))) (setq total (+ total tot)) (setq i (+ i 1)) ) (setq data (append data (list (list "Total" "" "" "" (rtos total 2 3) ;; total ) ))) (inserttable data (getpoint "\nInsert point of table: ") ) )
    1 point
  7. For starters you could look into SETBYLAYERMODE variable. SETBYLAYERMODE Type: Integer Saved in: Registry Initial value: 127 From the AutoCAD Help Section under system variables. Controls which properties are selected for SETBYLAYER The setting is stored as an integer using the sum of the following values: 0 No properties are selected 1 Color property 2 Linetype property 4 Lineweight property 8 Material property 16 Plot Style property 32 Changes ByBlock to Bylayer 64 Includes blocks when changing ByBlock to ByLayer There is also other information there not shown here. Also look into ssget in the Developer Help Section Creates a selection set from the selected object (ssget [sel-method] [pt1 [pt2]] [pt-list] [filter-list]) Selection sets can contain objects from both paper and model space, but when the selection set is used in an operation, ssget filters out objects from the space not currently in effect. Selection sets returned by ssget contain main entities only (no attributes or polyline vertices). Maybe this thread will give you some idea:http://www.cadtutor.net/forum/showthread.php?t=42062&highlight=SET+BYLAYER+LISP
    1 point
×
×
  • Create New...