center of polygon area

center of polygon area

Anonymous
Not applicable
2,599 Views
4 Replies
Message 1 of 5

center of polygon area

Anonymous
Not applicable
hello
i need to get the center of area of any polygon.
it should be always inside the polygon
thanks
0 Likes
2,600 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Like I said: create region from the ploygon and query the Centroid property
of the region.

--
http://www.acadx.com

Good judgment comes from experience.
Experience comes from bad judgment.


"Jimmy Lopez" wrote in message
news:[email protected]...
> hello
> i need to get the center of area of any polygon.
> it should be always inside the polygon
> thanks
>
>
>
>
0 Likes
Message 3 of 5

Anonymous
Not applicable
Jimmy,

Here is how that is done.

Joe

Public Sub GetCenterOfPolygon()
Dim Entity As AcadEntity
Dim Region As AcadRegion
Dim Polylist(0 To 0) As AcadEntity
Dim Point(0 To 2) As Double
Dim Index As Integer

ThisDrawing.Utility.GetEntity Entity, Point, "Select polygon"

If Entity.ObjectName = "AcDbPolyline" Then
Set Polylist(0) = Entity
ThisDrawing.ModelSpace.AddRegion Polylist

'Find centroid
For Index = 0 To ThisDrawing.ModelSpace.Count - 1
If ThisDrawing.ModelSpace.Item(Index).ObjectName = "AcDbRegion" Then 'Region ?
Set Region = ThisDrawing.ModelSpace.Item(Index)
MsgBox "Centroid X: " & Region.Centroid(0) & vbCrLf & "Centroid Y: " & Region.Centroid(1)
End If
Next Index
End If
'delete region when done
Region.Delete
End Sub


"Frank Oquendo" wrote in message news:[email protected]...
> Like I said: create region from the ploygon and query the Centroid property
> of the region.
>
> --
> http://www.acadx.com
>
> Good judgment comes from experience.
> Experience comes from bad judgment.
>
>
> "Jimmy Lopez" wrote in message
> news:[email protected]...
> > hello
> > i need to get the center of area of any polygon.
> > it should be always inside the polygon
> > thanks
> >
> >
> >
> >
>
>
0 Likes
Message 4 of 5

Anonymous
Not applicable
hello joe!!
thanks for your help.
Maybe i didn't explain what i need. sometimes my english is not good.
i have a function for getting the centroid of polygon, like the application
you sent me, but i don't create a region.
i just sum x and y coordinates and i get the centroide.

what a really need is, for example in an irregular polygon like an L, the
centroid is outside of it.
i need the centroid always inside. i don't know if i'm talking about
centroid and this is wrong.
do you know Autocad Map?? have you created topologies?? i need the point
like autocad map puts the centroid.
or like arcinfo the same.

thanks very much for your time.
I develope applications in AutoCad and AutoCad Map, working with topologies,
object data, databases etc.
basically GIS, and sometimes i have 50000 polygons for processing.
if i can help you anytime i'm here!!


"Joe Sutphin" wrote in message
news:[email protected]...
> Jimmy,
>
> Here is how that is done.
>
> Joe
>
> Public Sub GetCenterOfPolygon()
> Dim Entity As AcadEntity
> Dim Region As AcadRegion
> Dim Polylist(0 To 0) As AcadEntity
> Dim Point(0 To 2) As Double
> Dim Index As Integer
>
> ThisDrawing.Utility.GetEntity Entity, Point, "Select polygon"
>
> If Entity.ObjectName = "AcDbPolyline" Then
> Set Polylist(0) = Entity
> ThisDrawing.ModelSpace.AddRegion Polylist
>
> 'Find centroid
> For Index = 0 To ThisDrawing.ModelSpace.Count - 1
> If ThisDrawing.ModelSpace.Item(Index).ObjectName = "AcDbRegion" Then
'Region ?
> Set Region = ThisDrawing.ModelSpace.Item(Index)
> MsgBox "Centroid X: " & Region.Centroid(0) & vbCrLf & "Centroid Y:
" & Region.Centroid(1)
> End If
> Next Index
> End If
> 'delete region when done
> Region.Delete
> End Sub
>
>
> "Frank Oquendo" wrote in message
news:[email protected]...
> > Like I said: create region from the ploygon and query the Centroid
property
> > of the region.
> >
> > --
> > http://www.acadx.com
> >
> > Good judgment comes from experience.
> > Experience comes from bad judgment.
> >
> >
> > "Jimmy Lopez" wrote in message
> > news:[email protected]...
> > > hello
> > > i need to get the center of area of any polygon.
> > > it should be always inside the polygon
> > > thanks
> > >
> > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 5 of 5

Anonymous
Not applicable
Hello Jimmy,
I want to know if you have find a solution for your problem, because I have the seem.
Thanks
0 Likes