TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: DRIU on December 29, 2011, 06:28:16 PM

Title: Buffer area
Post by: DRIU on December 29, 2011, 06:28:16 PM
Hi,

I'm trying to calculate area of the buffer. I offset line in both directions, connected ends of result lines. And I have problem then I want to calculate area of intersecting buffers. Hatching don't work, you can see result.
Is there any simple solution to my problem or do I have to deal with intersetwith function?
Title: Re: Buffer area
Post by: DEVITG on December 29, 2011, 06:44:40 PM
You can get the are by the (street1  wide) times (street2 wide)
Please upload it as a 2008 or less DWG
Title: Re: Buffer area
Post by: Kerry on December 29, 2011, 07:08:04 PM
You can get the are by the (street1  wide) times (street2 wide)
Please upload it as a 2008 or less DWG

not quite
You'll may need to take the angular relationship between the 'streets' into account.
... depends if the area is a true rectangle or just a parallelogram
Title: Re: Buffer area
Post by: DRIU on December 30, 2011, 01:30:25 AM
I added a real life example of buffer area I want to calculate.
Title: Re: Buffer area
Post by: Kerry on December 30, 2011, 01:41:03 AM

If it was me :
draw a closed polyline with the vertexes at the intersections bounding the area you are concerned with.
Query the polyline to determine it's area.

Title: Re: Buffer area
Post by: CAB on December 30, 2011, 08:56:14 AM
That looks like wall center lines with the offset wall lines cleaned up.
The exception is the dead end center line which would be flat and not rounded.
Just an observation.
Title: Re: Buffer area
Post by: DEVITG on December 31, 2011, 04:04:32 PM
Hi DRIU.

I use the AREA command , Object option , pick on the Hatch , and get it


Command: area

Specify first corner point or [Object/Add/Subtract]: o

Select objects:
Area = 2417.06, Perimeter = 487.90

It will be kept at the AREA system variable, until you take other AREA 


Command: (getvar "area")
2417.06



Title: Re: Buffer area
Post by: DRIU on January 01, 2012, 12:52:31 PM
I use the AREA command , Object option , pick on the Hatch , and get it

Thanks, but as it not hatching overlapping space, area is not correct.
Title: Re: Buffer area
Post by: DEVITG on January 01, 2012, 07:06:03 PM
If I sum the area of the 2 polylines , as posted by Kerry , it give me the same area I take from the AREA comand Obj Hatch


Command: area

Specify first corner point or [Object/Add/Subtract]: o

Select objects: I pick on the small blue polyline
Area = 110.26, Perimeter = 39.91

Command:
AREA
Specify first corner point or [Object/Add/Subtract]: o

Select objects:  the big polyline
Area = 2306.80, Perimeter = 448.00

Command:
AREA
Specify first corner point or [Object/Add/Subtract]: o

Select objects: the hatch
Area = 2417.06, Perimeter = 487.90

As it can be see , the sum of the 2 polys area is equal to the hacht area

Please clear me.
Title: Re: Buffer area
Post by: m4rdy on January 01, 2012, 11:37:05 PM
Hi,

And I have problem then I want to calculate area of intersecting buffers. Hatching don't work, you can see result.


I dont know if this can help you, and i forgot the original author.
Assume if boundaries are lwpolyline.
Code: [Select]
(defun c:minters (/ *acad* *acdoc* ss space clst rlst reg hatch)
  (vl-load-com)
  (setvar "cmdecho" 0)
  (or *acad* (setq *acad* (vlax-get-acad-object)))
  (or *acdoc* (setq *acdoc* (vla-get-activedocument *acad*)))
  (if (ssget '((0 . "CIRCLE,LWPOLYLINE")))
    (progn (vlax-for c (setq ss (vla-get-activeselectionset *acdoc*))
             (setq clst (cons c clst))
           )
           (vla-delete ss)
           (setq space (if (= 1 (getvar 'cvport))
                         (vla-get-paperspace *acdoc*)
                         (vla-get-modelspace *acdoc*)
                       )
           )
           (setq rlst (vlax-invoke space 'addregion clst))
           (setq reg  (car rlst)
                 rlst (cdr rlst)
           )
           (while rlst
             (vla-boolean reg acintersection (car rlst))
             (setq rlst (cdr rlst))
           )
           (if (< 0.0 (vla-get-area reg))
             (progn (setq hatch (vla-addhatch space achatchpatterntypepredefined "ANSI31" :vlax-false 0)
                    )
                    (vlax-invoke hatch 'appendouterloop (list reg))
                    (vlax-put-property hatch 'patternscale 100.)
                    (vlax-put-property hatch 'color acred)
                    (vla-evaluate hatch)
                    (command "Explode" (vlax-vla-object->ename reg))
                    ;;(vla-delete reg)
                    (setvar "PEDITACCEPT" 1)
                    (command "_.PEDIT"
                             "_M"
                             "P"
                             ""
                             "_J"
                             0.0
                             "w"
                             10.
                             ""
                    )
    (command "_.CHPROP"  "L"  ""  "C"  6  "");_=>>substitute with function area
                    )
             )
           )
    )
  )
  (princ)
)

m4rdy
Title: Re: Buffer area
Post by: Kerry on January 01, 2012, 11:44:30 PM

The thing that sidetracks most problem solving is definition of terms.

What is a buffer area. ?
Title: Re: Buffer area
Post by: DRIU on January 03, 2012, 10:21:21 PM
Thank you m4rdy for code, I had no knowledge about regions and about union. That's what I was looking for.

Code: [Select]
(vla-boolean _o1 acUnion _o2)