Looking for AutoLISP code to place a cloud around MTEXT by a specified distance/AutoCADLT

Looking for AutoLISP code to place a cloud around MTEXT by a specified distance/AutoCADLT

chadrach4
Explorer Explorer
883 Views
8 Replies
Message 1 of 9

Looking for AutoLISP code to place a cloud around MTEXT by a specified distance/AutoCADLT

chadrach4
Explorer
Explorer

I'd like to speed up my work flow by being able to place a cloud around MTEXT offset by 3/32" by just selecting the MTEXT.

 

Right now I draw a rectangle around MTEXT using its grip locations, then offset that rectangle by 3/32", delete the original rectangle, convert the new rectangle to a cloud, and then change the cloud to a specified layer.

Here's a video:

It would be extremely helpful if I could automate this somehow. Any guidance would be extremely appreciated.

 

@chadrach4 - the moderation team has edited the title for better clarity.

0 Likes
884 Views
8 Replies
Replies (8)
Message 2 of 9

paullimapa
Mentor
Mentor

Looks like this thread would get you half way there. All that’s left is modifying the box to cloud and place onto your specific layer


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 9

Kent1Cooper
Consultant
Consultant

Since @paullimapa 's link is to a routine of mine, it seems easily adjustable, but with a question:  Would you always want to use it for only single Mtext objects?  That routine allows multiples, and boxes them collectively in one box, but that means you need to give it an extra Enter/space to tell it you're done selecting.  If you never do it with multiples, it could be made to save you the step of completing the selection, and proceed with just the one you pick.

 

EDIT:  Here's the modification for multiple-object selection [lightly tested].  Single-only would be a further modification, but not difficult.

Kent Cooper, AIA
Message 4 of 9

chadrach4
Explorer
Explorer

Thanks for the link @paullimapa, and thanks for the code @Kent1Cooper!

 

I would only use it on a single Mtext object, never multiples.

 

I've been studying the code and figured I could trim it down a little since my offset will always be the same and I will only use it on a single MText ojbect. Attached is what I have so far, and it's working, woohoo!

 

Thanks again for both of y'all pointing me in the right direction!

0 Likes
Message 5 of 9

komondormrex
Mentor
Mentor

if you are not on lt and have et, check this one

(defun c:revcloud_mtext (/ mtext bounding_box rectangle)
  (setq mtext (car (entsel "\nPick Mtext to revcloud by 3/32\": "))
  	bounding_box (acet-geom-mtxtbox (entget mtext) (/ 2.38125 (vla-get-height (vlax-ename->vla-object mtext))))
	rectangle (vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
		  			      (vlax-safearray-fill
						(vlax-make-safearray vlax-vbdouble '(0 . 7))
						(apply 'append (mapcar '(lambda (point) (mapcar '+ point '(0 0))) bounding_box))
					      )
		  )
  )
  (vla-put-closed rectangle :vlax-true)
  (setvar 'revcloudapproxarclen (vla-get-height (vlax-ename->vla-object mtext)))
  (setvar 'revcloudarcvariance 0) 
  (command "_revcloud" "_o" (vlax-vla-object->ename rectangle) "")
)

 

0 Likes
Message 6 of 9

paullimapa
Mentor
Mentor

Glad to have helped…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 9

chadrach4
Explorer
Explorer

Thank you @komondormrex, but I use LT; I should have noted that in my original post.

 

For anyone looking for something similar, attached is my version (piggybacked @Kent1Cooper's code from above) that does everything I noted previously.

0 Likes
Message 8 of 9

Kent1Cooper
Consultant
Consultant

If you're doing one object only, you can dump the part of the routine that's about finding the extremes of the collective bounding box of multiple objects.  You can replace this much:

      (setq
        eLL (vlax-safearray->list minpt)
        eUR (vlax-safearray->list maxpt)
        LL (if LL (mapcar 'min eLL LL) eLL)
        UR (if UR (mapcar 'max eUR UR) eUR)
      ); setq

with just this:

      (setq
        LL (vlax-safearray->list minpt)
        UR (vlax-safearray->list maxpt)
      ); setq

The longer version compares the extents of each individual entity [that's the e in eLL & eUR] to what's already been looked at [the un-prefixed LL & UR], but that's not needed with only one object.

Kent Cooper, AIA
0 Likes
Message 9 of 9

chadrach4
Explorer
Explorer

Thank you. I figured there was some more of the code that could be trimmed down.

 

I've slowly started to learn more about AutoLISP since LT just introduced it last year. I'm hoping to streamline a lot of stuff, just have to learn how to do it.

0 Likes