Author Topic: Check if a region is complex  (Read 2588 times)

0 Members and 1 Guest are viewing this topic.

matko

  • Mosquito
  • Posts: 5
Check if a region is complex
« on: June 19, 2020, 12:11:38 PM »
Hello, is there a way to check if a region is complex? I know one way would be to explode it and check if any of the exploded objects is also a region, but in my case that would make for a very messy code. I could use help with a routine which would return: a) a list with one member - entity name of the non-complex region with the region unexploded; or b) a list of all the (entity names of) subregions with the original complex region exploded.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Check if a region is complex
« Reply #1 on: June 19, 2020, 12:19:56 PM »
This topic is somewhat related to problem of complex regions... See if it can help you in some way...

http://www.theswamp.org/index.php?topic=54251.0

HTH., M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

matko

  • Mosquito
  • Posts: 5
Re: Check if a region is complex
« Reply #2 on: June 19, 2020, 12:32:35 PM »
I actually found that topic when searching for 'complex region', but i couldn't tell if any part of the code deals with my issue (performing a check if exploding a region results in simpler regions or other types of objects). Does it?
I hvala!

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Check if a region is complex
« Reply #3 on: June 19, 2020, 04:26:53 PM »
i don't know much about regions
but try calculating #lump-s in decoded acis string

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Check if a region is complex
« Reply #4 on: June 19, 2020, 04:57:53 PM »
Hi,

Maybe you can use gc-brep, a NET defined LISP function to get teh Boundary Representation of regions, 3d solids and surfaces.
Speaking English as a French Frog

matko

  • Mosquito
  • Posts: 5
Re: Check if a region is complex
« Reply #5 on: June 19, 2020, 05:37:54 PM »
Managed to do it. Thanks all!

Code - Auto/Visual Lisp: [Select]
  1. (defun regcheck (reg / listout ssexp br)
  2. (setq listout nil)
  3. (command "_undo" "M")
  4. (command "explode" reg)
  5. (setq ssexp (ssget "P"))
  6. (if (= "REGION" (cdr (assoc 0 (entget (ssname ssexp 0)))))
  7.         (setq br 0)
  8.         (repeat (sslength ssexp)
  9.         (setq listout (append listout (list (ssname ssexp br))))
  10.         (setq br (+ br 1))
  11. )
  12. )
  13.         (setq listout (list reg))
  14.         (command "_undo" "B")
  15. ))
  16. listout
  17. )
  18.  

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Check if a region is complex
« Reply #6 on: June 19, 2020, 06:50:00 PM »
Hello, is there a way to check if a region is complex? I know one way would be to explode it and check if any of the exploded objects is also a region, but in my case that would make for a very messy code. I could use help with a routine which would return: a) a list with one member - entity name of the non-complex region with the region unexploded; or b) a list of all the (entity names of) subregions with the original complex region exploded.

I don't see anything in the ACIS data - including lump defs - that is telling - acknowledging my eyes are weary. See supplemental info at end of post.

That said ...

If you explode an explode-able (let's say "volatile") object via activex the original object is left intact - you have to formally erase it if you want it to mimic the explode command. This is true for blocks, plines, regions ... yada.

So you can explode an object via activex, examine the resulting spawn, make some decision, then delete the spawn (if possible), leaving the original object blissfully unaware it had been abused - i.e. no need to create an undo group.

For the balance of your query - listing objects etc. - you could use the _explode function to suit.

Simplistic example:

Code: [Select]
(defun _explode ( volatile-object / spawn)
    (vl-catch-all-apply 'eval
       '((setq spawn (vlax-invoke volatile-object 'explode)))
    )
    spawn;; return spawn to caller
)

Code: [Select]
(defun _hosts-regions ( some-object / spawn result )
    (setq result
        (vl-some
           '(lambda (x) (eq "AcDbRegion" (vla-get-objectname x)))
            (setq spawn (_explode some-object))
        )
    )
    ;;  The following is error trapped in the event the spawn is
    ;;  spewed to a locked layer. I could deal with it but in the
    ;;  interests of brevity / laziness leaving that for you
    (foreach x spawn (vl-catch-all-apply 'vla-delete (list x)))
    result
)

Supplemental info:

ACIS Data for simple (no hosted regions) and complex (hosted regions):

(   ;;  SIMPLE
    (-1 . <Entity name: 2b0ec688e20>)
    (0 . "REGION")
    (330 . <Entity name: 2b0e0976f00>)
    (5 . "422")
    (100 . "AcDbEntity")
    (67 . 0)
    (410 . "Model")
    (8 . "0")
    (100 . "AcDbModelerGeometry")
    (70 . 1)
    (1 . "22300 27 2 4")
    (1 . "16 Autodesk AutoCAD 20 ASM 224.4.0.65535 NT 0")
    (1 . "1 9.999999999999999547e-07 1.000000000000000036e-10")
    (1 . "asmheader $-1 -1 @13 224.4.0.65535 #")
    (1 . "body $-1 -1 $-1 $2 $-1 $-1 #")
    (1 . "lump $-1 -1 $-1 $-1 $3 $1 #")
    (1 . "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $2 #")
    (1 . "face $-1 -1 $-1 $-1 $5 $3 $-1 $6 reversed double out #")
    (1 . "loop $-1 -1 $-1 $-1 $7 $4 #")
    (1 . "plane-surface $-1 -1 $-1 10745.66529620591973 -2501.9651766274892 0 -0 -0 -1 -1 0 0 forward_v I I I I #")
    (1 . "coedge $-1 -1 $-1 $8 $9 $-1 $10 forward $5 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $11 $7 $-1 $12 forward $5 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $7 $11 $-1 $13 forward $5 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $14 -214.9790382914034126 $15 -0 $7 $16 forward @7 unknown #")
    (1 . "coedge $-1 -1 $-1 $9 $8 $-1 $17 forward $5 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $15 -163.3575723362519057 $18 -0 $8 $19 forward @7 unknown #")
    (1 . "edge $-1 -1 $-1 $20 -163.3575723362519057 $14 0 $9 $21 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $10 0 $22 #")
    (1 . "vertex $-1 -1 $-1 $10 1 $23 #")
    (1 . "straight-curve $-1 -1 $-1 10586.58081319107805 -2364.400899879154167 0 -1 -0 -0 F -214.9790382914034126 F -0 #")
    (1 . "edge $-1 -1 $-1 $18 -214.9790382914034126 $20 0 $11 $24 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $12 1 $25 #")
    (1 . "straight-curve $-1 -1 $-1 10586.58081319107805 -2527.758472215406073 0 -0 -1 -0 F -163.3575723362519057 F -0 #")
    (1 . "vertex $-1 -1 $-1 $17 1 $26 #")
    (1 . "straight-curve $-1 -1 $-1 10801.55985148248146 -2364.400899879154167 0 0 1 0 F -163.3575723362519057 F -0 #")
    (1 . "point $-1 -1 $-1 10801.55985148248146 -2364.400899879154167 0 #")
    (1 . "point $-1 -1 $-1 10586.58081319107805 -2364.400899879154167 0 #")
    (1 . "straight-curve $-1 -1 $-1 10801.55985148248146 -2527.758472215406073 0 1 0 0 F -214.9790382914034126 F -0 #")
    (1 . "point $-1 -1 $-1 10586.58081319107805 -2527.758472215406073 0 #")
    (1 . "point $-1 -1 $-1 10801.55985148248146 -2527.758472215406073 0 #")
    (290 . 1)
    (2 . "{1df30c72-19d7-9747-b2fa-e48f11b7969d}")
)

(   ;;  COMPLEX
    (-1 . <Entity name: 2b0ec688e10>)
    (0 . "REGION")
    (330 . <Entity name: 2b0e0976f00>)
    (5 . "421")
    (100 . "AcDbEntity")
    (67 . 0)
    (410 . "Model")
    (8 . "0")
    (100 . "AcDbModelerGeometry")
    (70 . 1)
    (1 . "22300 48 2 4")
    (1 . "16 Autodesk AutoCAD 20 ASM 224.4.0.65535 NT 0")
    (1 . "1 9.999999999999999547e-07 1.000000000000000036e-10")
    (1 . "asmheader $-1 -1 @13 224.4.0.65535 #")
    (1 . "body $-1 -1 $-1 $2 $-1 $-1 #")
    (1 . "lump $-1 -1 $-1 $-1 $3 $1 #")
    (1 . "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $2 #")
    (1 . "face $-1 -1 $-1 $-1 $5 $3 $-1 $6 reversed double out #")
    (1 . "loop $-1 -1 $-1 $7 $8 $4 #")
    (1 . "plane-surface $-1 -1 $-1 10745.66529620591973 -2501.9651766274892 0 -0 -0 -1 -1 0 0 forward_v I I I I #")
    (1 . "loop $-1 -1 $-1 $-1 $9 $4 #")
    (1 . "coedge $-1 -1 $-1 $10 $11 $-1 $12 reversed $5 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $13 $14 $-1 $15 forward $7 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $16 $8 $-1 $17 reversed $5 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $8 $16 $-1 $18 reversed $5 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $19 0 $20 1281.275071119023778 $8 $21 forward @7 unknown #")
    (1 . "coedge $-1 -1 $-1 $22 $9 $-1 $23 forward $7 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $9 $22 $-1 $24 forward $7 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $25 0 $26 670.7345907624221582 $9 $27 forward @7 unknown #")
    (1 . "coedge $-1 -1 $-1 $11 $10 $-1 $28 reversed $5 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $29 0 $19 1134.905328551012644 $10 $30 forward @7 unknown #")
    (1 . "edge $-1 -1 $-1 $20 0 $31 1134.905328551012644 $11 $32 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $12 0 $33 #")
    (1 . "vertex $-1 -1 $-1 $12 1 $34 #")
    (1 . "straight-curve $-1 -1 $-1 10105.02776064640784 -1934.512512351982878 0 1 0 0 F 0 F 1281.275071119023778 #")
    (1 . "coedge $-1 -1 $-1 $14 $13 $-1 $35 forward $7 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $26 0 $36 507.2682944585903897 $13 $37 forward @7 unknown #")
    (1 . "edge $-1 -1 $-1 $38 0 $25 507.2682944585903897 $14 $39 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $15 0 $40 #")
    (1 . "vertex $-1 -1 $-1 $15 1 $41 #")
    (1 . "straight-curve $-1 -1 $-1 10380.20093352907497 -2192.445548901818256 0 1 0 0 F 0 F 670.7345907624221582 #")
    (1 . "edge $-1 -1 $-1 $31 0 $29 1281.275071119023778 $16 $42 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $17 0 $43 #")
    (1 . "straight-curve $-1 -1 $-1 10105.02776064640784 -3069.417840902995522 0 0 1 0 F 0 F 1134.905328551012644 #")
    (1 . "vertex $-1 -1 $-1 $28 0 $44 #")
    (1 . "straight-curve $-1 -1 $-1 11386.30283176543162 -1934.512512351982878 0 0 -1 0 F 0 F 1134.905328551012644 #")
    (1 . "point $-1 -1 $-1 10105.02776064640784 -1934.512512351982878 0 #")
    (1 . "point $-1 -1 $-1 11386.30283176543162 -1934.512512351982878 0 #")
    (1 . "edge $-1 -1 $-1 $36 0 $38 670.7345907624221582 $22 $45 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $23 1 $46 #")
    (1 . "straight-curve $-1 -1 $-1 11050.93552429149713 -2192.445548901818256 0 0 -1 0 F 0 F 507.2682944585903897 #")
    (1 . "vertex $-1 -1 $-1 $35 1 $47 #")
    (1 . "straight-curve $-1 -1 $-1 10380.20093352907497 -2699.713843360408646 0 0 1 0 F 0 F 507.2682944585903897 #")
    (1 . "point $-1 -1 $-1 10380.20093352907497 -2192.445548901818256 0 #")
    (1 . "point $-1 -1 $-1 11050.93552429149713 -2192.445548901818256 0 #")
    (1 . "straight-curve $-1 -1 $-1 11386.30283176543162 -3069.417840902995522 0 -1 0 0 F 0 F 1281.275071119023778 #")
    (1 . "point $-1 -1 $-1 10105.02776064640784 -3069.417840902995522 0 #")
    (1 . "point $-1 -1 $-1 11386.30283176543162 -3069.417840902995522 0 #")
    (1 . "straight-curve $-1 -1 $-1 11050.93552429149713 -2699.713843360408646 0 -1 0 0 F 0 F 670.7345907624221582 #")
    (1 . "point $-1 -1 $-1 11050.93552429149713 -2699.713843360408646 0 #")
    (1 . "point $-1 -1 $-1 10380.20093352907497 -2699.713843360408646 0 #")
    (290 . 1)
    (2 . "{b819d3d0-6d25-764d-83fd-423e5c7baa67}")
)


Cheers.
« Last Edit: June 19, 2020, 06:59:10 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Check if a region is complex
« Reply #7 on: June 19, 2020, 07:19:41 PM »
Even if I distill the ACIS data nothing distinctive reveals itself to me:

COMPLEX              SIMPLE
"asmheader"         "asmheader"
"body"              "body"
"lump"              "lump"
"shell"             "shell"
"face"              "face"
"loop"              "loop"
"plane-surface"     "plane-surface"
"loop"         
"coedge x 4"        "coedge" x 3
"edge"              "edge"
"coedge x 2"        "coedge"
"edge"              "edge x 2"
"coedge"       
"edge x 2"     
"vertex x 2"        "vertex x 2"
"straight-curve"    "straight-curve"
"coedge"       
"edge x 2"          "edge"
"vertex x 2"        "vertex"
"straight-curve"    "straight-curve"
"edge"         
"vertex"            "vertex"
"straight-curve"    "straight-curve"
"vertex"       
"straight-curve"
"point x 2"         "point x 2"
"edge"         
"vertex"       
"straight-curve"
"vertex"
"straight-curve"
"point x 2"
"straight-curve"
"point x 2"
"straight-curve"    "straight-curve"
"point x 2"         "point x 2"                       


tl;dr: Complex data hosts no defs that are unique to Complex data. There may be a sequence that's relevent but I'm not seein' it.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

matko

  • Mosquito
  • Posts: 5
Re: Check if a region is complex
« Reply #8 on: June 19, 2020, 09:09:13 PM »
MP, thank you, but I think I'm a bit in over my head here. There are hundreds of regions to examine in my drawing, so my code becomes a bit time consuming. If I understood you correctly, your approach would be a 'fake explode' with an option to inspect the 'spawned' entities? I tried implementing it, but the '_explode' function returns nil when selecting a region I'd like to inspect. Could you please add to your code the check if the spawned entities are regions (which would mean the original region is complex) or lines (for a simple original region).

The regions are generated with (vlax-invoke _ 'addregion (list of line entities)) so they are made up of only lines, no curves. I think this method only creates non-complex regions, but I will need a way to filter the complex ones some time soon.
I also have another issue, if anyone can help. The 'addregion method does create what I need, which are regions of every enclosed space between the provided lines. But, it also creates a bigger region which is like an outline of all the smaller regions. Is there a way to avoid that big region? There may be a more than one of them, so deleting only one with the biggest area isn't an option.


MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Check if a region is complex
« Reply #9 on: June 20, 2020, 12:15:17 AM »
There are hundreds of regions to examine in my drawing, so my code becomes a bit time consuming.

(1) If we arrive at a solution I suspect it will be speedy enough, but it will take some work on your part to adequately describe the end game and the initial -- interim -- and final steps -- you're taking to arrive there.

(2) Sample drawings -- original line work -- initial created regions -- and then desired final regions -- will significantly reduce time spent.

If I understood you correctly, your approach would be a 'fake explode' with an option to inspect the 'spawned' entities? I tried implementing it, but the '_explode' function returns nil when selecting a region I'd like to inspect.

(3) Are you passing an entity name or an object to the function? Every legit object I used to test said function yielded objects as expected.

Could you please add to your code the check if the spawned entities are regions (which would mean the original region is complex) or lines (for a simple original region).

(4) That's why the _hosts-regions function was written -- if called like this:

(_hosts-regions a-region-object)

It will return T if the region hosts at least 1 child region, otherwise nil.

The regions are generated with (vlax-invoke _ 'addregion (list of line entities)) so they are made up of only lines, no curves. I think this method only creates non-complex regions, but I will need a way to filter the complex ones some time soon.

(5) If you are creating regions this way I don't believe it will ever generate "complex" regions.

(6) However, if passed 12 lines representing the 2 by 2 configuration in your image -- 5 regions will be created -- 1 for each child square -- and 1 for a periphery region enclosing the others -- "the annoying one". That said, the latter will not be a "complex" region.

(7) If passed 6 lines representing the 2 by 2 configuration in your image -- 1 region will be created -- the periphery region enclosing all. It will not be a "complex" region. Interior regions will not be created.

Note: An alternate strategy may be to leverage the bpoly / boundary command. Need more info.

I also have another issue, if anyone can help. The 'addregion method does create what I need, which are regions of every enclosed space between the provided lines. But, it also creates a bigger region which is like an outline of all the smaller regions. Is there a way to avoid that big region? There may be a more than one of them, so deleting only one with the biggest area isn't an option.

(8) See response (6), adding -- everything is possible -- testing on real data -- see item (2) -- will be the acid test for any candidate code.



I'd like to help but I need a clear map -- items (1) and (2) -- to proceed. Cheers.
« Last Edit: June 20, 2020, 12:35:19 AM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

matko

  • Mosquito
  • Posts: 5
Re: Check if a region is complex
« Reply #10 on: June 20, 2020, 04:22:12 PM »
Are you passing an entity name or an object to the function? Every legit object I used to test said function yielded objects as expected.
The exact mistake I was making, sorry. Your code works perfectly, and much faster than mine, thank you very much for your time!

As for the other issue I'm having, I guess I'm annoyed and think the peripheral region created by the 'addregion method is redundant, as it can be easily attained by 'UNION'ing the smaller regions, but isn't as easy to filter out (in my case the regions are kind of grouped, so I have one peripheral region per group, which means I can't only delete one biggest created region). Still, I think I might be able to get rid of them with cross-comparison of every created region (using 'subtract' to find the encompassing regions). If it proves too challenging, hear you in a few days.
Thanks again!   :wink:

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Check if a region is complex
« Reply #11 on: June 20, 2020, 04:39:32 PM »
I don't see anything in the ACIS data - including lump defs - that is telling - acknowledging my eyes are weary.
create a couple of non-everlaping regions, then _unite them, then dump acis data

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Check if a region is complex
« Reply #12 on: June 21, 2020, 12:30:51 PM »
create a couple of non-overlaping regions, then _unite them, then dump acis data

Using rectilinear regions (to keep data dumps more concise) ...

Pop pop, fiz fiz, lump lump, shell shell, face, face ...

Will have to do a lot of testing (e.g. using non trivial regions as well as overlapping complex regions or those borne of other boolean operations that result in nested regions) to verify a reliable test ...

Single region:
(
    (-1 . <Entity name: 23baabc4900>)
    (0 . "REGION")
    (330 . <Entity name: 23baabc3f00>)
    (5 . "88")
    (100 . "AcDbEntity")
    (67 . 0)
    (410 . "Model")
    (8 . "0")
    (100 . "AcDbModelerGeometry")
    (70 . 1)
    (1 . "22300 27 2 4")
    (1 . "16 Autodesk AutoCAD 20 ASM 224.4.0.65535 NT 0")
    (1 . "1 9.999999999999999547e-07 1.000000000000000036e-10")
    (1 . "asmheader $-1 -1 @13 224.4.0.65535 #")
    (1 . "body $-1 -1 $-1 $2 $-1 $-1 #")
    (1 . "lump $-1 -1 $-1 $-1 $3 $1 #")
    (1 . "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $2 #")
    (1 . "face $-1 -1 $-1 $-1 $5 $3 $-1 $6 reversed double out #")

    (1 . "loop $-1 -1 $-1 $-1 $7 $4 #")
    (1 . "plane-surface $-1 -1 $-1 174.4210358763432112 192.9197620524880676 0 -0 -0 -1 -1 0 0 forward_v I I I I #")
    (1 . "coedge $-1 -1 $-1 $8 $9 $-1 $10 reversed $5 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $11 $7 $-1 $12 reversed $5 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $7 $11 $-1 $13 reversed $5 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $14 0 $15 91.60109087406408435 $7 $16 forward @7 unknown #")
    (1 . "coedge $-1 -1 $-1 $9 $8 $-1 $17 reversed $5 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $18 0 $14 84.90857223520652042 $8 $19 forward @7 unknown #")
    (1 . "edge $-1 -1 $-1 $15 0 $20 84.90857223520652042 $9 $21 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $10 0 $22 #")
    (1 . "vertex $-1 -1 $-1 $10 1 $23 #")
    (1 . "straight-curve $-1 -1 $-1 128.6204904393111974 235.3740481700913278 0 1 0 0 F 0 F 91.60109087406408435 #")
    (1 . "edge $-1 -1 $-1 $20 0 $18 91.60109087406408435 $11 $24 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $12 0 $25 #")
    (1 . "straight-curve $-1 -1 $-1 128.6204904393111974 150.4654759348848074 0 0 1 0 F 0 F 84.90857223520652042 #")
    (1 . "vertex $-1 -1 $-1 $17 0 $26 #")
    (1 . "straight-curve $-1 -1 $-1 220.2215813133752818 235.3740481700913278 0 0 -1 0 F 0 F 84.90857223520652042 #")
    (1 . "point $-1 -1 $-1 128.6204904393111974 235.3740481700913278 0 #")
    (1 . "point $-1 -1 $-1 220.2215813133752818 235.3740481700913278 0 #")
    (1 . "straight-curve $-1 -1 $-1 220.2215813133752818 150.4654759348848074 0 -1 0 0 F 0 F 91.60109087406408435 #")
    (1 . "point $-1 -1 $-1 128.6204904393111974 150.4654759348848074 0 #")
    (1 . "point $-1 -1 $-1 220.2215813133752818 150.4654759348848074 0 #")
    (290 . 1)
    (2 . "{575dcf40-8171-d54c-90b1-8f72e45c525c}")
)


Same region + union with another non overlapping region:
(
    (-1 . <Entity name: 23baabc4900>)
    (0 . "REGION")
    (330 . <Entity name: 23baabc3f00>)
    (5 . "88")
    (100 . "AcDbEntity")
    (67 . 0)
    (410 . "Model")
    (8 . "0")
    (100 . "AcDbModelerGeometry")
    (70 . 1)
    (1 . "22300 52 2 4")
    (1 . "16 Autodesk AutoCAD 20 ASM 224.4.0.65535 NT 0")
    (1 . "1 9.999999999999999547e-07 1.000000000000000036e-10")
    (1 . "asmheader $-1 -1 @13 224.4.0.65535 #")
    (1 . "body $-1 -1 $-1 $2 $-1 $-1 #")
    (1 . "lump $-1 -1 $-1 $3 $4 $1 #")
    (1 . "lump $-1 -1 $-1 $-1 $5 $1 #")
    (1 . "shell $-1 -1 $-1 $-1 $-1 $6 $-1 $2 #")
    (1 . "shell $-1 -1 $-1 $-1 $-1 $7 $-1 $3 #")
    (1 . "face $-1 -1 $-1 $-1 $8 $4 $-1 $9 reversed double out #")
    (1 . "face $-1 -1 $-1 $-1 $10 $5 $-1 $11 reversed double out #")

    (1 . "loop $-1 -1 $-1 $-1 $12 $6 #")
    (1 . "plane-surface $-1 -1 $-1 174.4210358763432112 192.9197620524880676 0 -0 -0 -1 -1 0 0 forward_v I I I I #")
    (1 . "loop $-1 -1 $-1 $-1 $13 $7 #")
    (1 . "plane-surface $-1 -1 $-1 200.7612629815966727 60.44666626897787864 0 -0 -0 -1 -1 0 0 forward_v I I I I #")
    (1 . "coedge $-1 -1 $-1 $14 $15 $-1 $16 reversed $8 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $17 $18 $-1 $19 reversed $10 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $20 $12 $-1 $21 reversed $8 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $12 $20 $-1 $22 reversed $8 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $23 0 $24 91.60109087406408435 $12 $25 forward @7 unknown #")
    (1 . "coedge $-1 -1 $-1 $26 $13 $-1 $27 reversed $10 0 $-1 #")
    (1 . "coedge $-1 -1 $-1 $13 $26 $-1 $28 reversed $10 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $29 0 $30 91.60109087406408435 $13 $31 forward @7 unknown #")
    (1 . "coedge $-1 -1 $-1 $15 $14 $-1 $32 reversed $8 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $33 0 $23 84.90857223520652042 $14 $34 forward @7 unknown #")
    (1 . "edge $-1 -1 $-1 $24 0 $35 84.90857223520652042 $15 $36 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $16 0 $37 #")
    (1 . "vertex $-1 -1 $-1 $16 1 $38 #")
    (1 . "straight-curve $-1 -1 $-1 128.6204904393111974 235.3740481700913278 0 1 0 0 F 0 F 91.60109087406408435 #")
    (1 . "coedge $-1 -1 $-1 $18 $17 $-1 $39 reversed $10 0 $-1 #")
    (1 . "edge $-1 -1 $-1 $40 0 $29 84.90857223520652042 $17 $41 forward @7 unknown #")
    (1 . "edge $-1 -1 $-1 $30 0 $42 84.90857223520652042 $18 $43 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $19 0 $44 #")
    (1 . "vertex $-1 -1 $-1 $19 1 $45 #")
    (1 . "straight-curve $-1 -1 $-1 154.960717544564659 102.9009523865811389 0 1 0 0 F 0 F 91.60109087406408435 #")
    (1 . "edge $-1 -1 $-1 $35 0 $33 91.60109087406408435 $20 $46 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $21 0 $47 #")
    (1 . "straight-curve $-1 -1 $-1 128.6204904393111974 150.4654759348848074 0 0 1 0 F 0 F 84.90857223520652042 #")
    (1 . "vertex $-1 -1 $-1 $32 0 $48 #")
    (1 . "straight-curve $-1 -1 $-1 220.2215813133752818 235.3740481700913278 0 0 -1 0 F 0 F 84.90857223520652042 #")
    (1 . "point $-1 -1 $-1 128.6204904393111974 235.3740481700913278 0 #")
    (1 . "point $-1 -1 $-1 220.2215813133752818 235.3740481700913278 0 #")
    (1 . "edge $-1 -1 $-1 $42 0 $40 91.60109087406408435 $26 $49 forward @7 unknown #")
    (1 . "vertex $-1 -1 $-1 $27 0 $50 #")
    (1 . "straight-curve $-1 -1 $-1 154.960717544564659 17.99238015137461844 0 0 1 0 F 0 F 84.90857223520652042 #")
    (1 . "vertex $-1 -1 $-1 $39 0 $51 #")
    (1 . "straight-curve $-1 -1 $-1 246.5618084186287433 102.9009523865811389 0 0 -1 0 F 0 F 84.90857223520652042 #")
    (1 . "point $-1 -1 $-1 154.960717544564659 102.9009523865811389 0 #")
    (1 . "point $-1 -1 $-1 246.5618084186287433 102.9009523865811389 0 #")
    (1 . "straight-curve $-1 -1 $-1 220.2215813133752818 150.4654759348848074 0 -1 0 0 F 0 F 91.60109087406408435 #")
    (1 . "point $-1 -1 $-1 128.6204904393111974 150.4654759348848074 0 #")
    (1 . "point $-1 -1 $-1 220.2215813133752818 150.4654759348848074 0 #")
    (1 . "straight-curve $-1 -1 $-1 246.5618084186287433 17.99238015137461844 0 -1 0 0 F 0 F 91.60109087406408435 #")
    (1 . "point $-1 -1 $-1 154.960717544564659 17.99238015137461844 0 #")
    (1 . "point $-1 -1 $-1 246.5618084186287433 17.99238015137461844 0 #")
    (290 . 1)
    (2 . "{8d45a286-c301-c549-ba87-01e656a4a343}")
)


Thanks VovKa, cheers.
« Last Edit: June 21, 2020, 01:14:38 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Check if a region is complex
« Reply #13 on: June 21, 2020, 12:33:43 PM »
The exact mistake I was making, sorry. Your code works perfectly, and much faster than mine, thank you very much for your time!

No worries and you're most welcome.

As for the other issue I'm having, I guess I'm annoyed and think the peripheral region created by the 'addregion method is redundant, as it can be easily attained by 'UNION'ing the smaller regions, but isn't as easy to filter out (in my case the regions are kind of grouped, so I have one peripheral region per group, which means I can't only delete one biggest created region). Still, I think I might be able to get rid of them with cross-comparison of every created region (using 'subtract' to find the encompassing regions). If it proves too challenging, hear you in a few days. Thanks again! :wink:

If you don't solve it to your satisfaction please post sample drawings and your code efforts and I'll try to help. Cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst