broncos15 Posted April 19, 2016 Posted April 19, 2016 So I am trying to create a lisp routine that would find all the text conflicts in a drawing. The routine would find if objects had partially overlapping text boxes, leaders, etc. I think the best way to do this would be to use the intersectwith method, but my issue is I can't think of a very efficient way to code it. I know one way I could accomplish this is to iterate through every single text object (mtext, mleaders, dimensions, etc) and run the intersect with method on each obect (ie obj1 intersect with obj2, obj1 intersect with obj3, etc) but this seems like a really inefficient way to code. (setq intPoints (vla-IntersectWith Objcnt objcnt2 acExtendNone)) Can anyone think of a more efficient way to accomplish this? Quote
rkmcswain Posted April 19, 2016 Posted April 19, 2016 No lisp needed if the command TSPACEINVADERS works for you. Quote
broncos15 Posted April 19, 2016 Author Posted April 19, 2016 Thanks for showing me that command, I never knew about it and it's pretty awesome! Is there anyway to have it select dimensions and mleaders because it seems like it only select mtext or text? Quote
broncos15 Posted April 19, 2016 Author Posted April 19, 2016 So this is my first go at the code but I can't get it to work properly and I keep getting an error with it that is telling me that my selection set is empty, but I don't know why it would be. I made it by basically doing 2 repeat functions that check each object against every other object. (defun c:textconflicts (/ ss ss1 conflictcnt *error*) (defun *error* (msg) (if (not (member msg '("Function cancelled" "quit / exit abort")) ) (princ (strcat "\nError: " msg)) ) (princ) ) (if (setq ss (ssget "_A" '((0 . "MTEXT, MULTILEADER,*DIMENSION")))) (progn (repeat:textconflicts) (if ss1 (layercreator:textconflicts) ) ) ) (princ) ) ;;;I am creating my repeat function right here (defun repeat:textconflicts (/ cnt1 len cnt2) (setq cnt1 0 len (sslength ss) cnt2 0 conflictcnt 0 ) (repeat len (setq ent1 (vlax-ename->vla-object (setq sname1 (ssname ss1 cnt1)))) (repeat (- len 1) (if (> (- len cnt1) 0) (setq ent2 (vlax-ename->vla-object (setq sname2 (ssname ss2 (- len cnt2))))) (setq ent2 (vlax-ename->vla-object (setq sname2 (ssname ss2 (- len (- cnt2 1)))))) ) (setq cnt2 (+ cnt2 1)) (if (safearray-value (variant-value (vla-intersectwith ent1 ent2 acExtendNone))) (progn (setq conflictcnt (+ conflictcnt 1)) (setq ss1 (ssadd sname1)) (setq ss1 (ssadd sname2)) ) ) ) (setq cnt1 (+ cnt 1)) ) ) ;;;I am creating a subfunction to create layers and place objects on them (defun layer:textconflicts () (if (not (TBLSEARCH "LAYER" "C-ANNO-TEXT-CNFL")) (command "._layer" "_M" "C-ANNO-TEXT-CNFL" "C" "1" "" "L" "CONTINUOUS" "" "LW" "0.25" "" "PS" "NORMAL" "" "D" "Annotation:Text Conflict" "" "y" "" ) ) (command "._chprop" ss1 "" "LA" "C-ANNO-TEXT-CNFL" "") (alert (strcat "\n" (itoa conflictcnt) " " "text objects had conflicts and where placed on the C-ANNO-TEXT-CNFL layer" ) ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.