Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/01/2022 in all areas

  1. Give this a try: (defun c:foo (/ _getvalue f s) (defun _getvalue (o / r) (cond ((and (vlax-method-applicable-p o 'getblockattributevalue) (= 1 (vla-get-contenttype o))) (vlax-for x (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-contentblockname o) ) (if (= "AcDbAttributeDefinition" (vla-get-objectname x)) (setq r (vla-getblockattributevalue o (vla-get-objectid x))) ) ) r ) ((vlax-property-available-p o 'textstring) (vla-get-textstring o)) ((vlax-property-available-p o 'textoverride) (vla-get-textoverride o)) ) ) (cond ((and (setq f (getstring t "\nEnter string to search for: ")) (setq s (ssget '((0 . "MULTILEADER,*TEXT,DIMENSION")))) ) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) ;; Not case sensitive exact match (or (= (strcase f) (strcase (_getvalue (vlax-ename->vla-object e)))) (ssdel e s)) ;; Not case sensitive partial match ;;; (or (wcmatch (strcase (_getvalue (vlax-ename->vla-object e))) (strcase (strcat "*" f "*"))) ;;; (ssdel e s) ;;; ) ) (sssetfirst nil s) ) ) (princ) )
    1 point
  2. You cannot directly filter with code 1 for multileaders, dimensions and long mtext strings.
    1 point
  3. @mhupp Thanks - works perfectly! 1. first,I cannot overstate the importance of the code clarifications at the end of each line - thanks for that! 2. Since I can't guarantee that only straight lines will be involved, I decided to stick with the original function (SELECTINSIDE) rather than the simpler one you used in second example. 3. the missing link (sort of speaking...) for me was this line: (while (> (getvar 'cmdactive) 0) (command pause)) ;pauses lisp until your done drawing the perimeter 4. And this line is also of great importance: (if (and (setq poly (entlast)) (eq (cdr (assoc 0 (entget poly))) "LWPOLYLINE")) ;checks to see if entlast is also a polyline. 5. here is the final lisp I'm going to use: (defun C:PJ (/ poly coord ss) (prompt "Draw polyline: ") ;letting you/others to know what to do. (vl-cmdf "_.pline") ;starts command (while (> (getvar 'cmdactive) 0) (command pause)) ;pauses lisp until your done drawing the perimeter (if (and (setq poly (entlast)) (eq (cdr (assoc 0 (entget poly))) "LWPOLYLINE")) ;checks to see if entlast is also a polyline. ;(if (setq poly (car (entsel "\nSelect Outside Polyline To Join Inside Object's "))) (progn (SELECTINSIDE poly) (vl-cmdf "_.Join" SS2 "") ) ) (entdel poly) (princ) ) (defun SELECTINSIDE (ent / poly obj seg lst len) (setq poly (vlax-invoke (vlax-ename->vla-object ent) 'explode)) ;this creates an exploded copy of the polyline (foreach obj poly ;steps though each segment of the exploded polyline to create the points list (cond ((eq (vla-get-Objectname obj) "AcDbArc") (setq seg (/ (vla-get-arclength obj) 5)) (setq lst (cons (vlax-curve-getPointAtDist obj 0) lst)) (setq len seg) (repeat 4 (setq lst (cons (vlax-curve-getPointAtDist obj len) lst)) (setq len (+ len seg)) ) (vla-delete obj) ) ((eq (vla-get-Objectname obj) "AcDbLine") (setq lst (cons (vlax-get obj 'StartPoint) lst)) (vla-delete obj) ) ) ) (setq SS1 (ssget "_WP" lst)) (setq SS2 (ssget "_CP" lst)) ) MANY THANKS, aridzv.
    1 point
  4. Your close try this. --edit it doesn't prompt but you can just hit c to close the polyline or if you leave it open it will act like a closed polyline and connect to the first vertices when you feed it to ssget. (defun C:PJ (/ poly coord ss) (prompt "Draw polyline: ") ;letting you/others to know what to do. (vl-cmdf "_.pline") ;starts command (while (> (getvar 'cmdactive) 0) (command pause)) ;pauses lisp until your done drawing the perimeter (if (and (setq poly (entlast)) (eq (cdr (assoc 0 (entget poly))) "LWPOLYLINE")) ;checks to see if entlast is also a polyline. ;(if (setq poly (car (entsel "\nSelect Outside Polyline To Join Inside Object's "))) (progn (setq coord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget poly)))) ;if your just using drawing straight lines this will be faster (setq SS (ssget "_CP" coord)) (vl-cmdf "_.Join" SS "") ) ) (entdel poly) (princ) )
    1 point
  5. if you feed this with an ename of a polyline it will make co-ord a list of all the vertexes. (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent)))) This will work if your polyline is only straight segments. if their are arc things could be omitted from the selection. because the cords only have the start and finish points of an arc. https://www.cadtutor.net/forum/topic/73104-polyline-coordinates/?do=findComment&comment=581425 This should get you what you need. just pull the selectinside function from here. (updated for better points) https://www.theswamp.org/index.php?PHPSESSID=48p02olnkruljfv4l7fupksnk5&topic=57795.msg611267#msg611267 (defun C:PJ (/ ent ss) (setvar 'cmdecho 0) (if (setq poly (car (entsel "\nSelect Outside Polyline To Join Inside Object's "))) (progn (SELECTINSIDE poly) (vl-cmdf "_.Join" SS2 "") ) ) (setvar 'cmdecho 1) (princ) )
    1 point
  6. Suspect there might be a couple of errors in there - was writing it on the laptop watching the TV and didn't have CAD running to check - I'll check and update the code above for you ....edited code above, couple of small errors,
    1 point
  7. Thank you, BIGAL; you are correct your code completes the task. As I search for examples at the beginning, I tend to follow the same logic in the code I find and try to learn from it. I hope with more experience, I won't overthink the solution in the future. And mhupp thank you for the explanation. I am struggling to learn and apply conditional functions. I really appreciate the example. Thank you very much to the admins and members of this forum.
    1 point
×
×
  • Create New...