Author Topic: How to Entmake region?  (Read 6582 times)

0 Members and 3 Guests are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
How to Entmake region?
« on: January 19, 2011, 04:08:42 AM »
How to Entmake region?

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to Entmake region?
« Reply #1 on: January 19, 2011, 04:44:39 AM »
It's the VBA function  8-)

Code: [Select]
vla-AddRegion


Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to Entmake region?
« Reply #2 on: January 19, 2011, 04:58:35 AM »
Here is one routine I made it from a while , you can use it for your own . :-)

Code: [Select]
(defun c:Addreg (/ *error* TH:UnDo TH:CAD TH:StartUnDo e obj Msapce Eobj TH:UnDo )
  ; THARWAT Nov. 04.2010
  (vl-load-com)
  (defun *error* ( msg )
    (and TH:UnDo (vla-EndUndoMark TH:CAD))
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )
  (setq TH:CAD
       (vla-get-ActiveDocument
           (vlax-get-acad-object ) ))
 (if (and (setq e
(car
   (entsel "\n Select [Rectangle,Circle] :")))
(or (eq (cdr
   (assoc 0 (entget e))) "CIRCLE")
     (eq (cdr
   (assoc 0 (entget e))) "LWPOLYLINE")
)
    )
  (progn
      (setq obj (vlax-ename->vla-object e)
    )
        (setq Msapce (vla-get-ModelSpace TH:CAD)
      )
          (setq Eobj  (vlax-safearray-fill
(vlax-make-safearray vlax-vbObject
  '(0 . 0))(list obj))
)
            (vla-addregion Msapce Eobj)
  (entdel e)
    )
  (princ "\n *** Object is not valid *** ")
  )
(princ)
)
Enjoy.

Tharwat

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to Entmake region?
« Reply #3 on: January 23, 2011, 02:24:03 AM »
Here is one routine I made it from a while
...
Thanks

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to Entmake region?
« Reply #4 on: January 23, 2011, 03:10:08 AM »
Is there way to addregion by selecting an inrernal point of PLine?

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to Entmake region?
« Reply #5 on: January 23, 2011, 07:14:37 AM »
What are you planning to do with Internal Point with region ?


HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to Entmake region?
« Reply #6 on: January 23, 2011, 08:18:17 AM »
Look at attached there are 2 example
- First is OK, but what about second one (right one).
- In case of the target area not a rectangle.

I'm wondering if ADDREGION can do the same by picking an internal point?

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to Entmake region?
« Reply #7 on: January 23, 2011, 08:24:37 AM »
Look at attached there are 2 example
- First is OK, but what about second one (right one).

Are you trying to make region at the area which is between the big and the small two rectangles ?

- In case of the target area not a rectangle.

It has to be closed to implement or to get the region shape of it .

Tharwat

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to Entmake region?
« Reply #8 on: January 23, 2011, 08:28:09 AM »
For this area

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to Entmake region?
« Reply #9 on: January 23, 2011, 08:45:21 AM »
Region do not accept open areas , it is like a solid mass .

Are you planning to get the areas of things like that afterall ? :?


Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to Entmake region?
« Reply #10 on: January 23, 2011, 09:13:02 AM »
Example:

Code: [Select]
(defun c:test ( / space e1 e2 ) (vl-load-com)

  (setq space
    (vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object))
      (if (= 1 (getvar 'CVPORT))
        'Paperspace
        'Modelspace
      )
    )
  )

  (if
    (and
      (setq e1 (car (entsel "\nSelect Outer Object: ")))
      (vlax-curve-isClosed e1)
      (setq e2 (car (entsel "\nSelect Inner Object: ")))
      (vlax-curve-isClosed e2)
    )
    (vla-Boolean
      (car (vlax-invoke space 'AddRegion (list (vlax-ename->vla-object e1)))) acSubtraction
      (car (vlax-invoke space 'AddRegion (list (vlax-ename->vla-object e2))))
    )
  )

  (princ)
)

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to Entmake region?
« Reply #11 on: January 24, 2011, 05:43:54 AM »
Example:
...
Thanks
But is this mean we cant ADDREGION by picking a point?

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to Entmake region?
« Reply #12 on: January 24, 2011, 05:47:10 AM »
Example:
...
Thanks
But is this mean we cant ADDREGION by picking a point?

What's the benefit of picking points to get REGION instead of Selection Set ? :realmad:

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to Entmake region?
« Reply #13 on: January 24, 2011, 06:12:46 AM »
What's the benefit of
...

Where I am working we need some information about the MAS
So we convert a closd area to region then get the needed information by using _massprop

I asked for a lisp to do that staff and a memener at CADTutor.net give me the answer
http://www.cadtutor.net/forum/showthread.php?24528-Lisp-to-find-Center-of-Gravity

But still there is step we cant find a solution
If it is a solid area but has a hall See previous attached

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: How to Entmake region?
« Reply #14 on: January 24, 2011, 07:02:25 AM »
Example:
...
Thanks
But is this mean we cant ADDREGION by picking a point?

What's the benefit of picking points to get REGION instead of Selection Set ? :realmad:

I think it is possible to do "only picking points", but now the solution is not so perfect.
(1) use command "_boundary" to pick a point , then it would generates some boundary objects
(2) cal each boundary object area
(3) convert all new boundary objects to regions one by one
(4) boolean (the Max area region)-(the other region).
(5) that is what you need?
« Last Edit: January 24, 2011, 07:05:37 AM by qjchen »
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)