Created
June 20, 2024 13:44
-
-
Save timrwood/8e538b7e428ae5e79c0584e9c65d6b37 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import Rhino | |
import scriptcontext as sc | |
import random | |
def RandomTranslateBoxMapping(): | |
go = Rhino.Input.Custom.GetObject() | |
go.SetCommandPrompt("Select surfaces to remap") | |
go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface | |
go.GetMultiple(1, 0) | |
if (go.CommandResult() != Rhino.Commands.Result.Success): | |
return | |
surfaces = go.Objects() | |
scale = 2000 | |
if sc.sticky.has_key('RandomTranslateBoxMapping_Scale'): | |
scale = sc.sticky['RandomTranslateBoxMapping_Scale'] | |
rc, scale = Rhino.Input.RhinoGet.GetNumber( | |
'XYZ Size', True, scale, lowerLimit=1, upperLimit=10000) | |
if rc != Rhino.Commands.Result.Success: | |
return | |
sc.sticky['RandomTranslateBoxMapping_Scale'] = scale | |
for surface_ref in surfaces: | |
surface = surface_ref.Object() | |
x = random.uniform(0, scale) | |
y = random.uniform(0, scale) | |
z = random.uniform(0, scale) | |
origin = Rhino.Geometry.Point3d(x, y, z) | |
plane = Rhino.Geometry.Plane( | |
origin, Rhino.Geometry.Vector3d.ZAxis) | |
interval = Rhino.Geometry.Interval(0, scale) | |
mapping = Rhino.Render.TextureMapping.CreateBoxMapping( | |
plane, interval, interval, interval, True) | |
surface.SetTextureMapping(1, mapping) | |
if __name__ == '__main__': | |
RandomTranslateBoxMapping() |
This file contains hidden or 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
bd BooleanDifference | |
bi BooleanIntersection | |
Break ! _DeleteSubCrv | |
bu BooleanUnion | |
C copy | |
cb curveboolean | |
cc move | |
COff '_CurvatureGraphOff | |
COn '_CurvatureGraph | |
cpr CPlane R 0 Z 90 | |
cpt SetView C T | |
d line | |
dd polyline | |
dx distribute x | |
dy distribute y | |
e extend | |
ee connect | |
f matchlayer | |
g join | |
M ! _Move | |
Make3D Extrude | |
ne '_Isometric ne | |
nw '_Isometric nw | |
O '_Ortho | |
P '_Planar | |
POff ! _PointsOff | |
POn ! _PointsOn | |
q delete | |
S split | |
s1 scale1d | |
s2 scale2d | |
se '_Isometric se | |
SelPolysurface '_SelPolysrf | |
ss trim | |
sw '_Isometric sw | |
U _Undo | |
W mirror | |
x explode | |
Z '_Zoom | |
ZE '_Zoom _Extents | |
ZEA '_Zoom _All _Extents | |
ZS '_Zoom _Selected | |
ZSA '_Zoom _All _Selected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment