From c17613637ebe783ae4b1e497b13373b8cb867777 Mon Sep 17 00:00:00 2001 From: trav Date: Wed, 20 May 2020 13:46:47 -0400 Subject: [PATCH] Add SampleQuadRemesh.py to v7 examples --- rhinopython/SampleQuadRemesh.py | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 rhinopython/SampleQuadRemesh.py diff --git a/rhinopython/SampleQuadRemesh.py b/rhinopython/SampleQuadRemesh.py new file mode 100644 index 00000000..fc4cf0ba --- /dev/null +++ b/rhinopython/SampleQuadRemesh.py @@ -0,0 +1,42 @@ +################################################################################ +# SampleQuadRemesh.py +# Copyright (c) 2020 Robert McNeel & Associates. +# See License.md in the root of this repository for details. +################################################################################ +import Rhino +import scriptcontext + + +def SampleQuadRemesh(): + + go = Rhino.Input.Custom.GetObject() + go.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh + go.GeometryAttributeFilter = Rhino.Input.Custom.GeometryAttributeFilter.ClosedCurve + go.SetCommandPrompt("Select Mesh to QuadRemesh") + go.Get() + if(go.CommandResult() != Rhino.Commands.Result.Success): + return go.CommandResult() + + mesh = go.Object(0).Mesh() + + qr_params = Rhino.Geometry.QuadRemeshParameters() + qr_params.AdaptiveQuadCount=True + qr_params.TargetQuadCount = 2000 + qr_params.AdaptiveSize = 50 + qr_params.DetectHardEdges=True + qr_params.SymmetryAxis = Rhino.Geometry.QuadRemeshSymmetryAxis.X | Rhino.Geometry.QuadRemeshSymmetryAxis.Y | Rhino.Geometry.QuadRemeshSymmetryAxis.Z + + + remeshed = mesh.QuadRemesh(qr_params) + + + scriptcontext.doc.ActiveDoc.Objects.Add(remeshed) + scriptcontext.doc.ActiveDoc.Views.Redraw + + return Rhino.Commands.Result.Success + +# Check to see if this file is being executed as the "main" python +# script instead of being used as a module by some other python script +# This allows us to use the module which ever way we want. +if( __name__ == '__main__' ): + SampleQuadRemesh() \ No newline at end of file