Author Topic: Boundary with gaps  (Read 3149 times)

0 Members and 1 Guest are viewing this topic.

hmspe

  • Bull Frog
  • Posts: 362
Boundary with gaps
« on: June 08, 2006, 12:57:38 PM »
I have a routine I use for centering an arbitrary number of lines of text within a defined area.  I use it mostly to clean up equipment schedules.   The routine takes the insertion point of a selected text entity, uses the BOUNDARY command to create a bounding box of the geometry surrounding the text, gets all text entities inside or crossing the boundary, then does the centering.  The problem comes when the geometry doesn't produce a closed area.  The gaps tend to be small -- usually an interior line in the schedule doesn't quite touch one of the outside lines (at 'T' intersections).  It's the same problem as having a hatch leak through a small gap.  We run 2004 by choice.  I've tried the "new and improved" boundary function in 2007, but it doesn't do any better at the "unclosed T" intersections than the function in 2004.i

So, I'm looking for ideas on how to reliably create a closed boundary based on a point picked within the boundary.  Having to manually select the entities that comprise the boundary isn't viable -- the intent of the routine is to be able to align an entire schedule by selecting the text with a crossing window, and it would be faster to redraw the table than to select the bounds for each cell.

For locating gaps I've looked at gap.lsp from McNeel, modified by J. Tippit, but it doesn't check for 'T' intersections, which is where the problem tends to be.  I've considered GBPOLY and similar programs, but they seem to be far more than is needed here, plus I'd have to buy a copy for each workstation here and the ROI for that doesn't work for us (we do building electrical and don't do boundaries much except in this routine).  In either case there's the issue of determining what entities comprise the boundary.

Any thoughts or suggestions would be appreciated.

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

Dinosaur

  • Guest
Re: Boundary with gaps
« Reply #1 on: June 08, 2006, 01:32:26 PM »
Luis has a great routine named GBPOLY that should do what you need.

LE

  • Guest
Re: Boundary with gaps
« Reply #2 on: June 08, 2006, 04:57:02 PM »
If you can upload here a simple drawing or an image showing of what you are after, and I will try to have a look if possible.

Luis.

hmspe

  • Bull Frog
  • Posts: 362
Re: Boundary with gaps
« Reply #3 on: June 08, 2006, 06:08:53 PM »
Luis,

Thanks for your reply.  I had been hesitant to post because I knew you had a commercial product.

I have attached a partial schedule that I received.  The line between the headings 'MCA' and 'MOCA' doesn't quite touch the horizontal line at the top of the table.  In R2004 the BOUNDARY and HATCH commands select both of these cells rather than just the cell I click in.  Here's a clip out of the function that shows how I'm acquiring the text to re-center.  I can attach the entire function if necessary, but it's over 350 lines.  lstPtIn is the insertion point of the TEXT or MTEXT entity that was selected.

Code: [Select]
    (command "_.boundary" "a" "o" "p" "" lstPtIn "")
; set the boundary around the point
    (setq entity_boundary (entlast)) ; retreive the boundary
    (setq entity3 (entget (entlast))) ; get the polyline
    (setq vertices (list)) ; create an empty list to store the vertices in.
    (foreach temp entity3 ; step through each sub-list
      (if (= 10 (car temp)) ; if the first item in the sub-list equals 10 then ...
(setq vertices ; reset vertices to the old list plus the new point
       (append vertices
       (list
(cdr temp)
       )
       )
)
      )
    )
    (setq ssbnd (ssget "CP" vertices '((0 . "MTEXT"))))
; get any mtext within the boundary - this is in case
; the selection was a single pick and was a text entity
; in a cell that also contains mtext
    (if (/= ssbnd nil)
      (progn
(setq index4 0) ; initialize the counter
(while (< index4 (sslength ssbnd))
; loop through the selection set
  (setq entity4 (entget (ssname ssbnd index4)))
; get the entity
  (if (= "MTEXT" (dxf 0 entity4)) ; if the entity is MTEXT...
    (command "_.explode" (ssname ssbnd index4))
; explode the mtext to text
  )
  (setq index4 (1+ index4)) ; increment the counter
)
      )
    )
    (setq ssbnd nil)
    (setq ssbnd (ssget "CP" vertices '((0 . "TEXT"))))
;    (command "_.justifytext" ssbnd "" "MC")      ; fix justification
    (c:ee-tjust ssbnd "MC")
    (setq index4 0)
    (while (< index4 (sslength ssbnd))
      (setq entity4 (entget (ssname ssbnd index4)))
      (setq cpoint (dxf 11 entity4))
      (if (/= (PointInPolylineP
cpoint
(GetPolylinePoints entity_boundary)
0.00001
      )
      1
  )
(ssdel (ssname ssbnd index4) ssbnd)
; delete the entity if the insertion point is not inside
;   the boundary. No counter increment so next entity is
;   not skipped.
(setq index4 (1+ index4)) ; otherwise increment the counter. 
      )
    )
"Science is the belief in the ignorance of experts." - Richard Feynman

LE

  • Guest
Re: Boundary with gaps
« Reply #4 on: June 08, 2006, 06:57:48 PM »
Hi Martin,

I ran several tests using your drawing, tried with bpoly,boundary,bhatch,hpgaptol sysvar and no luck.

Using AutoCAD 2005.

I used GBPoly and it creates ALL the closed polylines automatically in a single shot.

There is another product that does the same as my software, also map clean tools and maybe in the C3D something new to close those gaps.

It must be a way to do it in lisp, but have no time to play right now.

Remember, the boundary command sometimes works sometimes don't... there still the issues of not being close to the 0,0 base, and many other little things.

You might try to break at all intersections, then to use the region command and convert that back to lines.... a lot of tricks or workarounds.

HTH