place text in a position that does not overlap other objects

place text in a position that does not overlap other objects

xuantientutungXUK6E
Advocate Advocate
989 Views
3 Replies
Message 1 of 4

place text in a position that does not overlap other objects

xuantientutungXUK6E
Advocate
Advocate

hello everone,

i try to find a way to put partmark at a place which does not overlap other objects.

Is there a way to know if one object doesn't override another?

 

forum.PNG

0 Likes
990 Views
3 Replies
Replies (3)
Message 2 of 4

Sea-Haven
Mentor
Mentor

Possibly bounding box will give overlapping.

 

A crude rectang on an angle matching text and using ssget if not nil then has hit something. hint (strlen str)

 

The issue though is what is the rule to fix the problem ?

 

Better still dont do in 1st place.

 

0 Likes
Message 3 of 4

cadffm
Consultant
Consultant

I guess there is no way to "find a free area", so you have to check if the place you try is good or not.

Check out how the TSPACEINVADERS command works (Expresstools, TSCALE.lsp).

Sebastian

0 Likes
Message 4 of 4

john.uhden
Mentor
Mentor

Yes, boundingbox will reveal overwrites (not overrides), but as we have discussed before the boundingbox is just a rectangle, not all of which may be consumed by the mtext contents.  Actually, you can use the intersectwith method with text objects as well, but it uses the same boundingbox approach to find the intersections.

Okay, so you can find all the intersections, but then what?  It would be a lengthy trial and error process to programmatically (sp?) find a place to move them.  That is where the human eye has an advantage.  Ya just have to budget for clean-up time.

My most recent boss insisted on zero overwrites, and disdained the use of background masking.  So I wrote this little diddy to at least save some time:

(defun C:R+M ( / *error* vars vals e obj objname ip rot)
   ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
   ;*                                                                           *
   ;*         R+M.LSP    by     John F. Uhden                                   *
   ;*                           2 Village Road                                  *
   ;*                           Sea Girt, NJ  08750                             *
   ;*                                                                           *
   ;* * * * * * * * * * * *  Do not delete this heading!  * * * * * * * * * * * *

   ; Program combines rotating and moving text/mtext objects just to save time
   ; adjusting their position for neatness and legibility.

   ; v1.0 (01-17-2020) made for Challoner

   (gc)
   (prompt "\nR+M v1.0 (c)2020, John F. Uhden")
   (defun *error* (error)
      (sssetfirst)
      (mapcar 'setvar vars vals)
      (vla-endundomark *doc*)
      (cond
        (not error)
        ((wcmatch (strcase error) "*CANCEL*,*QUIT*")
          (vl-exit-with-error "\r                                              ")
        )
        (1 (vl-exit-with-error (strcat "\r*ERROR*: " error)))
      )
      (princ)
   )
   ;;------------------------------------------
   ;; Intitialze drawing and program variables:
   ;;
   (setq *acad* (vlax-get-acad-object))
   (setq *doc* (vlax-get *acad* 'ActiveDocument))
   (vla-endundomark *doc*)
   (vla-startundomark *doc*)
   (setq vars '("cmdecho" "highlight"))
   (setq vals (mapcar 'getvar vars))
   (mapcar 'setvar vars '(0 1))
   (command "_.expert" (getvar "expert")) ;; dummy command

   (while (setq e (car (entsel "\nSelect text object to rotate/move: ")))
     (setq obj (vlax-ename->vla-object e)
           objname (vlax-get obj 'ObjectName)
     )
     (and
       (or
         (wcmatch (strcase objname) "*TEXT")
         (prompt "\nObject selected is not text.")
       )
       (setq ip (vlax-get obj 'InsertionPoint))
       (setq rot (vlax-get obj 'Rotation))
       (princ "\nNew rotation: ")
       (vl-cmdf "_.rotate" e "" "_non" ip "_R" (angtos rot 0 4))
       (while (> (getvar "cmdactive") 0)(vl-cmdf pause) 1)
       (princ "\nNew position: ")
       (vl-cmdf "_.move" e "" "_non" ip)
       (while (> (getvar "cmdactive") 0)(vl-cmdf pause) 1)
     )
   )
   (*error* nil)
)
(defun c:RM ()(c:R+M))

John F. Uhden

0 Likes