Leaderboard
Popular Content
Showing content with the highest reputation since 03/23/2025 in Posts
-
Use entmakex. ; A 1000x500 rectangle with horizontal sides with a global width of 40, vertical sides with a global width of 0. (defun c:RectWidth-hor40 (/ pt1 pt2 hWidth vWidth p1 p2 p3 p4 pl) (setq width 1000 ; Rectangle width height 500 ; Rectangle height hWidth 40 ; Global width of horizontal sides vWidth 0) ; Global width of vertical sides (setq pt1 (getpoint "\nSpecify the insertion point: ")) (setq p1 pt1 p2 (list (+ (car pt1) width) (cadr pt1)) p3 (list (+ (car pt1) width) (+ (cadr pt1) height)) p4 (list (car pt1) (+ (cadr pt1) height))) (setq pl (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) (cons 10 p1) (cons 40 hWidth) (cons 41 hWidth) (cons 10 p2) (cons 40 vWidth) (cons 41 vWidth) (cons 10 p3) (cons 40 hWidth) (cons 41 hWidth) (cons 10 p4) (cons 40 vWidth) (cons 41 vWidth) ) ) ) (princ) )2 points
-
solved it, instead of pt I put '(0.0 0.0 0.0) and it works.(pt and r are acquired at start of lisp) THANX again for ur help and guidance, and @Tharwat for his lisp that gave me idea2 points
-
I really miss that guy. ;/ He was such a witty kind person and one of the most talented lisp programmers I knew.2 points
-
I hate spending time correcting AI-generated code, but the first thing that sticks out is that the following: (setq attArray (vla-getattributes vlaBlock)) Will return a safearray variant, which cannot be iterated directly using foreach. Instead, you can use: (setq attArray (vlax-invoke vlaBlock 'getattributes)) Which will return the data using native data types, i.e. a list. You can find more examples here.2 points
-
This function was originally written by the late great Michael Puckett - https://www.theswamp.org/index.php?topic=38072.02 points
-
PS: Someday you'll win one of those public tenders, and when that happens, I hope you'll come over here and have a coffee with one of us Good luck!2 points
-
Hi @PGia I think this should meet your needs. I could say I wrote it from scratch just for you, but really, I also did it for myself. I had a good time revisiting old concepts. As I said, this is much easier to do with Map or Civil3D, creating topologies and manipulating them with the 'mnt*' functions. But writing this code has helped me prove that these tools can also be done in Lisp, with reasonably good results. The expressions are in my language. You'll have to translate them into yours. ;******************* G L A V C V S ******************* ;********************* F E C I T ********************* (defun c:spf>PGia (/ conj cj cjP ent n lstent en ex d pt i l lC lCs cE ltS ltV ltds s lSV actEtqs selR) (defun lSV (l / p r) (setq ltS (cons (list (setq s (vlax-ename->vla-object (car l))) (cadr l)) ltS) lCs (cons (list s (last l)) lCs)) (foreach x (reverse (cdr l)) (if p (if (not (member x ltds));ltds es la lista de los ya tocados (if (setq r (assoc p ltV)) (setq ltV (subst (list (car r) (+ (cadr r) (vla-get-area x))) r ltV) ltds (cons x ltds));ltV es una lista en que se asocia el identificador de las lineas contenedoras con la suma de la áreas de las contenidas (setq ltV (cons (list p (vla-get-area x)) ltV) ltds (cons x ltds)) ) ) ) (setq p x) ) ) (defun actEtqs (/ a b c e p pc l et tx) (foreach v (reverse ltS) (setq e (car v) p (cadr v) pc (last v)) (if (= (vla-get-layer e) "US") (setq l (cadr (assoc e lCs)) tx (vl-some '(lambda (x) (if (equal (cadr x) l) (vla-get-textstring (car x)))) ltS)) (setq tx nil) ) (if (/= (vla-get-layer e) "GEN") (vla-put-color p 6)) (vla-put-textstring e (strcat (if tx (strcat tx "-") "") (vla-get-textstring e) ":" (rtos (- (vla-get-area p) (if (setq a (assoc p ltV)) (cadr a) 0)) 2 2)) ) ) ) (defun selR (p / r s l lt en ex cj n o r4 f) (defun r2+ (p l r / i b) (vl-some '(lambda(g) (= 2 (setq r (if (foreach a (cons (last l) l) (if b (if (inters p (polar p g d) b (setq b a)) (setq i (not i))) (setq b a)) i) (+ r 1) r)))) '(0 1.5708 3.141592 4.71239) ) ) (if (setq cj (ssget "_F" (list p (list (car p) (+ (cadr p) (getvar "viewsize")))) (list '(0 . "LWP*") (cons 8 "PRMTR") '(-4 . "&=") '(70 . 1)) ) ) (while (setq e (ssname cj (setq n (if n (1+ n) 0)))) (if (r2+ p (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget e))) 0) (progn (setq l (cons (vlax-ename->vla-object e) l)) (if (ssmemb e cjP) (ssdel e cjP))) ) ) ) (if l (vl-sort l '(lambda (a b) (< (vla-get-Area a) (vla-get-Area b))))) ) (setq en (getvar "extmin") ex (getvar "extmax") n -1 d (max (- (car ex) (car en)) (- (cadr ex) (cadr en))) ) (vla-zoomExtents (vlax-get-acad-object)) (setq cjP (ssget "x" (list '(0 . "LWP*") (cons 8 "PRMTR") '(-4 . "&=") '(70 . 1)))) (if (setq conj (ssget "_X" '((0 . "TEXT") (8 . "GEN,US")))) (while (setq ent (ssname conj (setq n (1+ n)))) (setq lstent (entget ent) pt (cdr (assoc 10 lstent))) (if (setq l (selR pt)) (lSV (cons ent l)) (princ (strcat "\n*** Etiqueta " (cdr (assoc 1 lstent)) " huerfana"))) ) ) (if (> (sslength cjP) 0) (alert "ATENCION: Hay polilíneas sin asignar")) (alert (strcat "Numero de perímetros procesados: " (itoa (length ltS)))) (actEtqs) (princ) )2 points
-
See attached code. 1. run the lisp in paper space. 2. the lisp prompt you to select a point on the block IN PAPER SPACE!! - click on the block. 3. click on the start point of the MLeader arrow - you are in paper space, no wories... 4. place the MLeader. 5. if you want to label another block go ahead. 6. to exit hit escape key or mouse right click. EDIT: the lisp works in model space as well. (defun c:MLeaderWBlname( / *error* temperr osnp tm tagname ptms ss ensel obj obj1 nam);ptps ptps1 (setq temperr *error*);store *error* (setq *error* trap1);re-assign *error* (setq osnp (getvar "OSMODE")) (setvar "OSMODE" 0) (setq tm (getvar "TILEMODE")) (princ "Select object in paper space,select start point of MLeader,exit with esc'") (while 1 (if (= tm 0);if in paper space (progn (getpoint) ;;get point in paper space on the target object (command "._MSPACE") (setq ptms (cadr (grread t)));;get the point where the cursor is on the target object in model space (setq ss (ssget ptms));;selction set of the object crossing the ptms point (setq obj(ssname ss 0)) (command "._PSPACE") );progn (progn ;in model space (setq ensel (entsel "\nSelect Block: ")) ;select the block object to copy (setq obj (car ensel)) ;set the block object to varaible );progn );if (setq obj1 (vlax-ename->vla-object obj)) (setq nam (vlax-get-property obj1 (if (vlax-property-available-p obj1 'effectivename) 'effectivename 'name ) ) ) (command "_mleader" "H" pause pause nam) );end while (setq *error* temperr) (princ) ) (defun trap1 (errmsg) (command "._PSPACE") (SETVAR "OSMODE" osnp) (princ) )2 points
-
One solution would be to turn off grips inside blocks. Open the Options window, go to the Selection tab, and turn off "Show grips within blocks" in the Grips pane. That way the only grip you can pick is the insertion point.1 point
-
here is the code with proper error handling and @BIGAL revised getpoint: (defun c:MLeaderWBlname( / trap1 olderr osnp tm tagname ptms ss ensel obj obj1 ifobj nam) (defun trap1 ( msg );define error trap (setq *error* olderr);restore *error* symbol (SETVAR "OSMODE" osnp);reset OSMODE (princ) ) (setq olderr *error*); assign current function defintion held by the *error* symbol to a local variable - olderr (setq *error* trap1); pointing the *error* symbol to new function definition - trap1 (setq osnp (getvar "OSMODE")) (setvar "OSMODE" 0) (setq tm (getvar "TILEMODE")) (setq ifobj 0) (while (getpoint "\nSelect object in paper space,select start point of MLeader,exit with ENTER/ESC/Right Click") ;;get point in paper space on the target object (if (= tm 0);if in paper space (progn (command "._MSPACE") (setq ptms (cadr (grread t)));;get the point where the cursor is on the target object in model space (if (=(setq ss (ssget ptms)) nil) ;;selction set of the object crossing the ptms point (progn (alert "There is no selection set please run again") (setq ifobj 0) (command "._PSPACE") );progn (progn (command "._PSPACE") (setq obj(ssname ss 0)) (setq ifobj 1) );progn );if );progn (progn ;in model space (setq ensel (entsel "\nSelect Block: ")) ;select the block object to copy (setq obj (car ensel)) ;set the block object to varaible (setq ifobj 1) );progn );if (if (= ifobj 1) ;; check if there is a selection set (progn (if (= (cdr (assoc 0 (entget obj))) "INSERT");; check if selected object is block (progn (setq obj1 (vlax-ename->vla-object obj)) (setq nam (vlax-get-property obj1 (if (vlax-property-available-p obj1 'effectivename) 'effectivename 'name ) ) ) (command "_mleader" "H" pause pause nam) (setq ifobj 0) );progn (alert "Not a Block") );if );progn (alert "Not a Block") );end if );end while (setq *error* olderr); restore *error* symbol (command "._PSPACE") (SETVAR "OSMODE" osnp) (princ) )1 point
-
Basically, I've made a call to 'vl-some' to check if 'ptclick' matches any of the points in 'coordslist'. If so, the code jumps to '(setq zc (last ptclick))' and terminates the function.1 point
-
Hi @dilan I understand that when that happens, it should simply return the vertex's z-coordinate. Therefore, it's just a matter of setting a filter before considering the other cases. I've edited your code to avoid explanations that would likely be more extensive than doing it this way. (defun get_Z_3Df (ss ptclick / acadObject acadDocument modelspace acadlayers acadblock util butlast midpoint ss objlist coordslist ptclick numerator denomiator cobj coord xc yc zc z0 i pfacelist ofacelist aface c0 c1 c2 c3 c4 c5 j pvertexlist overtexlist xp yp zp zp1 atri fpt spt tpt cpt inter1 inter2 inter3 rtri rfpt rspt rtpt x0 x1 x2 y0 y1 y2 z1 z2 ) ;----------------- ;; Example: ;;; (get_Z_3Df (ssget '((0 . "3dface"))) ;;; (getpoint "\nSpecify the point ->>") ;;; ) ;----------------- (vl-load-com) ;----------------- (setq acadObject (vlax-get-acad-object) acadDocument (vla-get-ActiveDocument acadObject) modelspace (vla-get-ModelSpace acadDocument) acadlayers (vla-get-layers acadDocument) acadblock (vla-get-Blocks acadDocument) util (vla-get-utility acadDocument) ) ;---------------------------------------------------------- (defun midpoint (a b) (polar a (angle a b) (* (distance a b) 0.5)) ) ;---------------------------------------------------------- (defun butlast (l) (reverse (cdr (reverse l)))) ;---------------------------------------------------------- (setq objlist '() Cobj nil coords nil coordslist '() zc nil ) (setq objlist (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) ) ) (setq i objlist) (repeat (length objlist);objlist es la lista del conjunto (setq cobj (car i) i (cdr i) ) (setq coord (vlax-safearray->list (vlax-variant-value (vlax-get-property cobj 'Coordinates)) ) ) (setq coordslist (cons coord coordslist)) ) ;----------------------------- (setq xc (car ptclick) yc (cadr ptclick) ) ;====================================== (= 1. 1.2 2.0) (if (and ptclick ss) (if (not (vl-some '(lambda(l / c x y c n) (while (and (not c) (setq x (nth (setq n (if n (+ n 3) 0)) l))) (setq c (equal (list x (setq y (nth (1+ n) l))) (list (car ptclick) (cadr ptclick)) 1e-8)) c ) ) coordslist ) ) (progn (setq i coordslist) (setq pfacelist '()) (setq ofacelist '()) (repeat (length i) (setq aface (car i) i (cdr i) ) (setq c0 (car aface) c1 (cadr aface) c2 (caddr aface) c3 (cadddr aface) c4 (cadddr (cdr aface)) c5 (cadddr (cddr aface)) ) (if (and (= c0 c3) (= c1 c4) (= c2 c5)) (setq j 3) (setq j 0) ) (setq pvertexlist '()) (setq overtexlist '()) (repeat (- (length aface) 3) (repeat j (setq aface (cdr aface))) (setq xp (car aface) yp (cadr aface) zp 0.0 zp1 (caddr aface) ) (setq pvertexlist (cons (list xp yp zp) pvertexlist)) (setq overtexlist (cons (list xp yp zp1) overtexlist)) (setq j 3) ) (setq pvertexlist (reverse pvertexlist)) (setq overtexlist (reverse overtexlist)) (setq pfacelist (cons pvertexlist pfacelist)) (setq ofacelist (cons overtexlist ofacelist)) ) (repeat (length pfacelist) (setq atri (car pfacelist) pfacelist (cdr pfacelist) ) (setq fpt (car atri) spt (cadr atri) tpt (caddr atri) ) (setq cpt (inters fpt (midpoint spt tpt) spt (midpoint fpt tpt)) cpt (butlast cpt) ) (setq inter1 (inters ptclick cpt fpt spt) inter2 (inters ptclick cpt spt tpt) inter3 (inters ptclick cpt tpt fpt) ) (setq rtri (car ofacelist) ofacelist (cdr ofacelist) ) (setq rfpt (car rtri) rspt (cadr rtri) rtpt (caddr rtri) ) (if (and (null inter1) (null inter2) (null inter3)) (progn (setq x0 (car rfpt) y0 (cadr rfpt) z0 (caddr rfpt) x1 (- (car rspt) x0) y1 (- (cadr rspt) y0) z1 (- (caddr rspt) z0) x2 (- (car rtpt) x0) y2 (- (cadr rtpt) y0) z2 (- (caddr rtpt) z0) ) (setq numerator (+ (* (- xc x0) (- (* y1 z2) (* y2 z1))) (* (- yc y0) (- (* x2 z1) (* x1 z2))) ) denomiator (- (* x2 y1) (* x1 y2)) ) (if (not (zerop denomiator)) (setq zc (+ z0 (/ numerator denomiator))) ) ) ) ) ) (setq zc (last ptclick)) ) ) zc )1 point
-
Glad to help : ) Here's another that is not a block. (defun c:foo (/ p) (while (setq p (getpoint "\\nPick a point: ")) (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(67 . 0) '(8 . "L-MVIEW") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 129) '(38 . 0) '(39 . 0) (cons 10 p) '(40 . 40) '(41 . 40) '(42 . 0) '(91 . 0) (cons 10 (setq p (mapcar '+ '(1000 0) p))) '(40 . 0) '(41 . 0) '(42 . 0) '(91 . 0) (cons 10 (setq p (mapcar '+ '(0 400) p))) '(40 . 40) '(41 . 40) '(42 . 0) '(91 . 0) (cons 10 (setq p (mapcar '+ '(-1000 0) p))) '(40 . 0) '(41 . 0) '(42 . 0) '(91 . 0) ) ) ) (princ) )1 point
-
@Nikon It's also good practice to retrieve variables before changing them. ;; Change this (setq vwidth 0) ;; To this (setq vwidth (getvar 'plinewid))1 point
-
Exactly. Why don't you use a block for this? (defun c:foo (/ p) (cond ((null (tblobjname "block" "FOO")) (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockReference") (2 . "FOO") (10 0. 0. 0.) (70 . 0) ) ) (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (8 . "L-MVIEW") (100 . "AcDbPolyline") (90 . 4) (70 . 129) (38 . 0.) (39 . 0.) (10 1000. 0.) (40 . 0.) (41 . 0.) (42 . 0.) (91 . 0) (10 1000. 500.) (40 . 40.) (41 . 40.) (42 . 0.) (91 . 0) (10 0. 500.) (40 . 0.) (41 . 0.) (42 . 0.) (91 . 0) (10 0. 0.) (40 . 40.) (41 . 40.) (42 . 0.) (91 . 0) ) ) (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0"))) ) ) (while (setq p (getpoint "\\nPick a point: ")) (entmakex (list '(0 . "INSERT") '(2 . "FOO") (cons 10 p))) ) (princ) )1 point
-
This is the easiest way to do it, taking advantage of your code (defun c:RectWidth-hor40 (/ pt1 pt2 hWidth vWidth p1 p2 p3 p4 cj) (setq width 1000 ; Rectangle width height 500 ; Rectangle height hWidth 40 ; Global width of horizontal sides vWidth 0) ; Global width of vertical sides (setq pt1 (getpoint "\nSpecify the insertion point: ")) (setq p1 pt1 p2 (list (+ (car pt1) width) (cadr pt1)) p3 (list (+ (car pt1) width) (+ (cadr pt1) height)) p4 (list (car pt1) (+ (cadr pt1) height))) (setvar 'PLINEWID hWidth) (setq cj (ssadd)) (command "_.PLINE" p1 p2 "") (ssadd (entlast) cj) (command "_.PLINE" p3 p4 "") (ssadd (entlast) cj) (setvar 'PLINEWID vWidth) (command "_.PLINE" (list (car p1) (cadr p1)) (list (car p1) (+ (cadr p1) height)) "") (ssadd (entlast) cj) (command "_.PLINE" (list (car p2) (cadr p2)) (list (car p2) (+ (cadr p2) height)) "") (ssadd (entlast) cj) (command "_pedit" "_m" cj "" "_j" 0 "") (princ) )1 point
-
1 point
-
1 point
-
Well done An alternative would be to move (setq rtn (cons ent rtn)) outside of the if statement, e.g.: (defun getblockentities ( blk / ent enx rtn ) (if (setq ent (tblobjname "block" blk)) (while (setq ent (entnext ent)) (setq rtn (cons ent rtn) enx (entget ent) ) (if (= "INSERT" (cdr (assoc 0 enx))) (setq rtn (append (reverse (getblockentities (cdr (assoc 2 enx)))) rtn)) ) ) ) (reverse rtn) )1 point
-
https://www.cadtutor.net/forum/topic/96878-assign-color-to-a-block-and-its-nested-blocks/1 point
-
Personally I wouldn't rely on the attribute order unless absolutely necessary (i.e. when faced with duplicate attribute tags).1 point
-
Ditto. I never knew it was possible to genuinely grieve the loss of someone you'd never met in person, but when I see an old post of his I'm reminded of just how much he contributed to the community and how much I miss our conversations.1 point
-
Just a comment when you get the attributes as a list you can edit any attribute by its position in the list so don't need a Tag name search. (nth 9 atts) is "TYPE" the 1st item in a list is (nth 0 .Sometimes its easier to do it this way.1 point
-
Of course it happens in the lisp, that's the idea. see at the start of the code (setq osnp (getvar "OSMODE")) (setvar "OSMODE" 0) and at the end of the code restore the OSNAP mode: (command "._PSPACE") (SETVAR "OSMODE" osnp) (princ) Try selecting the block with the cursor trying to snap at every entity around...1 point
-
try the last code and finish the command with ENTER, not escape or right click. only ENTER.1 point
-
1 point
-
In AutoCAD, theoretically, yes. Save this code to a file and name it with the lsp extension. Type 'appload' in the command line, search for, select the file you created, and press the 'Load' button. After that, the file will be loaded. Then, modify DIMSTYLE from the command line: if you get a message... WIN! (if (not GL*react*) (setq GL*react* (vlr-sysvar-reactor nil '((:vlr-sysVarChanged . aviso)))) ) (defun aviso (e p / r) (if (eq (car p) "DIMSCALE") (alert (vl-list->string (reverse '(33 33 78 65 67 32 117 111 89 10 33 33 115 110 111 105 116 97 108 117 116 97 114 103 110 111 67)) ) ) ) )1 point
-
'Hatch' isn't defined in the block definition, but the hatch references the block it is contained in (I think) - the opposite to what you'd expect.1 point
-
A couple of ways to do this: Create the block without the hatch, bedit it and in the block editor add the hatch. Use entmakex to create the block so that you have the block entity name to go into. This is slow though, opens up the block editor on the screen so also gives screen changes. This uses pure entmake. A more efficient way is to use vla-addhatch - it is all online with the key to this method being you need to add (vla-evaluate MyHatch) at the end of the hatch definition (where MyHatch is your hatch definition). It doesn't use entmake as such but things like the outlines, hole, hatch patterns etc. can all be done with entmake. This method doesn't open the block editor and is a lot quicker. -EDIT- Link wasn't a goo example1 point
-
use the last code I shared - it deals with the error issue. if it dosn't work - stroke out all the error refrences in the code. I didn't had any issues but if you think the error hadling give you problems than take it out.... edit: in the error trap change (command "._PSPACE") to (SETVAR "TILEMODE" 0) it is not a command so mybe this will solve the issue.1 point
-
Hi p7q, here are some approach that maybe will work for you. (command-s "_.dimradius" "_non" arc "_non" intersection "") and if the above function doesn't work, try the one below. (setq adoc (vla-get-activedocument (vlax-get-acad-object)) ms (vla-get-modelspace adoc)); insert at start of the program (vlax-invoke ms 'adddimradial center arc 0.); replace line of command-s1 point
-
A slightly more complete version. Maybe it will be useful to someone someday. (defun c:GLAVCVSfibo (/ n cierraOtro p1 p2 p3 p4 i osmant cja f1 f2) (defun cierraOtro (f1 f2 / d ang) (setq d (+ f1 f2) ang (angle p2 p3) ) (command "_pline" (setq p1 p3) (setq p2 (polar p3 ang d)) (setq p3 (polar p2 (- ang i) d)) (setq p4 (polar p3 (- ang i i) d)) (polar p4 (- ang PI i) d) "") (command "_arc" "c" p4 p3 p1) (ssadd (entlast) cja) ) (setq n (getint "\nFibonaciCAD: Specifies number of sequences: ")) (setq f1 0 f2 1 i (/ PI 2) osmant (getvar "osmode")) (setvar "osmode" 0) (command "_pline" (setq p1 '(0 0)) (setq p2 '(-1 0)) (setq p3 '(-1 1)) (setq p4 '(0 1)) '(0 0) "") (command "_arc" "c" p4 p3 p1 "") (setq cja (ssadd)) (ssadd (entlast) cja) (repeat (- n 1) (cierraOtro f1 f2) (setq f f2 f2 (+ f1 f2) f1 f) ) (command "_pedit" "_m" cja "" "" "_j" 0 "") (setvar "osmode" osmant) (princ) )1 point
-
@Nikon You should keep one thing in mind: the actual number of iterations will be 1 more than you specify. I forgot to consider the first one, which is done before the loop. Therefore, you should change 'repeat n' to 'repeat (- n 1)'1 point
-
Maybe something like this? (defun c:GLAVCVSfibo (/ n cierraOtro p1 p2 p3 p4) (defun cierraOtro (f1 f2) (setq d (+ f1 f2) ang (angle p2 p3) ) (command "pol" p3 (setq p2 (polar p3 ang d)) (setq p3 (polar p2 (- ang i) d)) (setq p4 (polar p3 (- ang i i) d)) (polar p4 (- ang PI i) d) "") ) (setq n (getint "\nFibonaciCAD: Specifies number of sequences: ")) (setq f1 0 f2 1 i (/ PI 2)) (command "pol" '(0 0) (setq p2 '(-1 0)) (setq p3 '(-1 1)) '(0 1) '(0 0) "") (repeat n (setq f f2 f2 (+ f1 f2) f1 f) (cierraOtro f1 f2) ) (princ) )1 point
-
The function EXTRACTNUMBER has been added. The code works. Thanks!1 point
-
If you submit integers to the divide function, the result will be an integer. See help ... This is possible: remove the variable "op" from local variables, which could give: (defun c:CalcTwoTxt ( / ss1 ss2 val1 val2 key rslt inspt) (princ "\nSelect first text") (while (not (setq ss1 (ssget "_+.:E:S" '((0 . "*TEXT")))))) (princ "\nSelect second text") (while (not (setq ss2 (ssget "_+.:E:S" '((0 . "*TEXT")))))) (setq val1 (extractnumber (cdr (assoc 1 (entget (ssname ss1 0)))))) (setq val2 (extractnumber (cdr (assoc 1 (entget (ssname ss2 0)))))) (cond ((and val1 val2) (if (not op) (setq op "+")) (initget "* + - /") (setq key (getkword (strcat "\nSelect an operation [*/+/-/\/]? <" op ">: "))) (if key (setq op key)) (if (and (eq op "/") (member 0 val2)) (setq rslt 0.0) (setq rslt (apply (read op) (append val1 val2))) ) (initget 1) (setq inspt (getpoint "\nSpecify the insertion point of the result: ")) (command "_.TEXT" inspt "2.5" "0" (rtos rslt 2 2)) ) (T (princ "\No value found in text")) ) (prin1) )1 point
-
1 point
-
@maahee Are you sure that this point '(polar p1 (* pi 1.75) 1))' will lie inside the rectangle?1 point
-
Just an idea for internal boundaries, not just one, if you make a list of ((area1 ent1)(area2 ent2)...) you can sort on areas the only one to keep is the second largest area, you have entity names so can erase all the others. Have a go plenty here will help if you get stuck.1 point
-
https://www.lee-mac.com/outlineobjects.html Or manually change all rectangles to regions then use the union command.1 point
-
Nikon, you forgot to add open and closing brackets for v1 and v2... Like I said it should be : (atof v1) and (atof v2)...1 point
-
Whereever in the code occurs v1 or v2, change them to (atof v1) and (atof v2)...1 point
-
Easy solution NO CODE, draw a closed pline around your shapes, Type Bpoly, pick point between shapes and out side pline, a pline around outside of shapes should be there now erase outer plines, yes plines as bpoly adds one to outside.1 point
-
1 point
-
To keep the dimension associated with the measurement, I'd create a new style identical to the current one, only without the diameter symbol. Change the name by one letter so it shows up next to the original in the list, and you'll remember to update both styles if that becomes necessary.1 point
-
1 point
-
1 point
-
Can you not just click on the dim and in properties just remove the %%d or the dia symbol. You can overwrite any dim, if you replace the text with <> it should revert back to the actual distance.1 point
-
1 point
-
I made this a long long time ago , before I new about Shell.Application etc. Not the prettiest by today's standards but it got the job done for me at that time. getfolder.lsp GetFolder.DCL1 point