Challenge 23-01 BoundingPoly

Challenge 23-01 BoundingPoly

john.uhden
Mentor Mentor
1,294 Views
19 Replies
Message 1 of 20

Challenge 23-01 BoundingPoly

john.uhden
Mentor
Mentor

I've mentioned the desire for this before, but does anyone have the guts to build a function that returns a polyline (or coordinates thereof) to tightly surround a block reference (yes, with attributes) or an MText or MLeader?

I thought not, but still think that Autodesk should provide it.  A rectangular boundingbox just ain't enough.

John F. Uhden

0 Likes
1,295 Views
19 Replies
Replies (19)
Message 2 of 20

Sea-Haven
Mentor
Mentor

There is a commercial product out there that may do it, For Civ3D it starts as Shrinkwrap. What is its name again. Has a Train as one shape and a car engine as another.

 

Something like this ? Add Gaps and no idea.

SeaHaven_0-1688458061541.png

 

Found it TotalBoundary • AutoCAD App for creating outlines of complex drawings

 

 

 

Message 3 of 20

komondormrex
Mentor
Mentor

komondormrex_0-1688464522397.png

no whatsoever texts

0 Likes
Message 4 of 20

john.uhden
Mentor
Mentor

@Sea-Haven ,

Oh, yeah!  I've seen it and even used it once at my new job.  I'll have to test it out some more.

John F. Uhden

0 Likes
Message 5 of 20

john.uhden
Mentor
Mentor

@komondormrex ,

No texts?  But Alan showed a poly going around "aaa."

Alan, did you cheat?

John F. Uhden

0 Likes
Message 6 of 20

Sea-Haven
Mentor
Mentor

Yep

 

If it is say text and objects all touching a bpoly approach will work, problem is when there is a gap between objects, so the text has a bounding box frame before running the bpoly.

 

An example may be worth looking at.

 

This is a problem say as a block or even text and lines due to gaps need a algorithm to work out a sequence of outer points. Maybe a clock approach. 

 

SeaHaven_0-1688519944012.png

Some form of checking next angle and distance a double If AND compare to say next. See red lines.

SeaHaven_0-1688521332629.png

 

 

 

 

 

 

0 Likes
Message 7 of 20

calderg1000
Mentor
Mentor

Regards @Sea-Haven 

That is the C3D command...

calderg1000_0-1688520173011.png

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 8 of 20

komondormrex
Mentor
Mentor

@john.uhden 

why 23-01? is it first challenge this year? were there others anywhen?

0 Likes
Message 9 of 20

john.uhden
Mentor
Mentor

@komondormrex ,

I have no knowledge of any other challenges in this calendar year.  Then again, it could be that my losses of knowledge exceed my gains.

There hopefully being more than one this year, I numbered it -01.

John F. Uhden

0 Likes
Message 10 of 20

john.uhden
Mentor
Mentor

@Sea-Haven ,

Would that be CW or CCW?

How about using the direction of the vortex when we flush? 😁

That would reduce the confusion, right?

John F. Uhden

0 Likes
Message 11 of 20

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

.... to tightly surround a block reference (yes, with attributes) or an MText or MLeader? ....


Can you illustrate what you would mean by tightly surrounding a MultiLeader?  Say it's like this, perhaps:

Kent1Cooper_0-1688584680677.png

And do I assume correctly that for Mtext of the same without the leaders, you would want something like this, if the simple bounding box does not satisfy?

Kent1Cooper_1-1688584866940.png

But then, it could be more convoluted -- say, like this, maybe?

Kent1Cooper_2-1688584942218.png

 

Kent Cooper, AIA
0 Likes
Message 12 of 20

john.uhden
Mentor
Mentor

Hi, @Kent1Cooper ,

The 4-sided boundingbox is severely underwhelming.

I favor the "more convoluted" example, and, no, we don't need to surround any leaders.

John F. Uhden

0 Likes
Message 13 of 20

Sea-Haven
Mentor
Mentor

For text can use a fuzz factor on the Strlen and text height to draw a box around the text. Mtext a bit more complicated with multiple boxes.

 

I think you need to post a dwg with true examples.  Cheat on the boundary for the before and after.

0 Likes
Message 14 of 20

john.uhden
Mentor
Mentor

@Sea-Haven ,

First, I must point out that I am not looking for one of us to come up with a function, but rather that Autodesk provide us a function and which can be applied in background masking, for example:

johnuhden_0-1688947233546.png

 

 

John F. Uhden

Message 15 of 20

Sea-Haven
Mentor
Mentor

Ok may be able to do something for Text or Mtext. If you read each line and make a box around each line, then draw a dummy pline outside the mtext, then a boply will create what you want. Erase all the dummy stuff. A mtext mask exposes the 4 corners when exploded. 

 

Ok found it so if remake the mtext into individual mtext with a frame then explode.

SeaHaven_0-1688949662167.png

Ok John your turn, the method worked need a few Undo's and erases etc 😀

 

SeaHaven_1-1688949918031.png

Will find the set to 0 for Paper defined width.

 

This may be a more useful way to make the boxes.

SeaHaven_2-1688950232212.png

 

Have to go away now have a coffee and a think.

0 Likes
Message 16 of 20

Sea-Haven
Mentor
Mentor

Proof of concept, try it John, bit buggy realised no need to copy, next go. The box or line spacing is not quite right perhaps a wrong dxf code value. Hacked another bit of code as my Bricscad does not have txt2mtxt.

 

SeaHaven_0-1688956959658.png

(defun c:Mtextbdy (/ ent ss ents)
(defun c:plpts ( / pt)
(setq pt (getpoint "\nStarting point of Pline : "))
(command "_pline" pt)
(while (= (getvar "cmdactive") 1 )
(command (getpoint (getvar 'lastpoint)))
)
)


(setvar "cmdecho" 0)
(setq ent (entsel "\nPick Mtext "))
(setq pt1  (cdr (assoc 10 (entget (car ent)))))
(setq pt2 (getpoint pt1 "\nPick point away from mtext "))
(command "copy" ent "" pt1 pt2)
(command "explode" (entlast))
(setq ss (ssget (list (cons 0 "TEXT"))))
(Repeat (setq x (sslength ss))
(setq ents  (ssname ss (setq x (- x 1))))
(setq ent (entget ents))
(entmake (list 
(cons 0 "MTEXT")
(cons 100 "AcDbEntity") 
(cons 100 "AcDbMText")
(cons 8 (cdr (assoc 8 ent)))
(cons 42 1) 
(cons 43 0) 
(cons 44 1) 
(cons 7 (cdr (assoc 7 ent)))
(cons 73 (cdr (assoc 73 ent)))
(cons 1 (cdr (assoc 1 ent)))
(cons 11 (cdr (assoc 11 ent)))
(cons 10 (cdr (assoc 10 ent)))
(cons 210 (cdr (assoc 210 ent)))
(cons 40 (cdr (assoc 40 ent)))
(cons 50 (cdr (assoc 50 ent)))
(cons 71 (cdr (assoc 71 ent)))
(cons 72 0)
)
)
(entmod (append (entget (entlast)) '((90 . 16) (63 . 256) (45 . 1.5) (441 . 0))))
(command "explode" (entlast))
(command "erase" ents "")
)
(c:plpts)
(setq bp (entlast))
(command "bpoly" (getpoint "\nPick a point inside pline ") "")
(setq bp2 (entlast))
(command "erase" bp "")
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget bp2))))
(command "move" bp2 "" (nth 0 co-ord) pt1)
(princ)
)
(c:Mtextbdy)

 

 

0 Likes
Message 17 of 20

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

... I am not looking for one of us to come up with a function, but rather that Autodesk provide us a function and which can be applied in background masking, for example:


[Then the topic heading and the first sentence in Message 1 should have been different.  You should go to the >Product Feedback page<.  This Forum is for Users, with minimal oversight by Autodesk employees, and those not the ones whose attention you need to get.]

Kent Cooper, AIA
0 Likes
Message 18 of 20

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

... realised no need to copy....

....
(command "copy" ent "" pt1 pt2)
(command "explode" (entlast))
(setq ss (ssget (list (cons 0 "TEXT"))))
....

But if someone should attempt a routine, big questions for @john.uhden :

 

What about justification in Mtext?  If you don't Copy it, and do the work with the Exploded original, then though you may convert back to Mtext later, you need to go into SEttings to not word-wrap, so justification won't always be Top-Left [although in quick trial sometimes it seems to revert to that, anyway], and so line breaks won't end up in different places [if line lengths are unequal enough caused by internal hard returns].  And it seems Line Space Style always ends up as "At least," which could shift things a little if the original was "Exactly."  So I think the better approach would be to Copy it to leave the original and preserve other justification and line breaks, and work with the Exploded copy.

 

Then there's the question of internal formatting.  Exploding seems to leave some of that, breaking up the original into separate Text pieces at each change.  Color and size and width factor seem to be preserved, but font changes can affect more than in the original, and tracking or obliquing are not preserved [obliquing survives EXPLODEing, but not TXT2MTXT-ing back], which can lead to incorrect results.  [Not that I have any idea how to account for those....]

 

If Exploding is to be part of the process [whether of the original or a copy], the pieces resulting from that become the Previous selection, so there's no need to have User selection involved in (ssget)-ing them:

 

....
(command "explode" {whether the original or the copy})
(setq ss (ssget "P"))
....

 

Kent Cooper, AIA
0 Likes
Message 19 of 20

john.uhden
Mentor
Mentor
I don't wanna make the boxes. I want Autodesk to make the function and
include it in masking!

John F. Uhden

0 Likes
Message 20 of 20

Sea-Haven
Mentor
Mentor

Good luck, suggestion Number 1,234,567. File it in the round cabinet on the floor with the others. 😂

 

Someone like Bricscad may do it, but then its a proxy object in Acad ?

0 Likes