Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/12/2021 in all areas

  1. Use the VLA-get-length obj (VL-LOAD-COM) (SETQ POLY (CAR (ENTSEL "\nSelect the polyline\n"))) (SETQ POLY-OBJ (VLAX-ENAME->VLA-OBJECT POLY)) (SETQ LONG (VLA-GET-LENGTH POLY-OBJ)) I did for this poly
    1 point
  2. YES But looking at your sample its better to make a table of the answer. Just select text then pick point for table. ; https://www.cadtutor.net/forum/topic/73550-help-count-texts-with-filter/ ; example of creating a table using passed variables ; By Alan H July 2017 ; Make a count of common items ; By AlanH Aug 2021 info@alanh.com.au (defun my-count (a L) (cond ((null L) 0) ((equal a (car L)) (+ 1 (my-count a (cdr L)))) (t (my-count a (cdr L)))) ) ; By Gile (defun remove_doubles (lst) (if lst (cons (car lst) (remove_doubles (vl-remove (car lst) lst))) ) ) (defun c:test ( / ss lst lt2 lst3 txt ) (setq ss (ssget (list (cons 0 "TEXT")))) (if (= ss nil) (alert "no text picked") (progn (setq lst '() lst3 '()) (repeat (setq x (sslength ss)) (setq txt (cdr (assoc 1 (entget (ssname ss (setq x (1- x))))))) (setq lst (cons txt lst)) ) (setq lst2 (remove_doubles lst)) (setq howlong 0) (foreach val lst2 (setq cnt (my-count val lst)) (setq lst3 (cons (list val cnt) lst3)) (setq howlong (strlen (car (last lst3)))) (if (> howlong howmany)(setq howmany howlong)) ) ) ) (setq txtht 45) (setq numcolumns 2 numrows (+ 2 (length lst3)) txtsz (* txtht 2.0) colwidth (* howlong 2.0 txtht)) (setq sp (vlax-3d-point (getpoint "Pick top left"))) (setq doc (vla-get-activedocument (vlax-get-acad-object) )) (if (= (vla-get-activespace doc) 0) (setq curspc (vla-get-paperspace doc)) (setq curspc (vla-get-modelspace doc)) ) (setq rowheight (* 3.0 txtht)) (setq objtable (vla-addtable curspc sp numrows numcolumns rowheight colwidth)) (vla-setcolumnwidth objtable 1 (* 3 txtht)) (vla-SetTextHeight Objtable (+ acDataRow acTitleRow acHeaderRow) txtht) (setq n 2) (vla-setcolumnwidth objtable 0 colwidth) (vla-setcolumnwidth objtable 1 400) (vla-settext objtable 0 0 "TABLE title") (vla-SetText Objtable 1 0 "Mark") (vla-SetText Objtable 1 1 "Count") (setq x 0) (repeat (length lst3) (setq val (nth (- n 2) lst3)) (vla-SetText Objtable n 0 (car val)) (vla-SetText Objtable n 1 (cadr val)) (setq n (1+ n)) ) (vla-SetAlignment objtable acDataRow acMiddleCenter) (princ) ) (c:test)
    1 point
  3. A couple of suggestions, if you have a pline no need to explode if using VL, (setq start (vlax-curve-getstartpoint Obj ))(setq end (vlax-curve-getendpoint Obj )) Also not sure why you dont just work out everything in radians it is very rare for me to have to use rtd or dtr. Except for entry of angle but all coding would then be in radians. If a pline is more than l section what then ? Same in my code may not be correct. The only reason I did not post a do all auto is simple draw a line left to right, then a second right to left, one answer will go up the other will go down. with plines same thing depends on direction. The red lines show the length of the original line or pline, Your code middle not sure about this, drew 2 plines L-R & R-L 10 10 45. Mine on right choice up down depending on end picked. Also note your answer increased overall length this is up to RIA to confirm the final length required. There are other posts floating around on multiple forums seeking multiple solutions for a number of patterns like this.
    1 point
  4. You have the box called "Plot with plot styles" checked which is unrelated. Edit your "my style.ctb" click the [Form View] tab up top and modify the settings for "Line end style:" and "Line join style:" Edit: You have to select the plot styles you want to modify first.
    1 point
  5. Hi VAC, Try the following which compute lengths of selected Lines & Polylines based on your request from the first post and the program would ignore the colour ByLayer as long as you wanted to filter them from ( 0 - 256 ) and sort them by colour number for a better presentation. (defun c:Test ( / int sel ent clr len fnd new lst ins tbl row col) ;; Tharwat - Date: 9.April.2021 ;; (and (princ "\nSelect object to computer lengths into AutoCAD Table : ") (setq int -1 sel (ssget '((0 . "LINE,*POLYLINE")))) (while (setq int (1+ int) ent (ssname sel int)) (and (setq clr (cdr (assoc 62 (entget ent)))) (or (and (setq len (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))) (setq fnd (assoc clr lst)) (setq new (list clr (+ (cadr fnd) len)) lst (vl-remove fnd lst) lst (cons new lst) ) ) (setq lst (cons (list clr len) lst)) ) ) ) (setq lst (vl-sort lst '(lambda (j k) (< (car j) (car k))))) (setq ins (getpoint "\nSpecify Table insertion point : ")) (setq tbl (vla-addtable (vlax-get (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))) 'BLOCK) (vlax-3d-point ins) (1+ (length lst)) 2 900 4125) ) (_write:data 0 0 "Length Calculation") (setq row 1 col -1) (foreach itm lst (foreach str (list (car itm) (rtos (cadr itm) 2 2)) (_write:data row (setq col (1+ col)) str) ) (setq row (1+ row) col -1 ) ) ) (princ) ) (vl-load-com) ;; ;; (defun _write:data (r c s) (vla-settext tbl r c s) (vla-setcelltextheight tbl r c 450) (vla-setrowheight tbl r 900) (vla-setcellalignment tbl r c acMiddleCenter) s )
    1 point
×
×
  • Create New...