Author Topic: to get "boundingbox" of the blank space in a hatch  (Read 416 times)

0 Members and 1 Guest are viewing this topic.

DEVITG

  • Bull Frog
  • Posts: 465
to get "boundingbox" of the blank space in a hatch
« on: July 06, 2021, 05:08:59 PM »
Hi all , I need to get the  so called, but I know it is not so, bounding box , of the blank space at a hatch . please see the attached DWG

I need the   "like" 'dl  'ur  . For the blank space

 

I will use it  increased a bit to do a


Code - Auto/Visual Lisp: [Select]
  1. (ssget  "c"  -dl +ur  '( (0 . "HATCH")))


-dl is a point a bit downward   dl

and +ur is a point a bit upward  ur

Guess a 10 % more than distance dl ur

In fact I need to select the Hatch, from the text .

As this hatch have no a stated  boundary










Location @ Córdoba Argentina Using ACAD 2019  at Window 10

ronjonp

  • Needs a day job
  • Posts: 7327
Re: to get "boundingbox" of the blank space in a hatch
« Reply #1 on: July 06, 2021, 05:39:26 PM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ a b c d n s)
  2.   (cond
  3.     ((setq s (ssget '((0 . "*TEXT"))))
  4.      (setq c (ssadd))
  5.      (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
  6.        (vla-getboundingbox (vlax-ename->vla-object e) 'a 'b)
  7.        (mapcar 'set '(a b) (mapcar 'vlax-safearray->list (list a b)))
  8.        ;; Fuzz value = 1/2 text height
  9.        (setq n (/ (cdr (assoc 40 (entget e))) 2))
  10.        (if (setq d (ssget "_C" (mapcar '- a (list n n)) (mapcar '+ b (list n n)) '((0 . "HATCH"))))
  11.          (ssadd (ssname d 0) c)
  12.        )
  13.        (grdraw (mapcar '- a (list n n)) (mapcar '+ b (list n n)) 3)
  14.      )
  15.      (sssetfirst nil c)
  16.     )
  17.   )
  18.   (princ)
  19. )

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

DEVITG

  • Bull Frog
  • Posts: 465
Re: to get "boundingbox" of the blank space in a hatch
« Reply #2 on: July 06, 2021, 05:53:16 PM »
Hi ronjonp, it is the same  way I did before asking for the way to get the blank not so boundingbox.

I just ask as to know if it is possible to get such value .

Thanks for your help




Location @ Córdoba Argentina Using ACAD 2019  at Window 10

ronjonp

  • Needs a day job
  • Posts: 7327
Re: to get "boundingbox" of the blank space in a hatch
« Reply #3 on: July 06, 2021, 05:55:41 PM »
Hi ronjonp, it is the same  way I did before asking for the way to get the blank not so boundingbox.

I just ask as to know if it is possible to get such value .

Thanks for your help
Sorry .. your problem got lost in translation ;\

"In fact I need to select the Hatch, from the text " to me means that the text is selected then used to grab the hatch.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

DEVITG

  • Bull Frog
  • Posts: 465
Re: to get "boundingbox" of the blank space in a hatch
« Reply #4 on: July 06, 2021, 09:56:26 PM »
Hi you quote

Quote
to me means that the text is selected then used to grab the hatch.

Yes it is , so .

I will try to

Code: [Select]
HATCHGENERATEBOUNDARY
,
then I can get the  boundary poly .

Thanks for your help

Location @ Córdoba Argentina Using ACAD 2019  at Window 10

BIGAL

  • Swamp Rat
  • Posts: 830
  • 30 + years of using Autocad
Re: to get "boundingbox" of the blank space in a hatch
« Reply #5 on: July 07, 2021, 12:58:14 AM »
Similar problem http://www.theswamp.org/index.php?topic=56861.0 there must be a way of getting hatch based on text. maybe bpoly then ssget wp Hatch
A man who never made a mistake never made anything

DEVITG

  • Bull Frog
  • Posts: 465
Re: to get "boundingbox" of the blank space in a hatch
« Reply #6 on: July 07, 2021, 07:32:33 AM »
Hi Bigal. I will try bpoly .
Thanks
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

BIGAL

  • Swamp Rat
  • Posts: 830
  • 30 + years of using Autocad
Re: to get "boundingbox" of the blank space in a hatch
« Reply #7 on: July 07, 2021, 09:08:26 PM »
I think Ronjonp code is working the issue is a couple of problems, the select "C" must touch something so a hatch pattern may not touch the line a-b, angle etc  the second thing I have found in other post is "draw order", the text must be on top.
A man who never made a mistake never made anything

DEVITG

  • Bull Frog
  • Posts: 465
Re: to get "boundingbox" of the blank space in a hatch
« Reply #8 on: July 08, 2021, 02:07:47 PM »
Hi bigal, I solved by "c" from 2 point UP an DW from the text insertion point , in this case UP to 0.60 the text heigth , and  DW to 1.6 text heigth , of course it is suited to dwg provided.
I did not  take in count about HATCH pattern , lucky  in this case is SOLID.
Neither About DRAWORDER .
One fact that make me  nut , is that the SSGET need points to bee seen at the display screen. After it,  I got.
Thanks for your tips.
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

BIGAL

  • Swamp Rat
  • Posts: 830
  • 30 + years of using Autocad
Re: to get "boundingbox" of the blank space in a hatch
« Reply #9 on: July 10, 2021, 08:35:46 PM »
Will try the bigger box on other post it was converting about 90%, there are other bugs in dwg making life hard.
A man who never made a mistake never made anything