McNeel Wiki
Marking Center Points of Closed Curves
edit · print · help · all topics
Main Pages

AccuRender

Bongo

Brazil r/s

Developer

Flamingo

Penguin

Rhino Blogs

Rhino

Rhino Labs

Search

Languages

Česky

Deutsch

English

Español

Français

Italiano

Polish

日本語

한국어

中文(繁體)

中文(简体)

 
.
DeveloperRhinoScript
SummaryDemonstrates how to mark the center points of closed planar curves with a point object.

Question

I have a pattern of circles from which I need to extract their center points. Is there a command or script that I can use to do this?

Answer

Yes. See the following RhinoScript code.

  Sub MarkCenterPoints()
    Dim curves, crv, pt, arr
    curves = Rhino.GetObjects("Select closed planar curves", 4, ,True)
    If IsArray(curves) Then
      Rhino.EnableRedraw False
      For Each crv In curves
        pt = vbNull
        If Rhino.IsCircle(crv) Then
          pt = Rhino.CircleCenterPoint(crv)
        Else
          arr = Rhino.CurveAreaCentroid(crv)
          If IsArray(arr) Then pt = arr(0)
        End If
        If IsArray(pt) Then
          Rhino.SelectObject Rhino.AddPoint(pt)
        End If
      Next        
      Rhino.EnableRedraw True
    End If
  End Sub

Here is a button macro version of the above script:

  ! _-Runscript (
  curves = Rhino.GetObjects("Select closed planar curves", 4, ,True)
  If IsArray(curves) Then
  Rhino.EnableRedraw False
  For Each crv In curves
  pt = vbNull
  If Rhino.IsCircle(crv) Then
  pt = Rhino.CircleCenterPoint(crv)
  Else
  arr = Rhino.CurveAreaCentroid(crv)
  If IsArray(arr) Then pt = arr(0)
  End If
  If IsArray(pt) Then
  Rhino.SelectObject Rhino.AddPoint(pt)
  End If
  Next        
  Rhino.EnableRedraw True
  End If
  ) 
rename · changes · history · subscriptions · lost and found · references · file upload