Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/23/2019 in all areas

  1. Here are some quickly written functions that may be of help - ; (GetInstancesOf (lambda (x)(= 10 (car x))) (entget (car (entsel "\nPick polyline")))) ; >> ((10 1288.07 1710.1) (10 2258.12 2318.01) (10 2529.53 2318.01) (10 3871.5 1865.85) (10 4595.26 2368.25) (10 5032.54 2212.5)) ; tf - test function ; L - list (defun GetInstancesOf ( tf L ) ( (lambda (f tf L) (f tf L)) (lambda (tf L) (if (setq L (vl-member-if 'tf L)) (cons (car L) (f tf (cdr L))) ) ) tf L ) ); defun ; (SubstInstances '((x)(= 10 (car x))) '(0 2) '("Donald" "Trump") (entget (car (entsel "\nPick polyline")))) ; >> ; ((-1 . <Entity name: 76940ffd10>) (0 . "LWPOLYLINE") (330 . <Entity name: 76b2f399f0>) (5 . "269") (100 . "AcDbEntity") ; (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbPolyline") (90 . 6) (70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0) ; "Donald" (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) ; (10 2258.12 2318.01) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) ; "Trump" (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) ; (10 3871.5 1865.85) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) ; (10 4595.26 2368.25) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) ; (10 5032.54 2212.5) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0) ; ) ; sL - source list ; tf - test function ; nL - positions to subst ; aL - list of new items (defun SubstInstances ( tf nL aL sL / i ) (setq i -1) (mapcar (function (lambda (x / itm) (cond ( (not (tf x)) x) ( (not aL) x) ( (member (setq i (1+ i)) nL) (setq itm (car aL)) (setq aL (cdr aL)) itm) (x) ); cond ); lambda ); function sL ); mapcar ); defun And heres some test function (tested on a LWPOLYLINE, since it has multiple dxf 10 values in its elist and its a graphical entity which is suitable for a preview during testing) - (defun C:test ( / enx vL nL p p2 ) (and (setq enx (car (entsel "\nPick a polyline: "))) (setq enx (entget enx)) (member '(0 . "LWPOLYLINE") enx) (setq vL (GetInstancesOf '((x)(= 10 (car x))) enx)) (setq nL ('((f n) (reverse (f (1- n)))) '((n) (if (> n -1) (cons n (f (1- n))))) (length vL))) (progn (foreach n nL ; use 'nL' or a custom list like: '(0 2 5 12) (and (setq p2 (nth n vL)) (setq p (getpoint (cdr p2) (strcat "\nSpecify new " (itoa (1+ n)) (cond ( (nth n '("st" "nd" "rd" "th")) ) ("th") ) " vertex of the polyline: " ) ) ) (setq enx (SubstInstances '((x)(= 10 (car x))) (list n) (list (cons 10 p)) enx)) ; update within the iteration for a real-time preview (entmod enx) ); and ); foreach (princ "\nPress anything to restore the shape") (grread) (entmod (SubstInstances '((x)(= 10 (car x))) nL vL enx)) ); progn ) (princ) ); defun
    1 point
  2. it's not difficult task. there are many useful functions ready to use just search or google. example --> old thread offset table (hp:table list insertion title size) ; just need to populate your data in the list (list ( ... ) ; 1st row ( ...) ; 2nd row (...) ; 3rd row (...) ; 4th row (...) ; nth row etc... ) This is very basic code see learn how coordinates put at 4th row? (defun c:test (/ pt x y z lst) (and (setq i 3 pt (getpoint "\nSpecify point of table..") ) (setq x (car pt) ; easting y (cadr pt) ; northing z (caddr pt) ; elevation ) (hp:TABLE (setq lst (list '("PT" "EASTING" "NORTHING" "ELEV" "REMARK") '("1" "0.000" "0.000" "10.00" "A") '("2" "123.00" "456.00" "20.00" "B") '("3" "-987.00" "654.00" "30.00" "C") ;;learn to populate list here (list (itoa (setq i (1+ i))) ; increamental (rtos y 2 3) (rtos x 2 3) (rtos z 2 3) "POINT" ) ;;try to add same pattern here see what happen? ) ) pt ; point "COORDINATES TABLE" ; Title 1.0 ; textsize ) ) (princ) )
    1 point
  3. check this old thread --> massoc i'd suggest finding nth position (defun foo (i l / c x ls) (setq c 0) (repeat (length l) (setq x (nth (setq c (1+ c)) l)) (if (= (car x) i) (setq ls (cons c ls)) ) ) (reverse ls) ) assum l1 is your list (setq nl (foo 3 l1)) ; nl = nth / position list ;;;(9 11 13) ;; retrieve nth position in l1 (mapcar ''((x)(nth x l1)) nl) ;;;((3 . "A1") (3 . "A2") (3 . "A3")) to replace new item , assume your wanna replace same index 3 with new item '("B1" "B2" "B3") (defun bar (i new x l) (mapcar ''((a b) (setq l (subst (cons i a) (nth b l) l))) new x ) l ) (bar 3 '("B1" "B2" "B3") nl l1) ;((-1 . <Entity name: 7ff4dca064a0>) (0 . "XRECORD") (330 . <Entity name: 0>) (5 . "2D2") (100 . "AcDbXrecord") (280 . 1) (7 . "Arial") (8 . "A09--T-") (40 . 20.0) ;(3 . "B1") (300 . "61") (3 . "B2") (300 . "69") (3 . "B3") (300 . "72"))
    1 point
  4. yes sir not working but anyway i found it in plot.log file thanks all
    1 point
  5. http://www.cadlispandtips.com/2011/09/lisp-coordinates-with-table.html
    1 point
  6. Is there any lisps to add the layout name (the 1st one) to a drawing file name like a Prefix? drawing file name is 1st floor plan 1st layout name is Part A therefore run lisp drawing file name will become Part A-1st floor plan (with a "-" to separate them) got a couple hundred drawings to do.
    1 point
×
×
  • Create New...