Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/21/2022 in all areas

  1. HERE is the lastest version of that. Many more options
    2 points
  2. That's true, I was going to use car, cadr.. decided to go nth because I reckon if you are learning from this nth is a little more obvious what it's doing - if you can understand that the first list item is number 0. Looking at Guran and RonJon, was the OP asking to create line types or layers using that line type, or both? I am not sure now
    1 point
  3. Try this one by Ron Perez. Linetype.lsp
    1 point
  4. Nice one Steven was almost there but then fell short! Id use car cadr caddr. found that nth is a bit slower (milliseconds). https://www.theswamp.org/index.php?PHPSESSID=356fa17355692a80576aa70cd5845024&topic=57519.msg609731#msg609731 (foreach layer lay (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 (car layer)) (cons 70 (cadr layer)) (cons 62 (caddr layer)) )) ; end entmake ) ; end for eac
    1 point
  5. Could do a list of lists and then the foreach ? ;;Codes: 2, 70, 62) (setq lay (list '("20mm" 0 52) '("40mm" 0 1) '("50mm" 0 2) '("63mm" 0 256) ...... )) ; end list (foreach layername lay (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 (nth 0 layername)) (cons 70 (nth 1 layername)) (cons 62 (nth 2 layername)) )) ; end entmake ) ; end for each off the top of my head as an example - might be typos - the best method might depend how many layers you are making and attributes to be set in each layer
    1 point
  6. I have this code which is very similar to your request. It numbers with a block but also informs the cumulated length of the vertex, its position in X,Y,Z. This can allow data to be extracted to a block attribute file for external processing. BlockAtt2Vtx.lsp
    1 point
  7. You can try this code: It allows you to make a selection by object (line, arc, circle or heavy/light polyline) For closed objects, you will be offered to do either by capture or by window. For open objects this will be the default fence option. Once the objects have been selected, it will be possible to invert the selection, ie to exclude the selected entities and take the rest. For curvilinear objects, the selection points are calculated with a central angle of 1/36 of a radian (line 31&85 of the code), it's up to you to see if this resolution suits you. (defun def_bulg_pl (ls lb flag_closed / ls lb rad a l_new) (if (not (zerop flag_closed)) (setq ls (append ls (list (car ls))))) (while (cadr ls) (if (zerop (car lb)) (setq l_new (append l_new (list (car ls)))) (progn (setq rad (/ (distance (car ls) (cadr ls)) (sin (* 2.0 (atan (abs (car lb))))) 2.0) a (- (/ pi 2.0) (- pi (* 2.0 (atan (abs (car lb)))))) ) (if (< a 0.0) (setq a (- (* 2.0 pi) a))) (if (or (and (< (car lb) 0.0) (> (car lb) -1.0)) (> (car lb) 1.0)) (setq l_new (append l_new (reverse (cdr (reverse (bulge_pts (polar (car ls) (- (angle (car ls) (cadr ls)) a) rad) (car ls) (cadr ls) rad (car lb))))))) (setq l_new (append l_new (reverse (cdr (reverse (bulge_pts (polar (car ls) (+ (angle (car ls) (cadr ls)) a) rad) (car ls) (cadr ls) rad (car lb))))))) ) ) ) (setq ls (cdr ls) lb (cdr lb)) ) (append l_new (list (car ls))) ) (defun bulge_pts (pt_cen pt_begin pt_end rad sens / inc ang nm p1 p2 lst) (setq inc (angle pt_cen (if (< sens 0.0) pt_end pt_begin)) ang (+ (* 2.0 pi) (angle pt_cen (if (< sens 0.0) pt_begin pt_end))) nm (fix (/ (rem (- ang inc) (* 2.0 pi)) (/ (* pi 2.0) 36.0))) ) (repeat nm (setq p1 (polar pt_cen inc rad) inc (+ inc (/ (* pi 2.0) 36.0)) lst (append lst (list p1)) ) ) (setq p2 (polar pt_cen ang rad) lst (append lst (list p2)) ) (if (< sens 0.0) (reverse lst) lst) ) (defun c:sel_by_object ( / ent dxf_ent typent closed lst l_bulg e_next key osmd opkb oapt vmin vmax minpt maxpt zt lst2 l_ent ss1 ss2 js_all tmp) (while (null (setq ent (entsel "\nChoice of entity: ")))) (setq typent (cdr (assoc 0 (setq dxf_ent (entget (car ent)))))) (cond ((eq typent "LWPOLYLINE") (setq closed (boole 1 (cdr (assoc 70 dxf_ent)) 1) lst (mapcar '(lambda (x) (trans x (car ent) 1)) (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 10)) dxf_ent))) l_bulg (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 42)) dxf_ent)) lst (def_bulg_pl lst l_bulg closed) ) ) ((eq typent "POLYLINE") (setq closed (boole 1 (cdr (assoc 70 dxf_ent)) 1) e_next (entnext (car ent)) ) (while (= "VERTEX" (cdr (assoc 0 (setq dxf_next (entget e_next))))) (if (zerop (boole 1 223 (cdr (assoc 70 dxf_next)))) (setq lst (cons (trans (cdr (assoc 10 dxf_next)) (car ent) 1) lst) l_bulg (cons (cdr (assoc 42 dxf_next)) l_bulg) ) ) (setq e_next (entnext e_next)) ) (setq lst (reverse lst) l_bulg (reverse l_bulg) lst (def_bulg_pl lst l_bulg closed) ) ) ((eq typent "LINE") (setq lst (list (trans (cdr (assoc 10 dxf_ent)) 0 1) (trans (cdr (assoc 11 dxf_ent)) 0 1)) closed 0 ) ) ((eq typent "CIRCLE") (setq lst (bulge_pts (trans (cdr (assoc 10 dxf_ent)) (car ent) 1) (polar (trans (cdr (assoc 10 dxf_ent)) (car ent) 1) 0.0 (cdr (assoc 40 dxf_ent))) (polar (trans (cdr (assoc 10 dxf_ent)) (car ent) 1) (- (* 2.0 pi) (/ (* pi 2.0) 36.0)) (cdr (assoc 40 dxf_ent))) (cdr (assoc 40 dxf_ent)) 1 ) lst (append lst (list (car lst))) closed 1 ) ) ((eq typent "ARC") (setq lst (bulge_pts (trans (cdr (assoc 10 dxf_ent)) (car ent) 1) (polar (trans (cdr (assoc 10 dxf_ent)) (car ent) 1) (cdr (assoc 50 dxf_ent)) (cdr (assoc 40 dxf_ent))) (polar (trans (cdr (assoc 10 dxf_ent)) (car ent) 1) (cdr (assoc 51 dxf_ent)) (cdr (assoc 40 dxf_ent))) (cdr (assoc 40 dxf_ent)) 1 ) closed 0 ) ) (T (princ "\nIs not a Line, Arc, Circle or Polyline!")) ) (cond (lst (if (equal (last lst) (car lst)) (setq lst (cdr lst) closed 1)) (setq osmd (getvar "osmode") oapt (getvar "aperture") opkb (getvar "pickbox")) (setvar "osmode" 0) (setq vmin (mapcar '- (getvar "viewctr") (list (/ (* (car (getvar "screensize")) (* 0.5 (getvar "viewsize"))) (cadr (getvar "screensize"))) (* 0.5 (getvar "viewsize")) 0.0)) vmax (mapcar '+ (getvar "viewctr") (list (/ (* (car (getvar "screensize")) (* 0.5 (getvar "viewsize"))) (cadr (getvar "screensize"))) (* 0.5 (getvar "viewsize")) 0.0)) minpt (list (eval (cons min (mapcar 'car lst))) (eval (cons min (mapcar 'cadr lst)))) maxpt (list (eval (cons max (mapcar 'car lst))) (eval (cons max (mapcar 'cadr lst)))) ) (setq zt (or (< (car minpt) (car vmin)) (< (cadr minpt) (cadr vmin)) (> (car maxpt) (car vmax)) (> (cadr maxpt) (cadr vmax)))) (if zt (command "_.zoom" "_window" minpt maxpt)) (setvar "aperture" 1) (setvar "pickbox" 1) (if (zerop (getvar "pickfirst")) (setvar "pickfirst" 1)) (while (car lst) (setq lst2 (cons (car lst) lst2) lst (vl-remove (car lst) lst) ) ) (setq lst (reverse lst2)) (if (zerop closed) (setq ss1 (ssdel (car ent) (ssget "_F" lst))) (progn (initget "WPolygon CPolygon") (setq key (getkword "\nSelection by [WPolygon/CPolygon] <CP>: ")) (if (eq key "WPolygon") (setq ss1 (ssget "_WP" lst)) (setq ss1 (ssdel (car ent) (ssget "_CP" lst))) ) ) ) (setvar "pickbox" opkb) (setvar "aperture" oapt) (setq l_ent (if ss1 (ssnamex ss1)) js_all (ssget "_X") ) (foreach n l_ent (if (eq (type (cadr n)) 'ENAME) (setq ss2 (ssdel (cadr n) js_all)))) (if (and ss1 ss2 (= 0 (getvar "CMDACTIVE"))) (progn (princ "\n<Click+left> to invert the selection; <Enter>/[Space]/Right+click to finish!.") (while (and (not (member (setq key (grread T 4 2)) '((2 13) (2 32)))) (/= (car key) 25)) (sssetfirst nil ss1) (cond ((eq (car key) 3) (setq tmp ss1 ss1 ss2 ss2 tmp) ) ) ) ) ) (setvar "osmode" osmd) ) ) (prin1) )
    1 point
  8. I fixed the -vpoint commad cell so all you need to do is copy/paste the contents of cell F17 to AutoCAD. Here are the results I got for your angles. Is this close enough? I'd like to improve the program and make it faster and more precise. Trimetric view calculator VBA.02.zip
    1 point
  9. Lrm could you just pass to (command "-VPOINT" X,Y,Z) You could just write the correct string to a cell and copy and paste to command line, no need to fill in dcl.
    1 point
  10. This is just a simple lisp unlike coonp.lsp it will ask for a selection of polylines and then create text middle center on their vertices and on the same layer as the polyline. "i" or the text number is reset for every polyline. So the start of the polyline will always be 1 But two things. Because of the annotative text in another drawing text could be a different size. the text ues the right style but annotative is set to no so you might have to change that after the fact (cant figure it out) ;;----------------------------------------------------------------------------;; ;; Add text to all Polylines Vertices (defun C:PolyNumber (/ SS i lay poly) (if (setq ss (ssget '((0 . "*POLYLINE")))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq i 1 lay (cdr (assoc 8 (setq poly (entget ent))))) (foreach pt (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) poly)) (entmake (list '(0 . "TEXT") (cons 8 lay) (cons 10 pt) (cons 11 pt) '(40 . 500) '(41 . 0.85) (cons 1 (rtos i 2 0)) '(72 . 4) '(73 . 2) ) ) (setq i (1+ i)) ) ) ) (princ) )
    1 point
  11. Call Grind for Lisp (CG) is a Lisp application aimed to help profiling of lisp programs running on IntelliCAD, AutoCAD, BricsCAD and alikes. If you are in need of determining the bottle-necks, the time consumed for specified functions , visualize call diagram of your lisp application you may find CG useful. CG collects data (time consumed by each function and call stack) at runtime (dynamic analysis) and creates “call grind” type output to be used by CacheGrind system (credit goes to authors). Requirement: Download and install qcachegrind software recompiled for Windows version of KCacheGrind. Refer to header of the lisp code attached for instructions. Limitation: May fail in consecutive functions forming loop. License: Copy Left Enhanced the code, found a bug? Just let me know. Suha cg.lsp
    1 point
  12. Try this .. solved many years ago. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/meet-joe-burke-s-tracepline-function/td-p/1592287
    1 point
  13. So the 100 is saying divide up the polyline into 100 segments and generate points from that. poly 1 has 5 points and wouldn't select anything between the blue and white poly 2 has 50 points (selectinside e 50) If you are using this on polylines that have a large number of verities then their will be gaps. don't get me wrong iv used that form lee mac for a long time and didn't under stand what it was doing also. But when I finally had time to study what it was doing I came up with this. BAD CODE - use RonjonP link What my lisp does is makes a copy of the polyline and explodes it into its base entity's arcs and lines. for the arcs its dividing them by x and generates points. for lines it calculates the endpoints. adds all those points into a list for ssget "WP" So the points on the shape would look like this. Only adding 5 points if x=5 With larger verities polylines it only add points to where the arc's are. So you don't have to keep guessing the number for the function or generating more points for smaller polyines. I would like to make x dynamic so it divides up larger arc more than smaller ones.
    1 point
  14. 1 point
×
×
  • Create New...