-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SampleQuadRemesh.py to v7 examples
- Loading branch information
1 parent
72bb746
commit c176136
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |